|
OpenTTD Source 20251116-master-g21329071df
|
Header of Action 04 "universal holder" structure and functions. More...
Go to the source code of this file.
Functions | |
| StringID | AddGRFString (uint32_t grfid, GRFStringID stringid, uint8_t langid, bool new_scheme, bool allow_newlines, std::string_view text_to_add, StringID def_string) |
| Add the new read string into our structure. | |
| StringID | GetGRFStringID (uint32_t grfid, GRFStringID stringid) |
| Returns the index for this stringid associated with its grfID. | |
| std::optional< std::string_view > | GetGRFStringFromGRFText (const GRFTextList &text_list) |
| Get a C-string from a GRFText-list. | |
| std::optional< std::string_view > | GetGRFStringFromGRFText (const GRFTextWrapper &text) |
| Get a C-string from a GRFText-list. | |
| std::string_view | GetGRFStringPtr (StringIndexInTab stringid) |
| Get a C-string from a stringid set by a newgrf. | |
| void | CleanUpStrings () |
| House cleaning. | |
| void | SetCurrentGrfLangID (uint8_t language_id) |
| Equivalence Setter function between game and newgrf langID. | |
| std::string | TranslateTTDPatchCodes (uint32_t grfid, uint8_t language_id, bool allow_newlines, std::string_view str, StringControlCode byte80=SCC_NEWGRF_PRINT_WORD_STRING_ID) |
| Translate TTDPatch string codes into something OpenTTD can handle (better). | |
| void | AddGRFTextToList (GRFTextList &list, uint8_t langid, uint32_t grfid, bool allow_newlines, std::string_view text_to_add) |
| Add a string to a GRFText list. | |
| void | AddGRFTextToList (GRFTextWrapper &list, uint8_t langid, uint32_t grfid, bool allow_newlines, std::string_view text_to_add) |
| Add a string to a GRFText list. | |
| void | AddGRFTextToList (GRFTextWrapper &list, std::string_view text_to_add) |
| Add a GRFText to a GRFText list. | |
| bool | CheckGrfLangID (uint8_t lang_id, uint8_t grf_version) |
| std::vector< StringParameter > | GetGRFStringTextStackParameters (const struct GRFFile *grffile, StringID stringid, std::span< const int32_t > textstack) |
| std::string | GetGRFStringWithTextStack (const struct GRFFile *grffile, GRFStringID grfstringid, std::span< const int32_t > textstack) |
| Format a GRF string using the text ref stack for parameters. | |
Header of Action 04 "universal holder" structure and functions.
Definition in file newgrf_text.h.
| StringID AddGRFString | ( | uint32_t | grfid, |
| GRFStringID | stringid, | ||
| uint8_t | langid, | ||
| bool | new_scheme, | ||
| bool | allow_newlines, | ||
| std::string_view | text_to_add, | ||
| StringID | def_string | ||
| ) |
Add the new read string into our structure.
Definition at line 537 of file newgrf_text.cpp.
References AddGRFString(), AddGRFTextToList(), MakeStringID(), TAB_SIZE_NEWGRF, TEXT_TAB_NEWGRF_START, and TranslateTTDPatchCodes().
Referenced by AddGRFString(), FeatureTownName(), and TranslateGRFStrings().
| void AddGRFTextToList | ( | GRFTextList & | list, |
| uint8_t | langid, | ||
| uint32_t | grfid, | ||
| bool | allow_newlines, | ||
| std::string_view | text_to_add | ||
| ) |
Add a string to a GRFText list.
| list | The list where the text should be added to. |
| langid | The language of the new text. |
| grfid | The grfid where this string is defined. |
| allow_newlines | Whether newlines are allowed in this string. |
| text_to_add | The text to add to the list. |
Definition at line 502 of file newgrf_text.cpp.
References AddGRFTextToList(), and TranslateTTDPatchCodes().
| void AddGRFTextToList | ( | GRFTextWrapper & | list, |
| std::string_view | text_to_add | ||
| ) |
Add a GRFText to a GRFText list.
The text should not contain any text-codes. The text will be added as a 'default language'-text.
| list | The list where the text should be added to. |
| text_to_add | The text to add to the list. |
Definition at line 528 of file newgrf_text.cpp.
References AddGRFTextToList().
| void AddGRFTextToList | ( | GRFTextWrapper & | list, |
| uint8_t | langid, | ||
| uint32_t | grfid, | ||
| bool | allow_newlines, | ||
| std::string_view | text_to_add | ||
| ) |
Add a string to a GRFText list.
| list | The list where the text should be added to. |
| langid | The language of the new text. |
| grfid | The grfid where this string is defined. |
| allow_newlines | Whether newlines are allowed in this string. |
| text_to_add | The text to add to the list. |
Definition at line 516 of file newgrf_text.cpp.
References AddGRFTextToList().
| bool CheckGrfLangID | ( | uint8_t | lang_id, |
| uint8_t | grf_version | ||
| ) |
Definition at line 658 of file newgrf_text.cpp.
| void CleanUpStrings | ( | ) |
House cleaning.
Remove all strings.
Definition at line 676 of file newgrf_text.cpp.
Referenced by ResetNewGRFData().
| std::optional< std::string_view > GetGRFStringFromGRFText | ( | const GRFTextList & | text_list | ) |
Get a C-string from a GRFText-list.
If there is a translation for the current language it is returned, otherwise the default translation is returned. If there is neither a default nor a translation for the current language nullptr is returned.
| text_list | The GRFTextList to get the string from. |
Definition at line 600 of file newgrf_text.cpp.
References _current_lang_id.
Referenced by NewGRFParametersWindow::DrawWidget(), GRFConfig::GetDescription(), GetGRFStringFromGRFText(), GetGRFStringPtr(), GRFConfig::GetName(), GRFConfig::GetURL(), NewGRFParametersWindow::OnClick(), and NewGRFParametersWindow::UpdateWidgetSize().
| std::optional< std::string_view > GetGRFStringFromGRFText | ( | const GRFTextWrapper & | text | ) |
Get a C-string from a GRFText-list.
If there is a translation for the current language it is returned, otherwise the default translation is returned. If there is neither a default nor a translation for the current language nullptr is returned.
| text | The GRFTextList to get the string from. |
Definition at line 625 of file newgrf_text.cpp.
References GetGRFStringFromGRFText().
| StringID GetGRFStringID | ( | uint32_t | grfid, |
| GRFStringID | stringid | ||
| ) |
Returns the index for this stringid associated with its grfID.
Definition at line 581 of file newgrf_text.cpp.
References MakeStringID(), and TEXT_TAB_NEWGRF_START.
Referenced by CheckTrainAttachment(), CmdStartStopVehicle(), GetAirportTextCallback(), GetCargoSubtypeText(), GetErrorMessageFromLocationCallbackResult(), GetGRFStringWithTextStack(), GetHouseName(), and MapGRFStringID().
| std::string_view GetGRFStringPtr | ( | StringIndexInTab | stringid | ) |
Get a C-string from a stringid set by a newgrf.
Definition at line 633 of file newgrf_text.cpp.
References GetGRFStringFromGRFText().
Referenced by GetStringWithArgs().
| std::string GetGRFStringWithTextStack | ( | const struct GRFFile * | grffile, |
| GRFStringID | grfstringid, | ||
| std::span< const int32_t > | textstack | ||
| ) |
Format a GRF string using the text ref stack for parameters.
| grffile | GRFFile of string. |
| grfstringid | GRFStringID of string. |
| textstack | Text parameter stack. |
Definition at line 1000 of file newgrf_text.cpp.
References GetGRFStringID(), GetGRFStringTextStackParameters(), and GetStringWithArgs().
Referenced by IndustryViewWindow::DrawInfo(), BuildIndustryWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), FormatString(), GetCargoSuffix(), and GetNewGRFAdditionalText().
| void SetCurrentGrfLangID | ( | uint8_t | language_id | ) |
Equivalence Setter function between game and newgrf langID.
This function will adjust _currentLangID as to what is the LangID of the current language set by the user. This function is called after the user changed language, from strings.cpp:ReadLanguagePack
| language_id | iso code of current selection |
Definition at line 653 of file newgrf_text.cpp.
References _current_lang_id.
Referenced by ReadLanguagePack().
| std::string TranslateTTDPatchCodes | ( | uint32_t | grfid, |
| uint8_t | language_id, | ||
| bool | allow_newlines, | ||
| std::string_view | str, | ||
| StringControlCode | byte80 | ||
| ) |
Translate TTDPatch string codes into something OpenTTD can handle (better).
| grfid | The (NewGRF) ID associated with this string |
| language_id | The (NewGRF) language ID associated with this string. |
| allow_newlines | Whether newlines are allowed in the string or not. |
| str | The string to translate. |
| byte80 | The control code to use as replacement for the 0x80-value. |
Definition at line 238 of file newgrf_text.cpp.
References StringConsumer::AnyBytesLeft(), CS_ALPHANUMERAL, LanguageMap::GetLanguageMap(), LanguageMap::GetMapping(), IsValidChar(), MapGRFStringID(), NFO_UTF8_IDENTIFIER, BaseStringBuilder::PutChar(), BaseStringBuilder::PutUtf8(), StringConsumer::ReadUint16LE(), StringConsumer::ReadUint8(), StringConsumer::ReadUtf8If(), SCC_BIGFONT, SCC_NEWGRF_DISCARD_WORD, SCC_NEWGRF_PRINT_BYTE_HEX, SCC_NEWGRF_PRINT_DWORD_DATE_LONG, 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_DATE_LONG, SCC_NEWGRF_PRINT_WORD_HEX, SCC_NEWGRF_PRINT_WORD_STATION_NAME, SCC_NEWGRF_PRINT_WORD_VOLUME_LONG, SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG, SCC_NEWGRF_PUSH_WORD, SCC_NEWGRF_ROTATE_TOP_4_WORDS, SCC_NEWGRF_STRINL, SCC_TINYFONT, StringConsumer::SkipUint8(), and StringConsumer::TryReadUtf8().
Referenced by AddGRFString(), AddGRFTextToList(), and FeatureTownName().