OpenTTD Source: src/strings_func.h File Reference

OpenTTD Source 15.0-beta1

Data Structures | Functions | Variables
strings_func.h File Reference

Functions related to OTTD's strings. More...

`#include "strings_type.h"`
`#include "string_type.h"`
`#include "gfx_type.h"`
`#include "core/bitmath_func.hpp"`
`#include "core/strong_typedef_type.hpp"`
`#include "vehicle_type.h"`

Go to the source code of this file.

## Data Structures
class | MissingGlyphSearcher
| A searcher for missing glyphs. More...

## Functions
StringTab | GetStringTab (StringID str)
| Extract the StringTab from a StringID.
uint | GetStringIndex (StringID str)
| Extract the StringIndex from a StringID.
StringID | MakeStringID (StringTab tab, uint index)
| Create a StringID.
std::string | GetString (StringID string)
| Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
const char * | GetStringPtr (StringID string)
void | AppendStringInPlace (std::string &result, StringID string)
| Resolve the given StringID and append in place into an existing std::string with all the associated DParam lookups and formatting.
uint | ConvertKmhishSpeedToDisplaySpeed (uint speed, VehicleType type)
| Convert the given km/h-ish speed to the display speed.
uint | ConvertDisplaySpeedToKmhishSpeed (uint speed, VehicleType type)
| Convert the given display speed to the km/h-ish speed.
int64_t | PackVelocity (uint speed, VehicleType type)
| Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
void | SetDParam (size_t n, uint64_t v)
| Set a string parameter v at index n in the global string parameter array.
void | SetDParamMaxValue (size_t n, uint64_t max_value, uint min_count=0, FontSize size=FS_NORMAL)
| Set DParam n to some number that is suitable for string size computations.
void | SetDParamMaxDigits (size_t n, uint count, FontSize size=FS_NORMAL)
| Set DParam n to some number that is suitable for string size computations.
template<typename T , std::enable_if_t< std::is_base_of< StrongTypedefBase, T >::value, int > = 0>
void | SetDParam (size_t n, T v)
template<typename T , std::enable_if_t< std::is_base_of< StrongTypedefBase, T >::value, int > = 0>
void | SetDParamMaxValue (size_t n, T max_value, uint min_count=0, FontSize size=FS_NORMAL)
void | SetDParamStr (size_t n, const char *str)
| This function is used to "bind" a C string to a OpenTTD dparam slot.
void | SetDParamStr (size_t n, const std::string &str)
| This function is used to "bind" the C string of a std::string to a OpenTTD dparam slot.
void | SetDParamStr (size_t n, std::string &&str)
| This function is used to "bind" the std::string to a OpenTTD dparam slot.
void | CopyInDParam (const std::span< const StringParameterData > backup)
| Copy the parameters from the backup into the global string parameter array.
void | CopyOutDParam (std::vector< StringParameterData > &backup, size_t num)
| Copy num string parameters from the global string parameter array to the backup.
bool | HaveDParamChanged (const std::span< const StringParameterData > backup)
| Checks whether the global string parameters have changed compared to the given backup.
uint64_t | GetDParam (size_t 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.
std::string_view | GetListSeparator ()
| Get the list separator string for the current language.
void | CheckForMissingGlyphs (bool base_font=true, MissingGlyphSearcher *search=nullptr)
| Check whether the currently loaded language pack uses characters that the currently loaded font does not support.

## Variables
TextDirection | _current_text_dir
| Text direction of the currently selected language.

## Detailed Description

Functions related to OTTD's strings.

Definition in file strings_func.h.

## Function Documentation

## ◆ AppendStringInPlace()

void AppendStringInPlace | ( | std::string & | result,
|  | StringID | string
| ) |  |

Resolve the given StringID and append in place into an existing std::string with all the associated DParam lookups and formatting.

Parameters

  result | The std::string to place the translated string.
  string | The unique identifier of the translatable string.

Definition at line 345 of file strings.cpp.

References GetStringWithArgs().

Referenced by DrawRoadVehDetails(), BuildIndustryWindow::MakeCargoListString(), DepotWindow::OnRightClick(), and ShowErrorMessage().

## ◆ CheckForMissingGlyphs()

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.

Parameters

  base_font | Whether to look at the base font as well.
  searcher | The methods to use to search for strings to check. If nullptr the loaded language pack searcher is used.

Definition at line 2291 of file strings.cpp.

References _current_text_dir, MissingGlyphSearcher::FindMissingGlyphs(), FontCacheSubSetting::font, InitFontCache(), INVALID_STRING_ID, LoadStringWidthTable(), FontCacheSettings::medium, FontCacheSettings::mono, MissingGlyphSearcher::Monospace(), FontCacheSubSetting::os_handle, SetDParamStr(), SetFallbackFont(), ShowErrorMessage(), TD_LTR, Utf8Encode(), WL_ERROR, and WL_WARNING.

Referenced by HandleBootstrap(), LoadIntroGame(), TextfileWindow::LoadText(), GameOptionsWindow::OnClick(), and GameOptionsWindow::OnDropdownSelect().

## ◆ ConvertDisplaySpeedToKmhishSpeed()

uint ConvertDisplaySpeedToKmhishSpeed | ( | uint | speed,
|  | VehicleType | type
| ) |  |

Convert the given display speed to the km/h-ish speed.

Parameters

  speed | the speed to convert

Returns
  the converted speed.

Definition at line 916 of file strings.cpp.

References Units::c, UnitConversion::FromDisplay(), and GetVelocityUnits().

Referenced by TimetableWindow::OnQueryTextFinished().

## ◆ ConvertKmhishSpeedToDisplaySpeed()

uint ConvertKmhishSpeedToDisplaySpeed | ( | uint | speed,
|  | VehicleType | type
| ) |  |

Convert the given km/h-ish speed to the display speed.

Parameters

  speed | the speed to convert

Returns
  the converted speed.

Definition at line 906 of file strings.cpp.

References Units::c, GetVelocityUnits(), and UnitConversion::ToDisplay().

Referenced by FormatString(), and TimetableWindow::OnClick().

## ◆ CopyInDParam()

void CopyInDParam | ( | const std::span< const StringParameterData > | backup | ) |

Copy the parameters from the backup into the global string parameter array.

Parameters

  backup | The backup to copy from.

Definition at line 159 of file strings.cpp.

Referenced by DrawNewsString(), ErrmsgWindow::DrawWidget(), TooltipsWindow::DrawWidget(), NewsWindow::DrawWidget(), ErrmsgWindow::SetStringParameters(), QueryWindow::SetStringParameters(), ErrmsgWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), and NewsWindow::UpdateWidgetSize().

