OpenTTD
|
Header of Action 04 "universal holder" structure and functions. More...
#include "string_type.h"
#include "strings_type.h"
#include "core/smallvec_type.hpp"
#include "table/control_codes.h"
Go to the source code of this file.
Data Structures | |
struct | LanguageMap |
Mapping of language data between a NewGRF and OpenTTD. More... | |
struct | LanguageMap::Mapping |
Mapping between NewGRF and OpenTTD IDs. More... |
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, uint16 stringid) |
Returns the index for this stringid associated with its grfID. | |
const char * | GetGRFStringFromGRFText (const struct GRFText *text) |
const char * | GetGRFStringPtr (uint16 stringid) |
Get a C-string from a stringid set by a newgrf. | |
void | CleanUpStrings () |
House cleaning. | |
void | SetCurrentGrfLangID (byte language_id) |
Equivalence Setter function between game and newgrf langID. | |
char * | TranslateTTDPatchCodes (uint32 grfid, uint8 language_id, bool allow_newlines, const char *str, int *olen=NULL, StringControlCode byte80=SCC_NEWGRF_PRINT_WORD_STRING_ID) |
Translate TTDPatch string codes into something OpenTTD can handle (better). | |
struct GRFText * | DuplicateGRFText (struct GRFText *orig) |
Create a copy of this GRFText list. | |
void | AddGRFTextToList (struct GRFText **list, struct GRFText *text_to_add) |
Add a GRFText to a GRFText list. | |
void | AddGRFTextToList (struct GRFText **list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add) |
Add a string to a GRFText list. | |
void | AddGRFTextToList (struct GRFText **list, const char *text_to_add) |
Add a GRFText to a GRFText list. | |
void | CleanUpGRFText (struct GRFText *grftext) |
Delete all items of a linked GRFText list. | |
bool | CheckGrfLangID (byte lang_id, byte grf_version) |
void | StartTextRefStackUsage (const GRFFile *grffile, byte numEntries, const uint32 *values=NULL) |
Start using the TTDP compatible string code parsing. | |
void | StopTextRefStackUsage () |
Stop using the TTDP compatible string code parsing. | |
void | RewindTextRefStack () |
bool | UsingNewGRFTextStack () |
Check whether the NewGRF text stack is in use. | |
struct TextRefStack * | CreateTextRefStackBackup () |
Create a backup of the current NewGRF text stack. | |
void | RestoreTextRefStackBackup (struct TextRefStack *backup) |
Restore a copy of the text stack to the used stack. | |
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. |
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.
Add a GRFText to a GRFText list.
list | The list where the text should be added to. |
text_to_add | The GRFText to add to the list. |
Definition at line 580 of file newgrf_text.cpp.
References GRFText::langid, and GRFText::next.
Referenced by AddGRFString(), AddGRFTextToList(), ChangeGRFDescription(), ChangeGRFName(), ChangeGRFParamDescription(), ChangeGRFParamName(), ChangeGRFParamValueNames(), ChangeGRFURL(), FindUnknownGRFName(), and ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS().
void AddGRFTextToList | ( | struct GRFText ** | 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 607 of file newgrf_text.cpp.
References AddGRFTextToList(), free(), GRFText::New(), and TranslateTTDPatchCodes().
void AddGRFTextToList | ( | struct GRFText ** | 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 623 of file newgrf_text.cpp.
References AddGRFTextToList(), and GRFText::New().
void CleanUpGRFText | ( | GRFText * | grftext | ) |
Delete all items of a linked GRFText list.
grftext | the head of the list to delete |
Definition at line 786 of file newgrf_text.cpp.
References GRFText::next.
Referenced by CleanUpStrings(), GRFParameterInfo::~GRFParameterInfo(), and GRFTextWrapper::~GRFTextWrapper().
void CleanUpStrings | ( | ) |
House cleaning.
Remove all strings and reset the text counter.
Definition at line 799 of file newgrf_text.cpp.
References CleanUpGRFText().
Referenced by ResetNewGRFData().
|
read |
Create a backup of the current NewGRF text stack.
Definition at line 902 of file newgrf_text.cpp.
Referenced by FormatString().
Create a copy of this GRFText list.
orig | The GRFText list to copy. |
Definition at line 633 of file newgrf_text.cpp.
References GRFText::Copy(), and GRFText::next.
Referenced by GRFParameterInfo::GRFParameterInfo().
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 972 of file newgrf_text.cpp.
References DAYS_TILL_ORIGINAL_BASE_YEAR, DEBUG, GetCargoTranslation(), MapGRFStringID(), max(), TextRefStack::RotateTop4Words(), 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_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_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, SCC_NEWGRF_PRINT_WORD_WEIGHT_SHORT, SCC_NEWGRF_PUSH_WORD, SCC_NEWGRF_ROTATE_TOP_4_WORDS, and SCC_NEWGRF_UNPRINT.
Referenced by FormatString().
void RestoreTextRefStackBackup | ( | struct TextRefStack * | backup | ) |
Restore a copy of the text stack to the used stack.
backup | The copy to restore. |
Definition at line 911 of file newgrf_text.cpp.
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 763 of file newgrf_text.cpp.
References _currentLangID.
Referenced by ReadLanguagePack().
void StartTextRefStackUsage | ( | const GRFFile * | grffile, |
byte | numEntries, | ||
const uint32 * | values | ||
) |
Start using the TTDP compatible string code parsing.
On start a number of values is copied on the TextRefStack. You can then use GetString() and the normal string drawing functions, and they will use the TextRefStack for NewGRF string codes.
However, when you want to draw a string multiple times using the same stack, you have to call RewindTextRefStack() between draws.
After you are done with drawing, you must disable usage of the TextRefStack by calling StopTextRefStackUsage(), so NewGRF string codes operate on the normal string parameters again.
grffile | the NewGRF providing the stack data |
numEntries | number of entries to copy from the registers |
values | values to copy onto the stack; if NULL the temporary NewGRF registers will be used instead |
Definition at line 935 of file newgrf_text.cpp.
References GB(), and TemporaryStorageArray< TYPE, SIZE >::GetValue().
Referenced by ErrorMessageData::CopyOutDParams(), IndustryViewWindow::DrawInfo(), BuildObjectWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), GetCargoSuffix(), ShowAdditionalText(), ShowErrorMessage(), and ErrmsgWindow::UpdateWidgetSize().
char* TranslateTTDPatchCodes | ( | uint32 | grfid, |
uint8 | language_id, | ||
bool | allow_newlines, | ||
const char * | str, | ||
int * | olen, | ||
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. | |
[out] | olen | The length of the final string. |
byte80 | The control code to use as replacement for the 0x80-value. |
Definition at line 339 of file newgrf_text.cpp.
References SmallMap< T, U, S >::Contains(), CS_ALPHANUMERAL, UnmappedChoiceList::Flush(), GB(), LanguageMap::GetLanguageMap(), LanguageMap::GetMapping(), grfmsg(), IsValidChar(), MapGRFStringID(), NFO_UTF8_IDENTIFIER, ReallocT(), SCC_BIGFONT, SCC_NEWGRF_DISCARD_WORD, SCC_NEWGRF_PRINT_BYTE_HEX, SCC_NEWGRF_PRINT_DWORD_DATE_LONG, 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_NEWGRF_UNPRINT, SCC_TINYFONT, UnmappedChoiceList::strings, Utf8Decode(), Utf8Encode(), and Utf8EncodedCharLen().
Referenced by AddGRFString(), AddGRFTextToList(), and FeatureTownName().
bool UsingNewGRFTextStack | ( | ) |
Check whether the NewGRF text stack is in use.
Definition at line 893 of file newgrf_text.cpp.
Referenced by FormatString().
|
static |
This character, the thorn ('þ'), indicates a unicode string to NFO.
Definition at line 21 of file newgrf_text.h.
Referenced by GlobalVarChangeInfo(), and TranslateTTDPatchCodes().