Changeset - r24435:88d8770a33ea
[Not reviewed]
master
0 4 0
jostephd - 4 years ago 2020-12-14 23:39:57
josteph@fastmail.com
Feature: new velocity unit "tiles/day" (#8278)
4 files changed with 21 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -194,6 +194,7 @@ STR_COLOUR_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_VE
 
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
src/strings.cpp
Show inline comments
 
@@ -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, co
 

	
 
			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;
 
			}
src/table/gameopt_settings.ini
Show inline comments
 
@@ -13,7 +13,7 @@ uint8 _old_units;                       
 
/* 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";
src/table/settings.ini
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general)