## ◆ CopyOutDParam()

void CopyOutDParam | ( | std::vector< StringParameterData > & | backup,
|  | size_t | num
| ) |  |

Copy num string parameters from the global string parameter array to the backup.

Parameters

  backup | The backup to write to.
  num | Number of string parameters to copy.

Definition at line 171 of file strings.cpp.

Referenced by ErrorMessageData::CopyOutDParams(), and NewsItem::NewsItem().

## ◆ GetCurrentLanguageIsoCode()

const char * GetCurrentLanguageIsoCode | ( |  | ) |

Get the ISO language code of the currently loaded language.

Returns
  the ISO code.

Definition at line 2183 of file strings.cpp.

Referenced by GameOptionsWindow::DrawWidget(), GetTextfile(), and GameOptionsWindow::OnResize().

## ◆ GetDParam()

uint64_t GetDParam | ( | size_t | n | ) |

Get the current string parameter at index n from the global string parameter array.

Parameters

  n | Index of the string parameter.

Returns
  Value of the requested string parameter.

Definition at line 114 of file strings.cpp.

Referenced by ErrorMessageData::CopyOutDParams().

## ◆ GetListSeparator()

std::string_view GetListSeparator | ( |  | ) |

Get the list separator string for the current language.

Returns
  string containing list separator to use.

Definition at line 229 of file strings.cpp.

References LoadedLanguagePack::list_separator.

Referenced by BuildCargoAcceptanceString(), NetworkContentListWindow::DrawDetails(), DrawRoadVehDetails(), and FormatString().

## ◆ GetString()

std::string GetString | ( | StringID | string | ) |

Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.

Parameters

  string | The unique identifier of the translatable string.

Returns
  The std::string of the translated string.

Definition at line 333 of file strings.cpp.

References GetStringWithArgs().

