1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-31 18:39:10 +00:00

(svn r2594) Fix: [strgen] Misc updates to the string system.

- Renamed the plural command to "P" instead of "PLURAL". Now write something like this to append an s on plural: {P "" s}. (You can optionally still add an argument index to explicitly specifiy which number that's used)
  - Removed the pluralized cargo strings from the string files. The new method is to use the plural specifier {P}
  - Added support for genders. First add "##gender der das die" on top, then use {G=der} on a cargoname/industry to set the gender, and to switch between genders do something like {G neu neu neue} {STRING}
  - Updated the swedish/english translation with P strings.
This commit is contained in:
ludde
2005-07-16 20:58:04 +00:00
parent 01f3b6b6fe
commit 64f6839816
13 changed files with 159 additions and 148 deletions

View File

@@ -525,7 +525,7 @@ static char *FormatString(char *buff, const char *str, const int32 *argv)
case 0x7C: // Move argument pointer
argv = argv_orig + (byte)*str++;
break;
case 0x7D: { // {PLURAL}
case 0x7D: { // {P}
int32 v = argv_orig[(byte)*str++]; // contains the number that determines plural
int len;
str = ParseStringChoice(str, DeterminePluralForm(v), buff, &len);
@@ -640,6 +640,24 @@ static char *FormatString(char *buff, const char *str, const int32 *argv)
break;
}
case 12: { // {VOLUME}
buff = FormatCommaNumber(buff, GetInt32(&argv) * 1000);
buff = strecpy(buff, " ", NULL);
buff = strecpy(buff, GetStringPtr(STR_LITERS), NULL);
break;
}
case 13: { // {G 0 Der Die Das}
byte *s = (byte*)GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender.
int len;
int gender = 0;
if (s && s[0] == 0x87)
gender = s[1];
str = ParseStringChoice(str, gender, buff, &len);
buff += len;
break;
}
default:
error("!invalid escape sequence in string");
}
@@ -648,10 +666,11 @@ static char *FormatString(char *buff, const char *str, const int32 *argv)
case 0x86: // {SKIP}
argv++;
break;
case 0x87: // {VOLUME}
buff = FormatCommaNumber(buff, GetInt32(&argv) * 1000);
buff = strecpy(buff, " ", NULL);
buff = strecpy(buff, GetStringPtr(STR_LITERS), NULL);
// This sets up the gender for the string.
// We just ignore this one. It's used somewhere else.
case 0x87: // {GENDER 0}
str++;
break;
case 0x88: {// {STRING}
@@ -667,10 +686,8 @@ static char *FormatString(char *buff, const char *str, const int32 *argv)
// Layout now is:
// 8bit - cargo type
// 16-bit - cargo count
int cargo_str = _cargoc.names_long_s[GetInt32(&argv)];
// Now check if the cargo count is 1, if it is, increase string by 32.
if (GetInt32(&argv) != 1) cargo_str += 32;
buff = GetStringWithArgs(buff, cargo_str, argv - 1);
StringID cargo_str = _cargoc.names_long[GetInt32(&argv)];
buff = GetStringWithArgs(buff, cargo_str, argv);
break;
}