OpenTTD Source: src/strings_internal.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Functions
strings_internal.h File Reference

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

`#include "strings_func.h"`
`#include "string_func.h"`
`#include "core/string_builder.hpp"`
`#include "core/string_consumer.hpp"`

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

  builder | string builder to write to
  lang | town name language
  seed | generation 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

  builder | The builder of the string.
  string | The ID of the string to parse.
  args | Span of arguments for the string.
  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 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

  builder | The builder of the string.
  string | The ID of the string to parse.
  args | Arguments for the string.
  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 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

  string | The ID of the string to parse.
  args | Arguments 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()

char32_t RemapNewGRFStringControlCode | ( | char32_t | scc,
|  | StringConsumer & | consumer
| ) |  |

Emit OpenTTD's internal string code for the different NewGRF string codes.

Parameters

  scc | NewGRF string code.
  consumer | String consumer, moved forward if SCC_NEWGRF_PUSH_WORD is found.

Returns
  String code to use.

Definition at line 878 of file newgrf_text.cpp.

References SCC_NEWGRF_DISCARD_WORD, SCC_NEWGRF_PRINT_BYTE_HEX, SCC_NEWGRF_PRINT_BYTE_SIGNED, SCC_NEWGRF_PRINT_DWORD_CURRENCY, SCC_NEWGRF_PRINT_DWORD_DATE_LONG, SCC_NEWGRF_PRINT_DWORD_DATE_SHORT, SCC_NEWGRF_PRINT_DWORD_FORCE, SCC_NEWGRF_PRINT_DWORD_HEX, SCC_NEWGRF_PRINT_DWORD_SIGNED, SCC_NEWGRF_PRINT_QWORD_CURRENCY, SCC_NEWGRF_PRINT_QWORD_HEX, SCC_NEWGRF_PRINT_WORD_CARGO_LONG, SCC_NEWGRF_PRINT_WORD_CARGO_NAME, SCC_NEWGRF_PRINT_WORD_CARGO_SHORT, SCC_NEWGRF_PRINT_WORD_CARGO_TINY, SCC_NEWGRF_PRINT_WORD_DATE_LONG, SCC_NEWGRF_PRINT_WORD_DATE_SHORT, SCC_NEWGRF_PRINT_WORD_HEX, SCC_NEWGRF_PRINT_WORD_POWER, SCC_NEWGRF_PRINT_WORD_SIGNED, SCC_NEWGRF_PRINT_WORD_SPEED, SCC_NEWGRF_PRINT_WORD_STATION_NAME, SCC_NEWGRF_PRINT_WORD_UNSIGNED, SCC_NEWGRF_PRINT_WORD_VOLUME_LONG, SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT, SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG, SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT, SCC_NEWGRF_PUSH_WORD, SCC_NEWGRF_ROTATE_TOP_4_WORDS, and StringConsumer::SkipUtf8().

Referenced by FormatString().