Referenced by StringFilter::AddLine(), Textbuf::Assign(), Subsidy::AwardTo(), BuildCargoAcceptanceString(), BuildGuiGroupList(), CargoSpecNameSorter(), ClassTagNameFilter(), CmdFoundTown(), CmdGiveMoney(), CompanyNewsInformation::CompanyNewsInformation(), NewGRFInspectWindow::DrawMainPanelWidget(), DrawNewsString(), DrawRoadVehDetails(), DrawString(), DrawStringMultiLine(), EngineNameSorter(), ErrorUnknownCallbackResult(), BuildVehicleWindow::FilterByText(), FiosGetFileList(), GenerateCompanyName(), GenerateDefaultSaveName(), GeneratePresidentName(), GetCargoSuffix(), BuildHouseWindow::GetHouseInformation(), BuildHouseWindow::GetHouseYear(), GetKeyboardLayout(), BaseSet< T, Tnum_files, Tsearch_in_tars >::GetListLabel(), GetNewGRFAdditionalText(), GetStringBoundingBox(), GetStringHeight(), GetStringLineCount(), IndustryTypeNameSorter(), BuildIndustryWindow::MakeCargoListString(), NetworkHandlePauseChange(), NetworkServerSendChat(), LandInfoWindow::OnInit(), SignListWindow::OnInit(), SelectGameWindow::OnResize(), openttd_main(), ReadLanguagePack(), ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(), ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(), StoryBookWindow::RefreshSelectedPage(), SaveFileToDisk(), SaveHighScoreValue(), SaveHighScoreValueNetwork(), SaveOrLoad(), Script_CreateDummy(), ServerNetworkAdminSocketHandler::SendCompanyInfo(), ServerNetworkAdminSocketHandler::SendCompanyUpdate(), ServerNetworkAdminSocketHandler::SendError(), ServerNetworkGameSocketHandler::SendError(), ShowErrorMessage(), ShowNewGrfVehicleError(), TownActionRoadRebuild(), TranslateGRFStrings(), TypeTagNameFilter(), ScanProgressWindow::UpdateNewGRFScanStatus(), ViewportSign::UpdatePosition(), and VehicleNameSorter().

## ◆ GetStringIndex()

uint GetStringIndex | ( | StringID | str | ) |
| inline

Extract the StringIndex from a StringID.

Parameters

  str | String identifier

Returns
  StringIndex from str

Definition at line 38 of file strings_func.h.

References GetStringTab(), and TAB_SIZE_BITS.

Referenced by GetStringWithArgs().

## ◆ GetStringPtr()

const char * GetStringPtr | ( | StringID | string | ) |

Definition at line 234 of file strings.cpp.

## ◆ GetStringTab()

StringTab GetStringTab | ( | StringID | str | ) |
| inline

Extract the StringTab from a StringID.

Parameters

  str | String identifier

Returns
  StringTab from str

Definition at line 25 of file strings_func.h.

References TAB_SIZE_BITS, TEXT_TAB_GAMESCRIPT_START, and TEXT_TAB_NEWGRF_START.

Referenced by CopyFromOldName(), FormatString(), GetStringIndex(), GetStringWithArgs(), CITYChunkHandler::Load(), and PLYRChunkHandler::LoadCheck().

## ◆ HaveDParamChanged()

bool HaveDParamChanged | ( | const std::span< const StringParameterData > | backup | ) |

Checks whether the global string parameters have changed compared to the given backup.

Parameters

  backup | The backup to check against.

Returns
  True when the parameters have changed, otherwise false.

Definition at line 184 of file strings.cpp.

## ◆ InitializeLanguagePacks()

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 2136 of file strings.cpp.

References _config_language_file, _languages, LanguageMetadata::file, FillLanguageList(), FS2OTTD(), GetCurrentLocale(), LANG_DIR, and ReadLanguagePack().

Referenced by openttd_main().

## ◆ MakeStringID()

StringID MakeStringID | ( | StringTab | tab,
|  | uint | index
| ) |  |
| inline

Create a StringID.

Parameters

  tab | StringTab
  index | StringIndex

Returns
  StringID composed from tab and index

Definition at line 49 of file strings_func.h.

References TAB_SIZE, TAB_SIZE_BITS, TAB_SIZE_GAMESCRIPT, TAB_SIZE_NEWGRF, TEXT_TAB_END, TEXT_TAB_GAMESCRIPT_START, and TEXT_TAB_NEWGRF_START.

Referenced by AddGRFString(), FormatString(), and GetGRFStringID().

## ◆ PackVelocity()

int64_t PackVelocity | ( | uint | speed,
|  | VehicleType | type
| ) |  |
| inline

Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.

Parameters

  speed | Display speed for parameter.
  type | Type of vehicle for parameter.

Returns
  Bit-packed velocity and vehicle type, for use with SetDParam().

Definition at line 75 of file strings_func.h.

Referenced by DrawAircraftPurchaseInfo(), TimetableWindow::DrawTimetablePanel(), VehicleDetailsWindow::DrawWidget(), VehicleViewWindow::DrawWidget(), BuildBridgeWindow::GetBridgeSelectString(), LandInfoWindow::OnInit(), BuildRailToolbarWindow::SetStringParameters(), and BuildRoadToolbarWindow::SetStringParameters().

## ◆ SetDParam() [1/2]

