#include "stdafx.h"
#include "debug.h"
#include "openttd.h"
#include "variables.h"
#include "newgrf.h"
#include "newgrf_text.h"
#include "strings_func.h"
#include "core/alloc_func.hpp"
#include "newgrf_storage.h"
#include "string_func.h"
#include "table/strings.h"
#include "table/control_codes.h"
Go to the source code of this file.
Data Structures | |
struct | iso_grf |
struct | GRFText |
Element of the linked list. More... | |
struct | GRFTextEntry |
Holder of the above structure. More... | |
struct | TextRefStack |
Defines | |
#define | GRFTAB 28 |
#define | TABSIZE 11 |
Enumerations | |
enum | grf_base_languages { GRFLB_AMERICAN = 0x01, GRFLB_ENGLISH = 0x02, GRFLB_GERMAN = 0x04, GRFLB_FRENCH = 0x08, GRFLB_SPANISH = 0x10, GRFLB_GENERIC = 0x80 } |
Explains the newgrf shift bit positionning. More... | |
enum | grf_extended_languages { GRFLX_AMERICAN = 0x00, GRFLX_ENGLISH = 0x01, GRFLX_GERMAN = 0x02, GRFLX_FRENCH = 0x03, GRFLX_SPANISH = 0x04, GRFLX_ESPERANTO = 0x05, GRFLX_RUSSIAN = 0x07, GRFLX_CZECH = 0x15, GRFLX_SLOVAK = 0x16, GRFLX_BULGARIAN = 0x18, GRFLX_AFRIKAANS = 0x1B, GRFLX_GREEK = 0x1E, GRFLX_DUTCH = 0x1F, GRFLX_CATALAN = 0x22, GRFLX_HUNGARIAN = 0x24, GRFLX_ITALIAN = 0x27, GRFLX_ROMANIAN = 0x28, GRFLX_ICELANDIC = 0x29, GRFLX_LATVIAN = 0x2A, GRFLX_LITHUANIAN = 0x2B, GRFLX_SLOVENIAN = 0x2C, GRFLX_DANISH = 0x2D, GRFLX_SWEDISH = 0x2E, GRFLX_NORWEGIAN = 0x2F, GRFLX_POLISH = 0x30, GRFLX_GALICIAN = 0x31, GRFLX_FRISIAN = 0x32, GRFLX_UKRAINIAN = 0x33, GRFLX_ESTONIAN = 0x34, GRFLX_FINNISH = 0x35, GRFLX_PORTUGUESE = 0x36, GRFLX_BRAZILIAN = 0x37, GRFLX_CROATIAN = 0x38, GRFLX_JAPANESE = 0x39, GRFLX_KOREAN = 0x3A, GRFLX_TURKISH = 0x3E, GRFLX_UNSPECIFIED = 0x7F } |
Functions | |
char * | TranslateTTDPatchCodes (uint32 grfid, const char *str) |
StringID | AddGRFString (uint32 grfid, uint16 stringid, byte langid_to_add, bool new_scheme, 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 * | GetGRFStringPtr (uint16 stringid) |
void | SetCurrentGrfLangID (const char *iso_name) |
Equivalence Setter function between game and newgrf langID. | |
bool | CheckGrfLangID (byte lang_id, byte grf_version) |
void | CleanUpStrings () |
House cleaning. | |
void | PrepareTextRefStackUsage (byte numEntries) |
Prepare the TTDP compatible string code parsing. | |
void | StopTextRefStackUsage () |
Stop using the TTDP compatible string code parsing. | |
void | SwitchToNormalRefStack () |
void | SwitchToErrorRefStack () |
void | RewindTextRefStack () |
uint | RemapNewGRFStringControlCode (uint scc, char **buff, const char **str, int64 *argv) |
FormatString for NewGRF specific "magic" string control codes. | |
Variables | |
const iso_grf | iso_codes [] |
ISO code VS NewGrf langID conversion array. | |
static uint | _num_grf_texts = 0 |
static GRFTextEntry | _grf_text [(1<< TABSIZE)*3] |
static byte | _currentLangID = GRFLX_ENGLISH |
by default, english is used. | |
static uint32 | _last_grfid = 0 |
static TextRefStack | _newgrf_normal_textrefstack |
static TextRefStack | _newgrf_error_textrefstack |
static TextRefStack * | _newgrf_textrefstack = &_newgrf_normal_textrefstack |
The stack that is used for TTDP compatible string code parsing. |
This file implements a linked-lists of strings, holding everything that the newgrf action 04 will send over to OpenTTD. One of the biggest problems is that Dynamic lang Array uses ISO codes as way to identifying current user lang, while newgrf uses bit shift codes not related to ISO. So equivalence functionnality had to be set.
Definition in file newgrf_text.cpp.
enum grf_base_languages |
Explains the newgrf shift bit positionning.
the grf base will not be used in order to find the string, but rather for jumping from standard langID scheme to the new one.
Definition at line 34 of file newgrf_text.cpp.
void CleanUpStrings | ( | ) |
House cleaning.
Remove all strings and reset the text counter.
Definition at line 490 of file newgrf_text.cpp.
References GRFTextEntry::grfid, GRFText::next, GRFTextEntry::stringid, and GRFTextEntry::textholder.
Referenced by ResetNewGRFData().
void PrepareTextRefStackUsage | ( | byte | numEntries | ) |
Prepare the TTDP compatible string code parsing.
numEntries | number of entries to copy from the registers |
Definition at line 576 of file newgrf_text.cpp.
References GB(), and TemporaryStorageArray< TYPE, SIZE >::Get().
Referenced by ShowAdditionalText().
uint RemapNewGRFStringControlCode | ( | uint | scc, | |
char ** | buff, | |||
const char ** | str, | |||
int64 * | argv | |||
) |
FormatString for NewGRF specific "magic" string control codes.
scc | the string control code that has been read | |
stack | the current "stack" |
Definition at line 615 of file newgrf_text.cpp.
References DAYS_TILL_ORIGINAL_BASE_YEAR.
void SetCurrentGrfLangID | ( | const char * | iso_name | ) |
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. The array iso_codes will be used to find that match. If not found, it will have to be standard english This function is called after the user changed language, from strings.cpp:ReadLanguagePack
iso_name | iso code of current selection |
Definition at line 456 of file newgrf_text.cpp.
References _currentLangID.
const iso_grf iso_codes[] |
ISO code VS NewGrf langID conversion array.
This array is used in two ways: 1-its ISO part is matching OpenTTD dynamic language id with newgrf bit positionning language id 2-its shift part is used to know what is the shift to watch for when inserting new strings, hence analysing newgrf langid
Definition at line 97 of file newgrf_text.cpp.