(svn r15696) -Codechange: move the NewGRF language ID into the language file instead of maintaining a table in the code.

This commit is contained in:
rubidium
2009-03-13 00:30:26 +00:00
parent aa441cd4d7
commit f1605cf475
58 changed files with 75 additions and 110 deletions

View File

@@ -27,7 +27,7 @@
* 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.
*/
enum grf_base_languages {
enum GRFBaseLanguages {
GRFLB_AMERICAN = 0x01,
GRFLB_ENGLISH = 0x02,
GRFLB_GERMAN = 0x04,
@@ -36,101 +36,15 @@ enum grf_base_languages {
GRFLB_GENERIC = 0x80,
};
enum grf_extended_languages {
enum GRFExtendedLanguages {
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,
};
struct iso_grf {
char code[6];
byte grfLangID;
};
/**
* 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
*/
const iso_grf iso_codes[] = {
{"en_US", GRFLX_AMERICAN},
{"en_GB", GRFLX_ENGLISH},
{"de_DE", GRFLX_GERMAN},
{"fr_FR", GRFLX_FRENCH},
{"es_ES", GRFLX_SPANISH},
{"af_ZA", GRFLX_AFRIKAANS},
{"hr_HR", GRFLX_CROATIAN},
{"cs_CZ", GRFLX_CZECH},
{"ca_ES", GRFLX_CATALAN},
{"da_DA", GRFLX_DANISH},
{"nl_NL", GRFLX_DUTCH},
{"et_ET", GRFLX_ESTONIAN},
{"fi_FI", GRFLX_FINNISH},
{"fy_NL", GRFLX_FRISIAN},
{"gl_ES", GRFLX_GALICIAN},
{"el_GR", GRFLX_GREEK},
{"hu_HU", GRFLX_HUNGARIAN},
{"is_IS", GRFLX_ICELANDIC},
{"it_IT", GRFLX_ITALIAN},
{"lv_LV", GRFLX_LATVIAN},
{"lt_LT", GRFLX_LITHUANIAN},
{"nb_NO", GRFLX_NORWEGIAN},
{"pl_PL", GRFLX_POLISH},
{"pt_PT", GRFLX_PORTUGUESE},
{"pt_BR", GRFLX_BRAZILIAN},
{"ro_RO", GRFLX_ROMANIAN},
{"ru_RU", GRFLX_RUSSIAN},
{"sk_SK", GRFLX_SLOVAK},
{"sl_SL", GRFLX_SLOVENIAN},
{"sv_SE", GRFLX_SWEDISH},
{"tr_TR", GRFLX_TURKISH},
{"uk_UA", GRFLX_UKRAINIAN},
{"eo_EO", GRFLX_ESPERANTO},
{"bg_BG", GRFLX_BULGARIAN},
{"ja_JP", GRFLX_JAPANESE},
{"ko_KR", GRFLX_KOREAN},
{"gen", GRFLB_GENERIC} ///< this is not iso code, but there has to be something...
};
/**
* Element of the linked list.
* Each of those elements represent the string,
@@ -453,26 +367,13 @@ const char *GetGRFStringPtr(uint16 stringid)
* 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
* @param iso_name iso code of current selection
* @param langauge_id iso code of current selection
*/
void SetCurrentGrfLangID(const char *iso_name)
void SetCurrentGrfLangID(byte language_id)
{
/* Use English by default, if we can't match up the iso_code. */
byte ret = GRFLX_ENGLISH;
byte i;
for (i=0; i < lengthof(iso_codes); i++) {
if (strncmp(iso_codes[i].code, iso_name, strlen(iso_codes[i].code)) == 0) {
/* We found a match, so let's use it. */
ret = iso_codes[i].grfLangID;
break;
}
}
_currentLangID = ret;
_currentLangID = language_id;
}
bool CheckGrfLangID(byte lang_id, byte grf_version)