template<typename T , std::enable_if_t< std::is_base_of< StrongTypedefBase, T >::value, int > = 0>

void SetDParam | ( | size_t | n,
|  | T | v
| ) |  |

Definition at line 87 of file strings_func.h.

## ◆ SetDParam() [2/2]

void SetDParam | ( | size_t | n,
|  | uint64_t | v
| ) |  |

Set a string parameter v at index n in the global string parameter array.

Parameters

  n | Index of the string parameter.
  v | Value of the string parameter.

Definition at line 104 of file strings.cpp.

Referenced by AdvertiseIndustryOpening(), AgeVehicle(), AircraftEntersTerminal(), AircraftHandleDestTooFar(), Subsidy::AwardTo(), BuildCargoAcceptanceString(), StoryBookWindow::BuildDropDownList(), GameOptionsWindow::BuildDropDownList(), BuildGuiGroupList(), BuildReplacementVehicle(), CalcRaildirsDrawstyle(), CcBuildIndustry(), ChangeIndustryProduction(), CheckAllowRemoveRoad(), CheckCompanyHasMoney(), ClientNetworkGameSocketHandler::CheckConnection(), CheckEngines(), CheckforTownRating(), CheckIfAuthorityAllowsNewStation(), CheckIndustries(), CheckOrders(), CheckTownRoadTypes(), CheckTrainCollision(), CheckTrainsLengths(), ClearTile_Station(), ClearTile_Town(), CmdBuildAirport(), CmdBuildBridge(), CmdCompanyCtrl(), CmdDecreaseLoan(), CmdFoundTown(), CmdGiveMoney(), CmdIncreaseLoan(), CmdIndustrySetProduction(), CompanyCheckBankrupt(), CompanyNewsInformation::CompanyNewsInformation(), CrashAirplane(), Disaster_CoalMine_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Zeppeliner(), StationViewWindow::DrawAcceptedCargo(), DrawAircraftDetails(), DrawAircraftPurchaseInfo(), TimetableWindow::DrawArrivalDeparturePanel(), StationViewWindow::DrawCargoRatings(), NetworkClientListWindow::DrawCompany(), CompanyInfrastructureWindow::DrawCountLine(), NetworkContentListWindow::DrawDetails(), DrawEngineList(), StationViewWindow::DrawEntries(), BaseGraphWindow::DrawGraph(), VehicleGroupWindow::DrawGroupInfo(), IndustryViewWindow::DrawInfo(), NewGRFInspectWindow::DrawMainPanelWidget(), DrawOrderString(), DrawPrice(), TownAuthorityWindow::DrawRatings(), DrawRoadVehDetails(), NetworkGameWindow::DrawServerLine(), SettingEntry::DrawSetting(), DrawShipDetails(), DrawSmallOrderList(), DrawStationCoverageAreaText(), TimetableWindow::DrawSummaryPanel(), TimetableWindow::DrawTimetablePanel(), SmallMapWindow::DrawTowns(), DrawTrainDetails(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehiclePurchaseInfo(), DrawVehicleRefitWindow(), ReplaceVehicleWindow::DrawWidget(), CheatWindow::DrawWidget(), SelectCompanyLiveryWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), CompanyWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), EnginePreviewWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), FramerateWindow::DrawWidget(), FrametimeGraphWindow::DrawWidget(), GSConfigWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), PaymentRatesGraphWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), IndustryProductionGraphWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), SelectGameWindow::DrawWidget(), PerformanceLeagueWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), MusicWindow::DrawWidget(), BaseNetworkContentDownloadStatusWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), MessageHistoryWindow::DrawWidget(), ScriptListWindow::DrawWidget(), ScriptSettingsWindow::DrawWidget(), GameSettingsWindow::DrawWidget(), SignListWindow::DrawWidget(), SmallMapWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), SelectStationWindow< T >::DrawWidget(), StatusBarWindow::DrawWidget(), StoryBookWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), TownAuthorityWindow::DrawWidget(), TownViewWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), VehicleDetailsWindow::DrawWidget(), VehicleViewWindow::DrawWidget(), DrawYearColumn(), EngineNameSorter(), ErrorUnknownCallbackResult(), BuildVehicleWindow::FilterByText(), FloodVehicle(), GenerateCompanyName(), GenerateDefaultSaveName(), GeneratePresidentName(), BuildBridgeWindow::GetBridgeSelectString(), RefitWindow::GetCapacityString(), StationViewWindow::GetEntryString(), BuildHouseWindow::GetHouseInformation(), BuildHouseWindow::GetHouseYear(), IndustryDirectoryWindow::GetIndustryString(), BaseSet< T, Tnum_files, Tsearch_in_tars >::GetListLabel(), GetRailTypeDropDownList(), BaseGraphWindow::GetYLabelWidth(), GRFLoadConfig(), Vehicle::HandlePathfindingResult(), IndustryProductionCallback(), CommandHelperBase::InternalExecuteProcessResult(), LoadTownData(), BuildIndustryWindow::MakeCargoListString(), MakeScreenshotWithConfirm(), NetworkHandlePauseChange(), NetworkServerSendChat(), NewVehicleAvailable(), BuildVehicleWindow::OnClick(), CheatWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), CompanyWindow::OnClick(), DepotWindow::OnClick(), GSConfigWindow::OnClick(), GenerateLandscapeWindow::OnClick(), CreateScenarioWindow::OnClick(), IndustryViewWindow::OnClick(), NetworkStartServerWindow::OnClick(), NewGRFParametersWindow::OnClick(), OrdersWindow::OnClick(), ScriptSettingsWindow::OnClick(), GameSettingsWindow::OnClick(), CustomCurrencyWindow::OnClick(), StationViewWindow::OnClick(), TimetableWindow::OnClick(), TownViewWindow::OnClick(), VehicleViewWindow::OnClick(), WaypointWindow::OnClick(), GenerateLandscapeWindow::OnDropdownSelect(), NetworkClientListWindow::OnDropdownSelect(), SelectCompanyManagerFaceWindow::OnInit(), LandInfoWindow::OnInit(), SmallMapWindow::OnInit(), BuildAirportWindow::OnPaint(), EndGameWindow::OnPaint(), HighScoreWindow::OnPaint(), GameSettingsWindow::OnPaint(), BuildIndustryWindow::OnPlaceObject(), CompanyWindow::OnResize(), SelectGameWindow::OnResize(), DepotWindow::OnRightClick(), ReplaceVehicleWindow::OnTooltip(), IndustryCargoesWindow::OnTooltip(), LinkGraphLegendWindow::OnTooltip(), RealMakeScreenshot(), ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(), StoryBookWindow::RefreshSelectedPage(), ReportNewsProductionChangeIndustry(), RoadVehArrivesAt(), SaveHighScoreValue(), SaveHighScoreValueNetwork(), ServerNetworkAdminSocketHandler::SendCompanyInfo(), ServerNetworkAdminSocketHandler::SendCompanyUpdate(), ServiceIntervalSettingsValueText(), SetDParamMaxDigits(), SetDParamsForOwnedBy(), SelectCompanyManagerFaceWindow::SetFaceStringParameters(), NIHelper::SetObjectAtStringParameters(), NIHelper::SetSimpleStringParameters(), AIConfigWindow::SetStringParameters(), BuildAirportWindow::SetStringParameters(), ReplaceVehicleWindow::SetStringParameters(), BuildVehicleWindow::SetStringParameters(), CompanyFinancesWindow::SetStringParameters(), SelectCompanyLiveryWindow::SetStringParameters(), CompanyInfrastructureWindow::SetStringParameters(), CompanyWindow::SetStringParameters(), BuyCompanyWindow::SetStringParameters(), SetDateWindow::SetStringParameters(), DepotWindow::SetStringParameters(), FramerateWindow::SetStringParameters(), FrametimeGraphWindow::SetStringParameters(), GenerateLandscapeWindow::SetStringParameters(), CreateScenarioWindow::SetStringParameters(), GoalListWindow::SetStringParameters(), GoalQuestionWindow::SetStringParameters(), IndustryProductionGraphWindow::SetStringParameters(), VehicleGroupWindow::SetStringParameters(), BuildIndustryWindow::SetStringParameters(), IndustryViewWindow::SetStringParameters(), IndustryDirectoryWindow::SetStringParameters(), IndustryCargoesWindow::SetStringParameters(), QueryStringWindow::SetStringParameters(), MusicTrackSelectionWindow::SetStringParameters(), ContentTextfileWindow::SetStringParameters(), NetworkStartServerWindow::SetStringParameters(), NetworkClientListWindow::SetStringParameters(), SpriteAlignerWindow::SetStringParameters(), NewGRFParametersWindow::SetStringParameters(), NewGRFTextfileWindow::SetStringParameters(), NewGRFWindow::SetStringParameters(), NewsWindow::SetStringParameters(), BuildObjectWindow::SetStringParameters(), OrdersWindow::SetStringParameters(), OskWindow::SetStringParameters(), BuildRailToolbarWindow::SetStringParameters(), BuildSignalWindow::SetStringParameters(), BuildRoadToolbarWindow::SetStringParameters(), ScriptListWindow::SetStringParameters(), ScriptSettingsWindow::SetStringParameters(), ScriptTextfileWindow::SetStringParameters(), ScriptDebugWindow::SetStringParameters(), BaseSetTextfileWindow::SetStringParameters(), GameOptionsWindow::SetStringParameters(), GameSettingsWindow::SetStringParameters(), CustomCurrencyWindow::SetStringParameters(), SignListWindow::SetStringParameters(), SignWindow::SetStringParameters(), SmallMapWindow::SetStringParameters(), CompanyStationsWindow::SetStringParameters(), StationViewWindow::SetStringParameters(), StoryBookWindow::SetStringParameters(), TimetableWindow::SetStringParameters(), ScenarioEditorToolbarWindow::SetStringParameters(), TownAuthorityWindow::SetStringParameters(), TownViewWindow::SetStringParameters(), TownDirectoryWindow::SetStringParameters(), RefitWindow::SetStringParameters(), VehicleListWindow::SetStringParameters(), VehicleDetailsWindow::SetStringParameters(), VehicleViewWindow::SetStringParameters(), ExtraViewportWindow::SetStringParameters(), WaypointWindow::SetStringParameters(), SetTimetableParams(), SettingsValueAbsolute(), SettingsValueVelocityUnit(), SetupSubsidyDecodeParam(), IntSettingDesc::SetValueDParams(), ShipArrivesAt(), ShowCostOrIncomeAnimation(), SetDateWindow::ShowDateDropDown(), ShowEstimatedCostOrIncome(), ShowFeederIncomeAnimation(), ShowFillingPercent(), ShowNewGRFError(), ShowNewGrfVehicleError(), ShowRefitOptionsList(), ShowRejectOrAcceptNews(), ToolbarScenDatePanel(), TownActionBuyRights(), TownActionRoadRebuild(), TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TrainDetailsInfoTab(), TrainEnterStation(), UpdateFillingPercent(), SettingEntry::UpdateFilterState(), Sign::UpdateVirtCoord(), Town::UpdateVirtCoord(), Station::UpdateVirtCoord(), Waypoint::UpdateVirtCoord(), ReplaceVehicleWindow::UpdateWidgetSize(), CheatWindow::UpdateWidgetSize(), SelectCompanyLiveryWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), BuyCompanyWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), EnginePreviewWindow::UpdateWidgetSize(), FramerateWindow::UpdateWidgetSize(), FrametimeGraphWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), CreateScenarioWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), PaymentRatesGraphWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), IndustryProductionGraphWindow::UpdateWidgetSize(), PerformanceLeagueWindow::UpdateWidgetSize(), ScriptLeagueWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), CustomCurrencyWindow::UpdateWidgetSize(), SelectStationWindow< T >::UpdateWidgetSize(), StatusBarWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), VehicleDetailsWindow::UpdateWidgetSize(), VehicleEnterDepot(), VehicleNameSorter(), VpSelectTilesWithMethod(), and VpSetPresizeRange().

