OpenTTD Source 20250905-master-g122023be8d
strings_internal.h File Reference

Types and functions related to the internal workings of formatting OpenTTD's strings. More...

Go to the source code of this file.

Data Structures

class  StringParameters
 

Functions

void GetStringWithArgs (StringBuilder &builder, StringID string, StringParameters &args, uint case_index=0, bool game_script=false)
 Get a parsed string with most special stringcodes replaced by the string parameters.
 
void GetStringWithArgs (StringBuilder &builder, StringID string, std::span< StringParameter > params, uint case_index=0, bool game_script=false)
 Get a parsed string with most special stringcodes replaced by the string parameters.
 
std::string GetStringWithArgs (StringID string, StringParameters &args)
 Get a parsed string with most special stringcodes replaced by the string parameters.
 
void GenerateTownNameString (StringBuilder &builder, size_t lang, uint32_t seed)
 Generates town name from given seed.
 
void GetTownName (StringBuilder &builder, const struct Town *t)
 
void GRFTownNameGenerate (StringBuilder &builder, uint32_t grfid, uint16_t gen, uint32_t seed)
 
char32_t RemapNewGRFStringControlCode (char32_t scc, StringConsumer &consumer)
 Emit OpenTTD's internal string code for the different NewGRF string codes.
 

Detailed Description

Types and functions related to the internal workings of formatting OpenTTD's strings.

Definition in file strings_internal.h.

Function Documentation

◆ GenerateTownNameString()

void GenerateTownNameString ( StringBuilder builder,
size_t  lang,
uint32_t  seed 
)

Generates town name from given seed.

Parameters
builderstring builder to write to
langtown name language
seedgeneration seed

Definition at line 991 of file townname.cpp.

References _town_name_generators.

Referenced by GetStringWithArgs().

◆ GetStringWithArgs() [1/3]

void GetStringWithArgs ( StringBuilder builder,
StringID  string,
std::span< StringParameter params,
uint  case_index,
bool  game_script 
)

Get a parsed string with most special stringcodes replaced by the string parameters.

Parameters
builderThe builder of the string.
stringThe ID of the string to parse.
argsSpan of arguments for the string.
case_indexThe "case index". This will only be set when FormatString wants to print the string in a different case.
game_scriptThe string is coming directly from a game script.

Definition at line 413 of file strings.cpp.

References GetStringWithArgs().

◆ GetStringWithArgs() [2/3]

void GetStringWithArgs ( StringBuilder builder,
StringID  string,
StringParameters args,
uint  case_index,
bool  game_script 
)

Get a parsed string with most special stringcodes replaced by the string parameters.

Parameters
builderThe builder of the string.
stringThe ID of the string to parse.
argsArguments for the string.
case_indexThe "case index". This will only be set when FormatString wants to print the string in a different case.
game_scriptThe string is coming directly from a game script.

Definition at line 336 of file strings.cpp.

References Debug, FormatString(), GenerateTownNameString(), GetGameStringPtr(), GetGRFStringPtr(), StringParameters::GetNextParameter(), GetStringIndex(), GetStringTab(), GetStringWithArgs(), IsInsideMM(), LoadedLanguagePack::langtab_num, SPECSTR_TOWNNAME_START, TEXT_TAB_GAMESCRIPT_START, and TEXT_TAB_NEWGRF_START.

Referenced by AppendStringInPlace(), DecodeEncodedString(), SmallMapWindow::DrawWidget(), FormatString(), GenerateDefaultSaveName(), GetGRFStringWithTextStack(), IndustryDirectoryWindow::GetIndustryString(), GetString(), GetString(), GetStringWithArgs(), GetStringWithArgs(), GetStringWithArgs(), GetTownName(), NetworkHandlePauseChange(), LandInfoWindow::OnInit(), and VehicleDetailsWindow::UpdateWidgetSize().

◆ GetStringWithArgs() [3/3]

std::string GetStringWithArgs ( StringID  string,
StringParameters args 
)

Get a parsed string with most special stringcodes replaced by the string parameters.

Parameters
stringThe ID of the string to parse.
argsArguments for the string.
Returns
The parsed string.

Definition at line 453 of file strings.cpp.

References GetStringWithArgs().

◆ GRFTownNameGenerate()

void GRFTownNameGenerate ( StringBuilder builder,
uint32_t  grfid,
uint16_t  gen,
uint32_t  seed 
)

Definition at line 69 of file newgrf_townname.cpp.

◆ RemapNewGRFStringControlCode()