1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

allow translation of unit and date strings, closes #307

This commit is contained in:
IntelOrca
2015-02-09 12:53:11 +00:00
parent ee51f31f57
commit 7ea809492a
4 changed files with 124 additions and 88 deletions

View File

@@ -2722,24 +2722,24 @@ STR_2716 :/
STR_2717 :'
STR_2718 :???
STR_2719 :???
STR_2720 :???
STR_2721 :???
STR_2722 :???
STR_2723 :???
STR_2724 :???
STR_2725 :???
STR_2726 :???
STR_2727 :???
STR_2728 :???
STR_2729 :???
STR_2730 :???
STR_2731 :???
STR_2732 :???
STR_2733 :???
STR_2734 :???
STR_2735 :???
STR_2736 :???
STR_2737 :???
STR_2720 :{UINT16}sec
STR_2721 :{UINT16}secs
STR_2722 :{UINT16}min:{UINT16}sec
STR_2723 :{UINT16}min:{UINT16}secs
STR_2724 :{UINT16}mins:{UINT16}sec
STR_2725 :{UINT16}mins:{UINT16}secs
STR_2726 :{UINT16}min
STR_2727 :{UINT16}mins
STR_2728 :{UINT16}hour:{UINT16}min
STR_2729 :{UINT16}hour:{UINT16}mins
STR_2730 :{UINT16}hours:{UINT16}min
STR_2731 :{UINT16}hours:{UINT16}mins
STR_2732 :{COMMA16}ft
STR_2733 :{COMMA16}m
STR_2734 :{COMMA16}mph
STR_2735 :{COMMA16}km/h
STR_2736 :{MONTH}, Year {COMMA16}
STR_2737 :{STRINGID} {MONTH}, Year {COMMA16}
STR_2738 :Title screen music
STR_2739 :None
STR_2740 :RollerCoaster Tycoon 1

View File

@@ -2722,24 +2722,24 @@ STR_2716 :/
STR_2717 :'
STR_2718 :???
STR_2719 :???
STR_2720 :???
STR_2721 :???
STR_2722 :???
STR_2723 :???
STR_2724 :???
STR_2725 :???
STR_2726 :???
STR_2727 :???
STR_2728 :???
STR_2729 :???
STR_2730 :???
STR_2731 :???
STR_2732 :???
STR_2733 :???
STR_2734 :???
STR_2735 :???
STR_2736 :???
STR_2737 :???
STR_2720 :{UINT16}sec
STR_2721 :{UINT16}secs
STR_2722 :{UINT16}min:{UINT16}sec
STR_2723 :{UINT16}min:{UINT16}secs
STR_2724 :{UINT16}mins:{UINT16}sec
STR_2725 :{UINT16}mins:{UINT16}secs
STR_2726 :{UINT16}min
STR_2727 :{UINT16}mins
STR_2728 :{UINT16}hour:{UINT16}min
STR_2729 :{UINT16}hour:{UINT16}mins
STR_2730 :{UINT16}hours:{UINT16}min
STR_2731 :{UINT16}hours:{UINT16}mins
STR_2732 :{COMMA16}ft
STR_2733 :{COMMA16}m
STR_2734 :{COMMA16}mph
STR_2735 :{COMMA16}km/h
STR_2736 :{MONTH}, Year {COMMA16}
STR_2737 :{STRINGID} {MONTH}, Year {COMMA16}
STR_2738 :Title screen music
STR_2739 :None
STR_2740 :RollerCoaster Tycoon 1

View File