## ◆ SetDParamMaxDigits()

void SetDParamMaxDigits | ( | size_t | n,
|  | uint | count,
|  | FontSize | size
| ) |  |

Set DParam n to some number that is suitable for string size computations.

Parameters

  n | Index of the string parameter.
  count | Number of digits which shall be displayable.
  size | Font of the number

Definition at line 143 of file strings.cpp.

References GetBroadestDigit(), and SetDParam().

Referenced by GetUnitNumberWidth(), SetDParamMaxValue(), DepotWindow::UpdateWidgetSize(), FramerateWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(), NetworkJoinStatusWindow::UpdateWidgetSize(), SpriteAlignerWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), and TownDirectoryWindow::UpdateWidgetSize().

## ◆ SetDParamMaxValue() [1/2]

template<typename T , std::enable_if_t< std::is_base_of< StrongTypedefBase, T >::value, int > = 0>

void SetDParamMaxValue | ( | size_t | n,
|  | T | max_value,
|  | uint | min_count = `0`,
|  | FontSize | size = `FS_NORMAL`
| ) |  |

Definition at line 93 of file strings_func.h.

## ◆ SetDParamMaxValue() [2/2]

void SetDParamMaxValue | ( | size_t | n,
|  | uint64_t | max_value,
|  | uint | min_count,
|  | FontSize | size
| ) |  |

