1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 05:23:04 +01:00

implement SI units for distance / speed measurement, closes #2496

This commit is contained in:
IntelOrca
2015-12-18 21:11:24 +00:00
parent 859c35574a
commit 22b4df1a99
10 changed files with 49 additions and 9 deletions

View File

@@ -104,6 +104,7 @@ config_enum_definition _screenShotFormatEnum[] = {
config_enum_definition _measurementFormatEnum[] = {
{ "IMPERIAL", MEASUREMENT_FORMAT_IMPERIAL },
{ "METRIC", MEASUREMENT_FORMAT_METRIC },
{ "SI", MEASUREMENT_FORMAT_SI },
END_OF_ENUM
};

View File

@@ -94,7 +94,8 @@ enum {
enum {
MEASUREMENT_FORMAT_IMPERIAL,
MEASUREMENT_FORMAT_METRIC
MEASUREMENT_FORMAT_METRIC,
MEASUREMENT_FORMAT_SI
};
enum {

View File

@@ -450,11 +450,20 @@ void format_length(char **dest, sint16 value)
void format_velocity(char **dest, uint16 value)
{
rct_string_id stringId = 2734;
rct_string_id stringId;
if (gConfigGeneral.measurement_format == MEASUREMENT_FORMAT_METRIC) {
switch (gConfigGeneral.measurement_format) {
default:
stringId = STR_UNIT_SUFFIX_MILES_PER_HOUR;
break;
case MEASUREMENT_FORMAT_METRIC:
value = mph_to_kmph(value);
stringId++;
stringId = STR_UNIT_SUFFIX_KILOMETRES_PER_HOUR;
break;
case MEASUREMENT_FORMAT_SI:
value = mph_to_mps(value);
stringId = STR_UNIT_SUFFIX_METRES_PER_SECOND;
break;
}
uint16 *argRef = &value;

View File

@@ -1407,6 +1407,11 @@ enum {
STR_SAVE_EVERY_HOUR = 2705,
STR_SAVE_NEVER = 2706,
STR_UNIT_SUFFIX_FEET = 2732,
STR_UNIT_SUFFIX_METRES = 2733,
STR_UNIT_SUFFIX_MILES_PER_HOUR = 2734,
STR_UNIT_SUFFIX_KILOMETRES_PER_HOUR = 2735,
STR_DATE_FORMAT_DMY = 2737,
STR_ROLLERCOASTER_TYCOON_1_DROPDOWN = 2740,
@@ -2182,6 +2187,9 @@ enum {
STR_TRAP_MOUSE = 5582,
STR_UNIT_SUFFIX_METRES_PER_SECOND = 5583,
STR_SI = 5584,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768
};

View File

@@ -40,7 +40,13 @@ int mph_to_kmph(int mph)
{
// 1 mph = 1.60934 kmph
// RCT2 approximates as 1.609375
return (mph * 1648) / 1024;
return (mph * 1648) >> 10;
}
int mph_to_mps(int mph)
{
// 1 mph = 0.44704 m/s
return (mph * 58594) >> 17;
}
bool filename_valid_characters(const utf8 *filename)

View File

@@ -26,6 +26,7 @@
int squaredmetres_to_squaredfeet(int squaredMetres);
int metres_to_feet(int metres);
int mph_to_kmph(int mph);
int mph_to_mps(int mph);
bool filename_valid_characters(const utf8 *filename);

View File

@@ -830,10 +830,12 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
case WIDX_DISTANCE_DROPDOWN:
gDropdownItemsFormat[0] = 1142;
gDropdownItemsFormat[1] = 1142;
gDropdownItemsFormat[2] = 1142;
gDropdownItemsArgs[0] = STR_IMPERIAL;
gDropdownItemsArgs[1] = STR_METRIC;
gDropdownItemsArgs[2] = STR_SI;
window_options_show_dropdown(w, widget, 2);
window_options_show_dropdown(w, widget, 3);
dropdown_set_checked(gConfigGeneral.measurement_format, true);
break;
@@ -1225,8 +1227,17 @@ static void window_options_invalidate(rct_window *w)
// currency: pounds, dollars, etc. (10 total)
RCT2_GLOBAL(0x013CE952 + 12, uint16) = CurrencyDescriptors[gConfigGeneral.currency_format].stringId;
// distance: metric/imperial
RCT2_GLOBAL(0x013CE952 + 14, uint16) = STR_IMPERIAL + gConfigGeneral.measurement_format;
// distance: metric / imperial / si
{
rct_string_id stringId;
switch (gConfigGeneral.measurement_format) {
default:
case MEASUREMENT_FORMAT_IMPERIAL: stringId = STR_IMPERIAL; break;
case MEASUREMENT_FORMAT_METRIC: stringId = STR_METRIC; break;
case MEASUREMENT_FORMAT_SI: stringId = STR_SI; break;
}
RCT2_GLOBAL(0x013CE952 + 14, uint16) = stringId;
}
// temperature: celsius/fahrenheit
RCT2_GLOBAL(0x013CE952 + 20, uint16) = STR_CELSIUS + gConfigGeneral.temperature_format;

View File

@@ -1585,7 +1585,7 @@ static void window_park_stats_paint(rct_window *w, rct_drawpixelinfo *dpi)
// Draw park size
parkSize = RCT2_GLOBAL(RCT2_ADDRESS_PARK_SIZE, uint16) * 10;
stringIndex = STR_PARK_SIZE_METRIC_LABEL;
if (!RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8)) {
if (gConfigGeneral.measurement_format == MEASUREMENT_FORMAT_IMPERIAL) {
stringIndex = STR_PARK_SIZE_IMPERIAL_LABEL;
parkSize = squaredmetres_to_squaredfeet(parkSize);
}