@@ -343,6 +343,84 @@ void format_currency_2dp(char **dest, long long value)
}
}
void format_date(char **dest, uint16 value)
{
uint16 args[] = { date_get_month(value), date_get_year(value) + 1 };
uint16 *argsRef = args;
format_string_part(dest, 2736, (char**)&argsRef);
(*dest)--;
}
void format_length(char **dest, uint16 value)
{
rct_string_id stringId = 2733;
if (gGeneral_config.measurement_format == MEASUREMENT_FORMAT_IMPERIAL) {
value = metres_to_feet(value);
stringId--;
}
uint16 *argRef = &value;
format_string_part(dest, stringId, (char**)&argRef);
}
void format_velocity(char **dest, uint16 value)
{
rct_string_id stringId = 2734;
if (gGeneral_config.measurement_format == MEASUREMENT_FORMAT_METRIC) {
value = mph_to_kmph(value);
stringId++;
}
uint16 *argRef = &value;
format_string_part(dest, stringId, (char**)&argRef);
}
void format_duration(char **dest, uint16 value)
{
uint16 minutes = value / 60;
uint16 seconds = value % 60;
uint16 args[] = { minutes, seconds };
uint16 *argsRef = &args[1];
rct_string_id stringId = 2720;
if (minutes > 0) {
stringId += 2;
if (minutes != 1)
stringId += 2;
argsRef--;
}
if (seconds != 1)
stringId++;
format_string_part(dest, stringId, (char**)&argsRef);
}
void format_realtime(char **dest, uint16 value)
{
uint16 hours = value / 60;
uint16 minutes = value % 60;
uint16 args[] = { hours, minutes };
uint16 *argsRef = &args[1];
rct_string_id stringId = 2726;
if (hours > 0) {
stringId += 2;
if (hours != 1)
stringId += 2;
argsRef--;
}
if (minutes != 1)
stringId++;
format_string_part(dest, stringId, (char**)&argsRef);
}
void format_string_code(unsigned char format_code, char **dest, char **args)
{
int value;
@@ -419,13 +497,7 @@ void format_string_code(unsigned char format_code, char **dest, char **args)
value = *((uint16*)*args);
*args += 2;
uint16 dateArgs[] = { date_get_month(value), date_get_year(value) + 1 };
uint16 *dateArgs2 = dateArgs;
char formatString[] = "?, Year ?";
formatString[0] = FORMAT_MONTH;
formatString[8] = FORMAT_COMMA16;
format_string_part_from_raw(dest, formatString, (char**)&dateArgs2);
(*dest)--;
format_date(dest, value);
break;
case FORMAT_MONTH:
// Pop argument
@@ -440,15 +512,7 @@ void format_string_code(unsigned char format_code, char **dest, char **args)
value = *((sint16*)*args);
*args += 2;
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8)) {
format_comma_separated_integer(dest, mph_to_kmph(value));
strcpy(*dest, "kmh");
*dest += strlen(*dest);
} else {
format_comma_separated_integer(dest, value);
strcpy(*dest, "mph");
*dest += strlen(*dest);
}
format_velocity(dest, value);
break;
case FORMAT_POP16:
*args += 2;
@@ -461,45 +525,21 @@ void format_string_code(unsigned char format_code, char **dest, char **args)
value = *((uint16*)*args);
*args += 2;
if (value / 60 > 0) {
format_integer(dest, value / 60);
strcpy(*dest, value / 60 == 1 ? "min:" : "mins:");
*dest += strlen(*dest);
}
format_integer(dest, value % 60);
strcpy(*dest, value % 60 == 1 ? "sec" : "secs");
*dest += strlen(*dest);
format_duration(dest, value);
break;
case FORMAT_REALTIME:
// Pop argument
value = *((uint16*)*args);
*args += 2;
if (value / 60 > 0) {
format_integer(dest, value / 60);
strcpy(*dest, value / 60 == 1 ? "hour:" : "hours:");
*dest += strlen(*dest);
}
format_integer(dest, value % 60);
strcpy(*dest, value % 60 == 1 ? "min" : "mins");
*dest += strlen(*dest);
format_realtime(dest, value);
break;
case FORMAT_LENGTH:
// Pop argument
value = *((sint16*)*args);
*args += 2;
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8)) {
format_comma_separated_integer(dest, value);
strcpy(*dest, "m");
*dest += strlen(*dest);
} else {
format_comma_separated_integer(dest, metres_to_feet(value));
strcpy(*dest, "ft");
*dest += strlen(*dest);
}
format_length(dest, value);
break;
case FORMAT_SPRITE:
// Pop argument

View File

@@ -477,20 +477,16 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi,
y = window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].top + w->y + 2;
// Date
char *freeStr = (char*)0x009BC677;
freeStr[0] = FORMAT_STRINGID;
freeStr[1] = ' ';
freeStr[2] = FORMAT_MONTHYEAR;
freeStr[3] = 0;
int month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7;
int year = date_get_year(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)) + 1;
int month = date_get_month(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7);
int day = ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) * days_in_month[month]) >> 16) & 0xFF;
RCT2_GLOBAL(0x013CE952, short) = STR_DATE_DAY_1 + day;
RCT2_GLOBAL(0x013CE954, short) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16);
RCT2_GLOBAL(0x013CE954, short) = month;
RCT2_GLOBAL(0x013CE956, short) = year;
gfx_draw_string_centred(
dpi,
3165,
2737,
x,
y,
(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) == 2 && RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, sint32) == WIDX_DATE ? 2 : w->colours[0] & 0x7F),