Set DParam n to some number that is suitable for string size computations.

Parameters

  n | Index of the string parameter.
  max_value | The biggest value which shall be displayed. For the result only the number of digits of max_value matter.
  min_count | Minimum number of digits independent of max.
  size | Font of the number

Definition at line 127 of file strings.cpp.

References SetDParamMaxDigits().

Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), TimetableWindow::DrawTimetablePanel(), OrdersWindow::DrawWidget(), CheatWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), SetDateWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), CreateScenarioWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), NetworkGameWindow::UpdateWidgetSize(), NetworkJoinStatusWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), SignListWindow::UpdateWidgetSize(), StatusBarWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), and VehicleDetailsWindow::UpdateWidgetSize().

## ◆ SetDParamStr() [1/3]

void SetDParamStr | ( | size_t | n,
|  | const char * | str
| ) |  |

This function is used to "bind" a C string to a OpenTTD dparam slot.

Parameters

  n | slot of the string
  str | string to bind

Definition at line 371 of file strings.cpp.

Referenced by Subsidy::AwardTo(), GameOptionsWindow::BuildDropDownList(), CheckForMissingGlyphs(), CmdCompanyCtrl(), CmdCustomNewsItem(), CmdFoundTown(), CmdIndustrySetProduction(), CompanyCheckBankrupt(), NetworkClientListWindow::DrawCompany(), NetworkContentListWindow::DrawDetails(), IndustryViewWindow::DrawInfo(), GoalListWindow::DrawListColumn(), AIConfigWindow::DrawWidget(), FramerateWindow::DrawWidget(), GSConfigWindow::DrawWidget(), GoalQuestionWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), LandInfoWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), MusicWindow::DrawWidget(), BaseNetworkContentDownloadStatusWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), NewsWindow::DrawWidget(), ScriptListWindow::DrawWidget(), ScriptSettingsWindow::DrawWidget(), GameOptionsWindow::DrawWidget(), StoryBookWindow::DrawWidget(), TownViewWindow::DrawWidget(), ErrorUnknownCallbackResult(), FiosGetFileList(), GenerateCompanyName(), TownViewWindow::GetDesiredInfoHeight(), StoryBookWindow::GetHeadHeight(), IndustryDirectoryWindow::GetIndustryString(), BaseSet< T, Tnum_files, Tsearch_in_tars >::GetListLabel(), StoryBookWindow::GetPageElementHeight(), GetSavegameFormat(), GetSaveLoadErrorMessage(), GraphicsSetLoadConfig(), GRFLoadConfig(), IndustryProductionCallback(), LoadTownData(), BuildIndustryWindow::MakeCargoListString(), NetworkDrawChatMessage(), NetworkGameWindow::OnClick(), NetworkStartServerWindow::OnClick(), NetworkClientListWindow::OnClick(), CustomCurrencyWindow::OnClick(), TextfileWindow::OnClick(), NetworkClientListWindow::OnDropdownSelect(), LandInfoWindow::OnInit(), IConsoleWindow::OnPaint(), GoalListWindow::OnPaint(), HighScoreWindow::OnPaint(), NewsWindow::OnResize(), GameOptionsWindow::OnResize(), DepotWindow::OnRightClick(), openttd_main(), RealMakeScreenshot(), ClientNetworkGameSocketHandler::Receive_SERVER_ERROR(), FrametimeGraphWindow::SetStringParameters(), GenerateLandscapeWindow::SetStringParameters(), GameManualTextfileWindow::SetStringParameters(), ScriptLeagueWindow::SetStringParameters(), AboutWindow::SetStringParameters(), MusicTrackSelectionWindow::SetStringParameters(), NetworkChatWindow::SetStringParameters(), ContentTextfileWindow::SetStringParameters(), NetworkClientListWindow::SetStringParameters(), NetworkAskRelayWindow::SetStringParameters(), SpriteAlignerWindow::SetStringParameters(), NewGRFTextfileWindow::SetStringParameters(), NewGRFWindow::SetStringParameters(), ScriptTextfileWindow::SetStringParameters(), ScriptDebugWindow::SetStringParameters(), BaseSetTextfileWindow::SetStringParameters(), GameOptionsWindow::SetStringParameters(), CustomCurrencyWindow::SetStringParameters(), StoryBookWindow::SetStringParameters(), ShowNewGRFError(), ShowNewGrfVehicleError(), TownActionBuyRights(), TownActionRoadRebuild(), FramerateWindow::UpdateWidgetSize(), GoalQuestionWindow::UpdateWidgetSize(), ScriptLeagueWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), MusicWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), SpriteAlignerWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), StoryBookWindow::UpdateWidgetSize(), and WarnCorruptSprite().

