mirror of https://github.com/OpenTTD/OpenTTD
Feature: new velocity unit "tiles/day" (#8278)
parent
79240eab1e
commit
b1cf79da5b
|
@ -194,6 +194,7 @@ STR_COLOUR_DEFAULT :Default
|
|||
STR_UNITS_VELOCITY_IMPERIAL :{COMMA}{NBSP}mph
|
||||
STR_UNITS_VELOCITY_METRIC :{COMMA}{NBSP}km/h
|
||||
STR_UNITS_VELOCITY_SI :{COMMA}{NBSP}m/s
|
||||
STR_UNITS_VELOCITY_GAMEUNITS :{DECIMAL}{NBSP}tiles/day
|
||||
|
||||
STR_UNITS_POWER_IMPERIAL :{COMMA}{NBSP}hp
|
||||
STR_UNITS_POWER_METRIC :{COMMA}{NBSP}hp
|
||||
|
@ -1678,6 +1679,7 @@ STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_HELPTEXT :Whenever a spee
|
|||
STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_IMPERIAL :Imperial (mph)
|
||||
STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_METRIC :Metric (km/h)
|
||||
STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_SI :SI (m/s)
|
||||
STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_GAMEUNITS :Game units (tiles/day)
|
||||
|
||||
STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER :Vehicle power units: {STRING2}
|
||||
STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_HELPTEXT :Whenever a vehicle's power is shown in the user interface, show it in the selected units
|
||||
|
|
|
@ -665,6 +665,7 @@ struct UnitConversion {
|
|||
struct Units {
|
||||
UnitConversion c; ///< Conversion
|
||||
StringID s; ///< String for the unit
|
||||
unsigned int decimal_places; ///< Number of decimal places embedded in the value. For example, 1 if the value is in tenths, and 3 if the value is in thousandths.
|
||||
};
|
||||
|
||||
/** Information about a specific unit system with a long variant. */
|
||||
|
@ -676,16 +677,17 @@ struct UnitsLong {
|
|||
|
||||
/** Unit conversions for velocity. */
|
||||
static const Units _units_velocity[] = {
|
||||
{ { 1, 0}, STR_UNITS_VELOCITY_IMPERIAL },
|
||||
{ { 103, 6}, STR_UNITS_VELOCITY_METRIC },
|
||||
{ {1831, 12}, STR_UNITS_VELOCITY_SI },
|
||||
{ { 1, 0}, STR_UNITS_VELOCITY_IMPERIAL, 0 },
|
||||
{ { 103, 6}, STR_UNITS_VELOCITY_METRIC, 0 },
|
||||
{ { 1831, 12}, STR_UNITS_VELOCITY_SI, 0 },
|
||||
{ {37888, 16}, STR_UNITS_VELOCITY_GAMEUNITS, 1 },
|
||||
};
|
||||
|
||||
/** Unit conversions for velocity. */
|
||||
static const Units _units_power[] = {
|
||||
{ { 1, 0}, STR_UNITS_POWER_IMPERIAL },
|
||||
{ {4153, 12}, STR_UNITS_POWER_METRIC },
|
||||
{ {6109, 13}, STR_UNITS_POWER_SI },
|
||||
{ { 1, 0}, STR_UNITS_POWER_IMPERIAL, 0 },
|
||||
{ {4153, 12}, STR_UNITS_POWER_METRIC, 0 },
|
||||
{ {6109, 13}, STR_UNITS_POWER_SI, 0 },
|
||||
};
|
||||
|
||||
/** Unit conversions for weight. */
|
||||
|
@ -704,16 +706,16 @@ static const UnitsLong _units_volume[] = {
|
|||
|
||||
/** Unit conversions for force. */
|
||||
static const Units _units_force[] = {
|
||||
{ {3597, 4}, STR_UNITS_FORCE_IMPERIAL },
|
||||
{ {3263, 5}, STR_UNITS_FORCE_METRIC },
|
||||
{ { 1, 0}, STR_UNITS_FORCE_SI },
|
||||
{ {3597, 4}, STR_UNITS_FORCE_IMPERIAL, 0 },
|
||||
{ {3263, 5}, STR_UNITS_FORCE_METRIC, 0 },
|
||||
{ { 1, 0}, STR_UNITS_FORCE_SI, 0 },
|
||||
};
|
||||
|
||||
/** Unit conversions for height. */
|
||||
static const Units _units_height[] = {
|
||||
{ { 3, 0}, STR_UNITS_HEIGHT_IMPERIAL }, // "Wrong" conversion factor for more nicer GUI values
|
||||
{ { 1, 0}, STR_UNITS_HEIGHT_METRIC },
|
||||
{ { 1, 0}, STR_UNITS_HEIGHT_SI },
|
||||
{ { 3, 0}, STR_UNITS_HEIGHT_IMPERIAL, 0 }, // "Wrong" conversion factor for more nicer GUI values
|
||||
{ { 1, 0}, STR_UNITS_HEIGHT_METRIC, 0 },
|
||||
{ { 1, 0}, STR_UNITS_HEIGHT_SI, 0 },
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1228,8 +1230,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
|||
|
||||
case SCC_VELOCITY: { // {VELOCITY}
|
||||
assert(_settings_game.locale.units_velocity < lengthof(_units_velocity));
|
||||
int64 args_array[] = {ConvertKmhishSpeedToDisplaySpeed(args->GetInt64(SCC_VELOCITY))};
|
||||
StringParameters tmp_params(args_array);
|
||||
unsigned int decimal_places = _units_velocity[_settings_game.locale.units_velocity].decimal_places;
|
||||
uint64 args_array[] = {ConvertKmhishSpeedToDisplaySpeed(args->GetInt64(SCC_VELOCITY)), decimal_places};
|
||||
StringParameters tmp_params(args_array, decimal_places ? 2 : 1, nullptr);
|
||||
buff = FormatString(buff, GetStringPtr(_units_velocity[_settings_game.locale.units_velocity].s), &tmp_params, last);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ uint8 _old_units; ///< Old units from old s
|
|||
/* Most of these strings are used both for gameopt-backward compatibility
|
||||
* and the settings tables. The rest is here for consistency. */
|
||||
static const char *_locale_currencies = "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|RON|RUR|SIT|SEK|YTL|SKK|BRL|EEK|custom";
|
||||
static const char *_locale_units = "imperial|metric|si";
|
||||
static const char *_locale_units = "imperial|metric|si|gameunits";
|
||||
static const char *_town_names = "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovak|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan";
|
||||
static const char *_climates = "temperate|arctic|tropic|toyland";
|
||||
static const char *_autosave_interval = "off|monthly|quarterly|half year|yearly";
|
||||
|
|
|
@ -2475,7 +2475,7 @@ from = SLV_184
|
|||
flags = SLF_NO_NETWORK_SYNC
|
||||
guiflags = SGF_MULTISTRING
|
||||
def = 1
|
||||
max = 2
|
||||
max = 3
|
||||
full = _locale_units
|
||||
proc = RedrawScreen
|
||||
cat = SC_BASIC
|
||||
|
|
Loading…
Reference in New Issue