|
OpenTTD Source
1.11.0-beta2
|
#include "string_type.h"#include "strings_type.h"#include "core/smallvec_type.hpp"#include "table/control_codes.h"#include <utility>#include <vector>#include <string>Go to the source code of this file.
Data Structures | |
| struct | GRFText |
| A GRF text with associated language ID. More... | |
| struct | LanguageMap |
| Mapping of language data between a NewGRF and OpenTTD. More... | |
| struct | LanguageMap::Mapping |
| Mapping between NewGRF and OpenTTD IDs. More... | |
Typedefs | |
| typedef std::vector< GRFText > | GRFTextList |
| A GRF text with a list of translations. | |
| typedef std::shared_ptr< GRFTextList > | GRFTextWrapper |
| Reference counted wrapper around a GRFText pointer. | |
Functions | |
| StringID | AddGRFString (uint32 grfid, uint16 stringid, byte langid, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string) |
| Add the new read string into our structure. | |
| StringID | GetGRFStringID (uint32 grfid, StringID stringid) |
| Returns the index for this stringid associated with its grfID. | |
| const char * | GetGRFStringFromGRFText (const GRFTextList &text_list) |
| Get a C-string from a GRFText-list. More... | |
| const char * | GetGRFStringFromGRFText (const GRFTextWrapper &text) |
| Get a C-string from a GRFText-list. More... | |
| const char * | GetGRFStringPtr (uint16 stringid) |
| Get a C-string from a stringid set by a newgrf. | |
| void | CleanUpStrings () |
| House cleaning. More... | |
| void | SetCurrentGrfLangID (byte language_id) |
| Equivalence Setter function between game and newgrf langID. More... | |
| std::string | TranslateTTDPatchCodes (uint32 grfid, uint8 language_id, bool allow_newlines, const std::string &str, StringControlCode byte80=SCC_NEWGRF_PRINT_WORD_STRING_ID) |
| Translate TTDPatch string codes into something OpenTTD can handle (better). More... | |
| void | AddGRFTextToList (GRFTextList &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add) |
| Add a string to a GRFText list. More... | |
| void | AddGRFTextToList (GRFTextWrapper &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add) |
| Add a string to a GRFText list. More... | |
| void | AddGRFTextToList (GRFTextWrapper &list, const char *text_to_add) |
| Add a GRFText to a GRFText list. More... | |
| bool | CheckGrfLangID (byte lang_id, byte grf_version) |
| void | StartTextRefStackUsage (const struct GRFFile *grffile, byte numEntries, const uint32 *values=nullptr) |
| void | StopTextRefStackUsage () |
| Stop using the TTDP compatible string code parsing. | |
| void | RewindTextRefStack () |
| bool | UsingNewGRFTextStack () |
| Check whether the NewGRF text stack is in use. More... | |
| struct TextRefStack * | CreateTextRefStackBackup () |
| Create a backup of the current NewGRF text stack. More... | |
| void | RestoreTextRefStackBackup (struct TextRefStack *backup) |
| Restore a copy of the text stack to the used stack. More... | |
| uint | RemapNewGRFStringControlCode (uint scc, char *buf_start, char **buff, const char **str, int64 *argv, uint argv_size, bool modify_argv) |
| FormatString for NewGRF specific "magic" string control codes. More... | |
Variables | |
| static const WChar | NFO_UTF8_IDENTIFIER = 0x00DE |
| This character, the thorn ('รพ'), indicates a unicode string to NFO. | |
Header of Action 04 "universal holder" structure and functions
Definition in file newgrf_text.h.
| void AddGRFTextToList | ( | GRFTextList & | list, |
| byte | langid, | ||
| uint32 | grfid, | ||
| bool | allow_newlines, | ||
| const char * | 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 517 of file newgrf_text.cpp.
References AddGRFTextToList(), and TranslateTTDPatchCodes().
| void AddGRFTextToList | ( | GRFTextWrapper & | list, |
| byte | langid, | ||
| uint32 | grfid, | ||
| bool | allow_newlines, | ||
| const char * | 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 531 of file newgrf_text.cpp.
References AddGRFTextToList().
| void AddGRFTextToList | ( | GRFTextWrapper & | list, |
| const char * | 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 543 of file newgrf_text.cpp.
References AddGRFTextToList().
| void CleanUpStrings | ( | ) |
House cleaning.
Remove all strings and reset the text counter.
Definition at line 696 of file newgrf_text.cpp.
Referenced by ResetNewGRFData().
| struct TextRefStack* CreateTextRefStackBackup | ( | ) |
Create a backup of the current NewGRF text stack.
Definition at line 789 of file newgrf_text.cpp.
References _newgrf_textrefstack.
Referenced by FormatString().
| const char* 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 621 of file newgrf_text.cpp.
References _currentLangID.
Referenced by GRFFileScanner::AddFile(), NewGRFParametersWindow::DrawWidget(), GRFConfig::GetDescription(), GetGRFStringFromGRFText(), GRFConfig::GetName(), GRFConfig::GetURL(), and ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS().
| const char* 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 646 of file newgrf_text.cpp.
References GetGRFStringFromGRFText().
| uint RemapNewGRFStringControlCode | ( | uint | scc, |
| char * | buf_start, | ||
| char ** | buff, | ||
| const char ** | str, | ||
| int64 * | argv, | ||
| uint | argv_size, | ||
| bool | modify_argv | ||
| ) |
FormatString for NewGRF specific "magic" string control codes.
| scc | the string control code that has been read |
| buff | the buffer we're writing to |
| str | the string that we need to write |
| argv | the OpenTTD stack of values |
| argv_size | space on the stack argv |
| modify_argv | When true, modify the OpenTTD stack. |
Definition at line 859 of file newgrf_text.cpp.
References _newgrf_textrefstack, DEBUG, 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_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_STRING_ID, SCC_NEWGRF_PRINT_WORD_UNSIGNED, SCC_NEWGRF_PRINT_WORD_VOLUME_LONG, SCC_NEWGRF_PRINT_WORD_VOLUME_SHORT, SCC_NEWGRF_PRINT_WORD_WEIGHT_LONG, and SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT.
| void RestoreTextRefStackBackup | ( | struct TextRefStack * | backup | ) |
Restore a copy of the text stack to the used stack.
| backup | The copy to restore. |
Definition at line 798 of file newgrf_text.cpp.
References _newgrf_textrefstack.
Referenced by FormatString().
| void SetCurrentGrfLangID | ( | byte | 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 673 of file newgrf_text.cpp.
References _currentLangID.
| std::string TranslateTTDPatchCodes | ( | uint32 | grfid, |
| uint8 | language_id, | ||
| bool | allow_newlines, | ||
| const std::string & | 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 241 of file newgrf_text.cpp.
References NFO_UTF8_IDENTIFIER, Utf8Decode(), and Utf8EncodedCharLen().
Referenced by AddGRFTextToList().
| bool UsingNewGRFTextStack | ( | ) |
Check whether the NewGRF text stack is in use.
Definition at line 780 of file newgrf_text.cpp.
References _newgrf_textrefstack.
Referenced by FormatString().