## ◆ SetDParamStr() [2/3]

void SetDParamStr | ( | size_t | n,
|  | const std::string & | str
| ) |  |

This function is used to "bind" the C string of a std::string to a OpenTTD dparam slot.

The caller has to ensure that the std::string reference remains valid while the string is shown.

Parameters

  n | slot of the string
  str | string to bind

Definition at line 382 of file strings.cpp.

## ◆ SetDParamStr() [3/3]

void SetDParamStr | ( | size_t | n,
|  | std::string && | str
| ) |  |

This function is used to "bind" the std::string to a OpenTTD dparam slot.

Contrary to the other `SetDParamStr` functions, this moves the string into the parameter slot.

Parameters

  n | slot of the string
  str | string to bind

Definition at line 394 of file strings.cpp.

## Variable Documentation

## ◆ _current_text_dir

TextDirection _current_text_dir
| extern

Text direction of the currently selected language.

Definition at line 56 of file strings.cpp.

Referenced by AddCargoIconOverlay(), NWidgetLeaf::ButtonHit(), IndustryCargoesWindow::CalculatePositionInWidget(), CheckForMissingGlyphs(), ClickSliderWidget(), NWidgetMatrix::Draw(), NWidgetLeaf::Draw(), BaseSettingEntry::Draw(), CargoesField::Draw(), DrawAircraftImage(), DrawArrowButtons(), DrawButtonDropdown(), NetworkClientListWindow::DrawButtons(), DrawCargoIcons(), StationViewWindow::DrawCargoRatings(), DrawCategory(), NetworkClientListWindow::DrawCompany(), CompanyInfrastructureWindow::DrawCountLine(), DrawEngineList(), StationViewWindow::DrawEntries(), DrawFrame(), VehicleGroupWindow::DrawGroupInfo(), IndustryViewWindow::DrawInfo(), DrawLayoutLine(), GoalListWindow::DrawListColumn(), DrawOrderString(), TownAuthorityWindow::DrawRatings(), DrawRoadVehImage(), NetworkGameWindow::DrawServerLine(), SettingEntry::DrawSetting(), SettingsPage::DrawSetting(), DrawShipImage(), DrawSliderWidget(), DrawSmallOrderList(), Window::DrawSortButtonState(), TimetableWindow::DrawTimetablePanel(), DrawTrainDetails(), DrawTrainImage(), NewGRFInspectWindow::DrawVehicleChainWidget(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehicleRefitWindow(), BuildBridgeWindow::DrawWidget(), CheatWindow::DrawWidget(), SelectCompanyLiveryWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), DepotWindow::DrawWidget(), GSConfigWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), PaymentRatesGraphWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), IndustryProductionGraphWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), IndustryCargoesWindow::DrawWidget(), PerformanceLeagueWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), BaseNetworkContentDownloadStatusWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), NewGRFWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), MessageHistoryWindow::DrawWidget(), OrdersWindow::DrawWidget(), ScriptSettingsWindow::DrawWidget(), SignListWindow::DrawWidget(), SmallMapWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), TownViewWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), RefitWindow::DrawWidget(), VehicleDetailsWindow::DrawWidget(), VehicleViewWindow::DrawWidget(), GetAlignedPosition(), GetAutoPlacePosition(), QueryString::GetBoundingRect(), NetworkClientListWindow::GetButtonAtPoint(), QueryString::GetCaretPosition(), QueryString::GetCharAtPosition(), Layouter::GetCharPosition(), SmallMapWindow::GetPositionOnLegend(), NWidgetMatrix::GetScrollOffsets(), GetSingleVehicleWidth(), GetToolbarAlignedWindowPosition(), NWidgetMatrix::GetWidgetFromPos(), HandleScrollbarHittest(), HandleScrollbarScrolling(), HighlightDragPosition(), Window::InitializeData(), IsGoodAutoPlace2(), ItemizeBidi(), LocalGetWindowPlacement(), Textbuf::MovePos(), ReplaceVehicleWindow::OnClick(), BuildVehicleWindow::OnClick(), CheatWindow::OnClick(), GSConfigWindow::OnClick(), VehicleGroupWindow::OnClick(), IndustryViewWindow::OnClick(), NewGRFParametersWindow::OnClick(), ScriptSettingsWindow::OnClick(), GameSettingsWindow::OnClick(), RefitWindow::OnPaint(), NetworkClientListWindow::OnTooltip(), ReadLanguagePack(), Window::ReInit(), ResizeWindow(), ScrollbarClickPositioning(), ScrollRect(), SetMouseCursorVehicle(), NWidgetLeaf::SetupSmallestSize(), ShowDropDownList(), ShowTerraformToolbar(), UniscribeItemizeString(), Textbuf::UpdateCaretPosition(), DropdownWindow::UpdateSizeAndPosition(), PerformanceRatingDetailWindow::UpdateWidgetSize(), and MusicWindow::UpdateWidgetSize().