Functions related to OTTD's strings. More...
#include "strings_type.h"
#include "string_type.h"
#include "gfx_type.h"
Go to the source code of this file.
Data Structures | |
class | StringParameters |
class | MissingGlyphSearcher |
A searcher for missing glyphs. More... | |
Functions | |
char * | InlineString (char *buf, StringID string) |
char * | GetString (char *buffr, StringID string, const char *last) |
char * | GetStringWithArgs (char *buffr, StringID string, StringParameters *args, const char *last, uint case_index=0, bool game_script=false) |
Get a parsed string with most special stringcodes replaced by the string parameters. | |
const char * | GetStringPtr (StringID string) |
void | InjectDParam (uint amount) |
Shift the string parameters in the global string parameter array by amount positions, making room at the beginning. | |
static void | SetDParamX (uint64 *s, uint n, uint64 v) |
Set a string parameter v at index n in a given array s. | |
static void | SetDParam (uint n, uint64 v) |
Set a string parameter v at index n in the global string parameter array. | |
void | SetDParamStr (uint n, const char *str) |
This function is used to "bind" a C string to a OpenTTD dparam slot. | |
void | CopyInDParam (int offs, const uint64 *src, int num) |
Copy num string parameters from array src into the global string parameter array. | |
void | CopyOutDParam (uint64 *dst, int offs, int num) |
Copy num string parameters from the global string parameter array to the dst array. | |
void | CopyOutDParam (uint64 *dst, const char **strings, StringID string, int num) |
Copy num string parameters from the global string parameter array to the dst array. | |
static uint64 | GetDParamX (const uint64 *s, uint n) |
Get the current string parameter at index n from parameter array s. | |
static uint64 | GetDParam (uint n) |
Get the current string parameter at index n from the global string parameter array. | |
void | InitializeLanguagePacks () |
Make a list of the available language packs. | |
const char * | GetCurrentLanguageIsoCode () |
Get the ISO language code of the currently loaded language. | |
int CDECL | StringIDSorter (const StringID *a, const StringID *b) |
void | CheckForMissingGlyphs (bool base_font=true, MissingGlyphSearcher *search=NULL) |
Check whether the currently loaded language pack uses characters that the currently loaded font does not support. | |
Variables | |
StringParameters | _global_string_params |
TextDirection | _current_text_dir |
Text direction of the currently selected language. |
Functions related to OTTD's strings.
Definition in file strings_func.h.
void CheckForMissingGlyphs | ( | bool | base_font, | |
MissingGlyphSearcher * | searcher | |||
) |
Check whether the currently loaded language pack uses characters that the currently loaded font does not support.
If this is the case an error message will be shown in English. The error message will not be localized because that would mean it might use characters that are not in the font, which is the whole reason this check has been added.
base_font | Whether to look at the base font as well. | |
searcher | The methods to use to search for strings to check. If NULL the loaded language pack searcher is used. |
Definition at line 1996 of file strings.cpp.
References _current_text_dir, MissingGlyphSearcher::FindMissingGlyphs(), InitFreeType(), INVALID_STRING_ID, LanguagePackHeader::isocode, LoadStringWidthTable(), MissingGlyphSearcher::Monospace(), SetDParamStr(), SetFallbackFont(), ShowErrorMessage(), TD_LTR, Utf8Encode(), LanguagePackHeader::winlangid, WL_ERROR, and WL_WARNING.
Referenced by HandleBootstrap(), LoadIntroGame(), TextfileWindow::LoadTextfile(), and GameOptionsWindow::OnDropdownSelect().
void CopyInDParam | ( | int | offs, | |
const uint64 * | src, | |||
int | num | |||
) |
Copy num string parameters from array src into the global string parameter array.
offs | Index in the global array to copy the first string parameter to. | |
src | Source array of string parameters. | |
num | Number of string parameters to copy. |
Definition at line 81 of file strings.cpp.
References StringParameters::GetPointerToOffset(), and MemCpyT().
Referenced by DrawNewsString(), NewsWindow::DrawWidget(), QueryWindow::SetStringParameters(), and NewsWindow::UpdateWidgetSize().
void CopyOutDParam | ( | uint64 * | dst, | |
int | offs, | |||
int | num | |||
) |
Copy num string parameters from the global string parameter array to the dst array.
dst | Destination array of string parameters. | |
offs | Index in the global array to copy the first string parameter from. | |
num | Number of string parameters to copy. |
Definition at line 92 of file strings.cpp.
References StringParameters::GetPointerToOffset(), and MemCpyT().
Referenced by AddNewsItem(), and ErrorMessageData::ErrorMessageData().
void CopyOutDParam | ( | uint64 * | dst, | |
const char ** | strings, | |||
StringID | string, | |||
int | num | |||
) |
Copy num string parameters from the global string parameter array to the dst array.
Furthermore clone raw string parameters into strings and amend the data in dst.
dst | Destination array of string parameters. | |
strings | Destination array for clone of the raw strings. Must be of same length as dst. Deallocation left to the caller. | |
string | The string used to determine where raw strings are and where there are no raw strings. | |
num | Number of string parameters to copy. |
Definition at line 105 of file strings.cpp.
References DRAW_STRING_BUFFER, StringParameters::GetPointerToOffset(), StringParameters::GetTypeAtOffset(), StringParameters::HasTypeInformation(), lastof, and MemCpyT().
const char* GetCurrentLanguageIsoCode | ( | ) |
Get the ISO language code of the currently loaded language.
Definition at line 1892 of file strings.cpp.
References LanguagePackHeader::isocode.
Referenced by GameOptionsWindow::DrawWidget(), GetTextfile(), and GameOptionsWindow::UpdateWidgetSize().
static uint64 GetDParam | ( | uint | n | ) | [inline, static] |
Get the current string parameter at index n from the global string parameter array.
n | Index of the string parameter. |
Definition at line 189 of file strings_func.h.
static uint64 GetDParamX | ( | const uint64 * | s, | |
uint | n | |||
) | [inline, static] |
Get the current string parameter at index n from parameter array s.
s | Array of string parameters. | |
n | Index of the string parameter. |
Definition at line 179 of file strings_func.h.
Referenced by ErrorMessageData::ErrorMessageData().
char* GetStringWithArgs | ( | char * | buffr, | |
StringID | string, | |||
StringParameters * | args, | |||
const char * | last, | |||
uint | case_index, | |||
bool | game_script | |||
) |
Get a parsed string with most special stringcodes replaced by the string parameters.
buffr | Pointer to a string buffer where the formatted string should be written to. | |
string | ||
args | Arguments for the string. | |
last | Pointer just past the end of buffr. | |
case_index | The "case index". This will only be set when FormatString wants to print the string in a different case. | |
game_script | The string is coming directly from a game script. |
Definition at line 161 of file strings.cpp.
References _langtab_num, error(), FormatString(), GAME_TEXT_TAB, GB(), GetGameStringPtr(), GetGRFStringID(), GetGRFStringPtr(), StringParameters::GetInt32(), GetStringWithArgs(), HasBit(), TAB_COUNT_BITS, TAB_COUNT_OFFSET, TAB_SIZE_BITS, and TAB_SIZE_OFFSET.
Referenced by FormatString(), GetStringWithArgs(), and GetTownName().
void InitializeLanguagePacks | ( | ) |
Make a list of the available language packs.
Put the data in _languages list.
< Matching the language in the configuration file or the current locale
< Using pt_PT for pt_BR locale when pt_BR is not available
< Fallback when no locale-matching language has been found
Definition at line 1844 of file strings.cpp.
References _config_language_file, SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), LanguageMetadata::file, FOR_ALL_SEARCHPATHS, GetCurrentLocale(), GetLanguageList(), LANG_DIR, SmallVector< T, S >::Length(), lengthof, ReadLanguagePack(), and usererror().
void InjectDParam | ( | uint | amount | ) |
Shift the string parameters in the global string parameter array by amount positions, making room at the beginning.
amount | Number of positions to shift. |
Definition at line 249 of file strings.cpp.
References StringParameters::ShiftParameters().
Referenced by Subsidy::AwardTo().
static void SetDParam | ( | uint | n, | |
uint64 | v | |||
) | [inline, static] |
Set a string parameter v at index n in the global string parameter array.
n | Index of the string parameter. | |
v | Value of the string parameter. |
Definition at line 162 of file strings_func.h.
Referenced by AdvertiseIndustryOpening(), AgeVehicle(), AircraftEntersTerminal(), AircraftHandleDestTooFar(), Subsidy::AwardTo(), CcBuildIndustry(), ChangeIndustryProduction(), NetworkChatWindow::ChatTabCompletionNextItem(), CheckAllowRemoveRoad(), CheckCompanyHasMoney(), ClientNetworkGameSocketHandler::CheckConnection(), CheckforTownRating(), CheckIfAuthorityAllowsNewStation(), CheckOrders(), CheckTrainCollision(), CheckTrainsLengths(), ClearTile_Station(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildIndustry(), CmdCompanyCtrl(), CmdDecreaseLoan(), CmdFoundTown(), CmdIncreaseLoan(), CompanyCheckBankrupt(), VehicleGroupWindow::ComputeGroupInfoSize(), CrashAirplane(), Disaster_CoalMine_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Zeppeliner(), DoCommandPInternal(), CargoesField::Draw(), DrawAircraftDetails(), StationViewWindow::DrawCargoRatings(), NetworkContentListWindow::DrawDetails(), DrawEngineList(), StationViewWindow::DrawEntries(), SelectCompanyManagerFaceWindow::DrawFaceStringLabel(), BaseGraphWindow::DrawGraph(), VehicleGroupWindow::DrawGroupInfo(), IndustryViewWindow::DrawInfo(), DrawOrderString(), DrawPrice(), TownAuthorityWindow::DrawRatings(), DrawRoadVehDetails(), NetworkGameWindow::DrawServerLine(), SettingEntry::DrawSetting(), DrawShipDetails(), SmallMapWindow::DrawTowns(), DrawTrainDetails(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehiclePurchaseInfo(), DrawVehicleRefitWindow(), VehicleViewWindow::DrawWidget(), VehicleDetailsWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), TownViewWindow::DrawWidget(), TownAuthorityWindow::DrawWidget(), ScenarioEditorToolbarWindow::DrawWidget(), TimetableWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), StatusBarWindow::DrawWidget(), SelectStationWindow< T >::DrawWidget(), CompanyStationsWindow::DrawWidget(), SmallMapWindow::DrawWidget(), BuildRailStationWindow::DrawWidget(), OrdersWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), MessageHistoryWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), MusicWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), TooltipsWindow::DrawWidget(), SelectGameWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), CompanyLeagueWindow::DrawWidget(), PaymentRatesGraphWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), EnginePreviewWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), CompanyWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), CompanyFinancesWindow::DrawWidget(), CheatWindow::DrawWidget(), BuildBridgeWindow::DrawWidget(), ReplaceVehicleWindow::DrawWidget(), BuildAirportWindow::DrawWidget(), AISettingsWindow::DrawWidget(), AIListWindow::DrawWidget(), DrawYearColumn(), EngineNameSorter(), ErrorUnknownCallbackResult(), FloodVehicle(), GenerateCompanyName(), GenerateDefaultSaveName(), GeneratePresidentName(), RefitWindow::GetCapacityString(), StationViewWindow::GetEntryString(), IndustryDirectoryWindow::GetIndustryString(), GetNameOfOwner(), GetSaveLoadErrorString(), BaseGraphWindow::GetYLabelWidth(), GRFLoadConfig(), VehicleGroupWindow::GroupNameSorter(), Vehicle::HandlePathfindingResult(), IndustryDirectoryWindow::IndustryNameSorter(), IndustryProductionCallback(), IndustryTypeNameSorter(), NetworkHandlePauseChange(), NetworkServerSendChat(), NewVehicleAvailable(), WaypointWindow::OnClick(), VehicleDetailsWindow::OnClick(), TownViewWindow::OnClick(), TimetableWindow::OnClick(), StationViewWindow::OnClick(), CustomCurrencyWindow::OnClick(), GameSettingsWindow::OnClick(), OrdersWindow::OnClick(), NewGRFParametersWindow::OnClick(), IndustryViewWindow::OnClick(), CreateScenarioWindow::OnClick(), DepotWindow::OnClick(), SetDateWindow::OnClick(), CompanyWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), CheatWindow::OnClick(), BuildVehicleWindow::OnClick(), AISettingsWindow::OnClick(), SmallMapWindow::OnInit(), LandInfoWindow::OnInit(), IndustryCargoesWindow::OnInit(), SelectCompanyManagerFaceWindow::OnInit(), StationViewWindow::OnPaint(), HighScoreWindow::OnPaint(), EndGameWindow::OnPaint(), ReplaceVehicleWindow::OnPaint(), BuildAirportWindow::OnPaint(), BuildIndustryWindow::OnPlaceObject(), DepotWindow::OnRightClick(), ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO(), ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(), ReportNewsProductionChangeIndustry(), RoadVehArrivesAt(), SaveHighScoreValue(), ServerNetworkAdminSocketHandler::SendCompanyInfo(), ServerNetworkAdminSocketHandler::SendCompanyUpdate(), SetArrivalDepartParams(), SetDParamStr(), NIHelper::SetObjectAtStringParameters(), NIHelper::SetSimpleStringParameters(), WaypointWindow::SetStringParameters(), ExtraViewportWindow::SetStringParameters(), VehicleViewWindow::SetStringParameters(), VehicleDetailsWindow::SetStringParameters(), VehicleListWindow::SetStringParameters(), RefitWindow::SetStringParameters(), TownDirectoryWindow::SetStringParameters(), TownViewWindow::SetStringParameters(), TownAuthorityWindow::SetStringParameters(), TimetableWindow::SetStringParameters(), StationViewWindow::SetStringParameters(), CompanyStationsWindow::SetStringParameters(), SmallMapWindow::SetStringParameters(), CustomCurrencyWindow::SetStringParameters(), GameDifficultyWindow::SetStringParameters(), GameOptionsWindow::SetStringParameters(), BuildSignalWindow::SetStringParameters(), BuildRailStationWindow::SetStringParameters(), BuildRailToolbarWindow::SetStringParameters(), OskWindow::SetStringParameters(), OrdersWindow::SetStringParameters(), BuildObjectWindow::SetStringParameters(), NewsWindow::SetStringParameters(), NewGRFParametersWindow::SetStringParameters(), SpriteAlignerWindow::SetStringParameters(), MusicTrackSelectionWindow::SetStringParameters(), QueryWindow::SetStringParameters(), SelectGameWindow::SetStringParameters(), IndustryCargoesWindow::SetStringParameters(), IndustryDirectoryWindow::SetStringParameters(), IndustryViewWindow::SetStringParameters(), BuildIndustryWindow::SetStringParameters(), VehicleGroupWindow::SetStringParameters(), GoalQuestionWindow::SetStringParameters(), CreateScenarioWindow::SetStringParameters(), DepotWindow::SetStringParameters(), BuyCompanyWindow::SetStringParameters(), CompanyWindow::SetStringParameters(), CompanyInfrastructureWindow::SetStringParameters(), SelectCompanyLiveryWindow::SetStringParameters(), CompanyFinancesWindow::SetStringParameters(), BuildVehicleWindow::SetStringParameters(), ReplaceVehicleWindow::SetStringParameters(), BuildAirportWindow::SetStringParameters(), AIConfigWindow::SetStringParameters(), AISettingsWindow::SetStringParameters(), AIListWindow::SetStringParameters(), SetTimetableParams(), SetupSubsidyDecodeParam(), ShipArrivesAt(), ShowCostOrIncomeAnimation(), ShowEstimatedCostOrIncome(), ShowFeederIncomeAnimation(), ShowFillingPercent(), ShowNewGRFError(), ShowNewGrfVehicleError(), ShowRejectOrAcceptNews(), SignList::SignNameFilter(), SignList::SignNameSorter(), CompanyStationsWindow::StationNameSorter(), ToolbarScenDatePanel(), TownDirectoryWindow::TownNameSorter(), TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TrainDetailsInfoTab(), TrainEnterStation(), UpdateFillingPercent(), Waypoint::UpdateVirtCoord(), Town::UpdateVirtCoord(), Station::UpdateVirtCoord(), Sign::UpdateVirtCoord(), VehicleDetailsWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), StatusBarWindow::UpdateWidgetSize(), SelectStationWindow< T >::UpdateWidgetSize(), CustomCurrencyWindow::UpdateWidgetSize(), GameDifficultyWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), BuildRailStationWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), NetworkJoinStatusWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), SelectGameWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), CompanyLeagueWindow::UpdateWidgetSize(), PaymentRatesGraphWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), CreateScenarioWindow::UpdateWidgetSize(), EnginePreviewWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), BuyCompanyWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), CheatWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), VehicleEnterDepot(), and VehicleNameSorter().
void SetDParamStr | ( | uint | n, | |
const char * | str | |||
) |
This function is used to "bind" a C string to a OpenTTD dparam slot.
n | slot of the string | |
str | string to bind |
Definition at line 240 of file strings.cpp.
References SetDParam().
Referenced by Subsidy::AwardTo(), CheckForMissingGlyphs(), CmdCompanyCtrl(), CmdCustomNewsItem(), CmdFoundTown(), CompanyCheckBankrupt(), DrawCargoListText(), NetworkContentListWindow::DrawDetails(), IndustryViewWindow::DrawInfo(), TownViewWindow::DrawWidget(), GameOptionsWindow::DrawWidget(), NewsWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), MusicWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), LandInfoWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), GoalQuestionWindow::DrawWidget(), GoalListWindow::DrawWidget(), AIConfigWindow::DrawWidget(), AISettingsWindow::DrawWidget(), AIListWindow::DrawWidget(), ErrorUnknownCallbackResult(), GenerateCompanyName(), TownViewWindow::GetDesiredInfoHeight(), IndustryDirectoryWindow::GetIndustryString(), GetSavegameFormat(), GetSaveLoadErrorString(), GRFLoadConfig(), IndustryProductionCallback(), IniLoadSettings(), MakeScreenshot(), CustomCurrencyWindow::OnClick(), LandInfoWindow::OnInit(), IConsoleWindow::OnPaint(), SaveFileError(), CustomCurrencyWindow::SetStringParameters(), GameOptionsWindow::SetStringParameters(), SpriteAlignerWindow::SetStringParameters(), NetworkLobbyWindow::SetStringParameters(), AboutWindow::SetStringParameters(), ShowNewGRFError(), ShowNewGrfVehicleError(), ShowRefitOptionsList(), StringToVal(), GameOptionsWindow::UpdateWidgetSize(), MusicWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), GoalQuestionWindow::UpdateWidgetSize(), and WarnCorruptSprite().
static void SetDParamX | ( | uint64 * | s, | |
uint | n, | |||
uint64 | v | |||
) | [inline, static] |
Set a string parameter v at index n in a given array s.
s | Array of string parameters. | |
n | Index of the string parameter. | |
v | Value of the string parameter. |
Definition at line 152 of file strings_func.h.