summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-06-29 09:47:18 +0000
committerrubidium <rubidium@openttd.org>2013-06-29 09:47:18 +0000
commitf9c9ff6ec3754ae7d36c64bff0a13bf8bda80bd8 (patch)
treeebcdd76048e5f65bc1fb0779866347b3c4f0a400 /src
parent6e97b7a6e81559f5e9fe3ccea2d1fda0095379c5 (diff)
downloadopenttd-f9c9ff6ec3754ae7d36c64bff0a13bf8bda80bd8.tar.xz
(svn r25508) -Change: split unit localisation choice into a choice per type of unit, and move it to the advanced settings
-Feature [FS#5482]: have tractive effort in imperial (lbf) and metric (kgf) units -Feature: have weights and volumes in imperial units (short tons, gallons)
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt44
-rw-r--r--src/saveload/afterload.cpp11
-rw-r--r--src/saveload/oldloader_sl.cpp3
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/settings_gui.cpp38
-rw-r--r--src/settings_type.h7
-rw-r--r--src/strings.cpp159
-rw-r--r--src/table/gameopt_settings.ini10
-rw-r--r--src/table/settings.ini102
9 files changed, 268 insertions, 109 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 424c728f0..3cf738091 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -199,21 +199,28 @@ STR_UNITS_POWER_IMPERIAL :{COMMA}hp
STR_UNITS_POWER_METRIC :{COMMA}hp
STR_UNITS_POWER_SI :{COMMA}kW
+STR_UNITS_WEIGHT_SHORT_IMPERIAL :{COMMA}t
STR_UNITS_WEIGHT_SHORT_METRIC :{COMMA}t
STR_UNITS_WEIGHT_SHORT_SI :{COMMA}kg
+STR_UNITS_WEIGHT_LONG_IMPERIAL :{COMMA} ton{P "" s}
STR_UNITS_WEIGHT_LONG_METRIC :{COMMA} tonne{P "" s}
STR_UNITS_WEIGHT_LONG_SI :{COMMA} kg
+STR_UNITS_VOLUME_SHORT_IMPERIAL :{COMMA}gal
STR_UNITS_VOLUME_SHORT_METRIC :{COMMA}l
STR_UNITS_VOLUME_SHORT_SI :{COMMA}m³
+STR_UNITS_VOLUME_LONG_IMPERIAL :{COMMA} gallon{P "" s}
STR_UNITS_VOLUME_LONG_METRIC :{COMMA} litre{P "" s}
STR_UNITS_VOLUME_LONG_SI :{COMMA} m³
+STR_UNITS_FORCE_IMPERIAL :{COMMA} lbf
+STR_UNITS_FORCE_METRIC :{COMMA} kgf
STR_UNITS_FORCE_SI :{COMMA} kN
STR_UNITS_HEIGHT_IMPERIAL :{COMMA} ft
+STR_UNITS_HEIGHT_METRIC :{COMMA} m
STR_UNITS_HEIGHT_SI :{COMMA} m
# Common window strings
@@ -1588,7 +1595,44 @@ STR_CONFIG_SETTING_DEMAND_SIZE_HELPTEXT :Setting this to
STR_CONFIG_SETTING_SHORT_PATH_SATURATION :Saturation of short paths before using capacious paths: {STRING2}
STR_CONFIG_SETTING_SHORT_PATH_SATURATION_HELPTEXT :Frequently there are multiple paths between two given stations. Cargodist will saturate the shortest path first, then use the second shortest path until that is saturated and so on. Saturation is determined by an estimation of capacity and planned usage. Once it has saturated all paths, if there is still demand left, it will overload all paths, prefering the ones with high capacity. Most of the time the algorithm will not estimate the capacity accurately, though. This setting allows you to specify up to which percentage a shorter path must be saturated in the first pass before choosing the next longer one. Set it to less than 100% to avoid overcrowded stations in case of overestimated capacity.
+STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY :Speed units: {STRING2}
+STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_HELPTEXT :Whenever a speed is shown in the user interface, show it in the selected units
+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_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
+STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_IMPERIAL :Imperial (hp)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_METRIC :Metric (hp)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_SI :SI (kW)
+
+STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT :Weights units: {STRING2}
+STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT_HELPTEXT :Whenever weights are shown in the user interface, show it in the selected units
+STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT_IMPERIAL :Imperial (short t/ton)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT_METRIC :Metric (t/tonne)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT_SI :SI (kg)
+
+STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME :Volumes units: {STRING2}
+STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME_HELPTEXT :Whenever volumes are shown in the user interface, show it in the selected units
+STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME_IMPERIAL :Imperial (gal)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME_METRIC :Metric (l)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME_SI :SI (m³)
+
+STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE :Tractive effort units: {STRING2}
+STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE_HELPTEXT :Whenever tractive effort, also known as tractive force, is shown in the user interface, show it in the selected units
+STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE_IMPERIAL :Imperial (lbf)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE_METRIC :Metric (kgf)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE_SI :SI (kN)
+
+STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT :Heights units: {STRING2}
+STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_HELPTEXT :Whenever heights are shown in the user interface, show it in the selected units
+STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_IMPERIAL :Imperial (ft)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_METRIC :Metric (m)
+STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_SI :SI (m)
+
STR_CONFIG_SETTING_GUI :{ORANGE}Interface
+STR_CONFIG_SETTING_LOCALISATION :{ORANGE}Localisation
STR_CONFIG_SETTING_CONSTRUCTION :{ORANGE}Construction
STR_CONFIG_SETTING_VEHICLES :{ORANGE}Vehicles
STR_CONFIG_SETTING_STATIONS :{ORANGE}Stations
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 478717ff8..d969a40fc 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2803,6 +2803,17 @@ bool AfterLoadGame()
}
}
+ if (IsSavegameVersionBefore(184)) {
+ /* The global units configuration is split up in multiple configurations. */
+ extern uint8 _old_units;
+ _settings_game.locale.units_velocity = Clamp(_old_units, 0, 2);
+ _settings_game.locale.units_power = Clamp(_old_units, 0, 2);
+ _settings_game.locale.units_weight = Clamp(_old_units, 1, 2);
+ _settings_game.locale.units_volume = Clamp(_old_units, 1, 2);
+ _settings_game.locale.units_force = 2;
+ _settings_game.locale.units_height = Clamp(_old_units, 0, 2);
+ }
+
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index 791e63db5..f9215cf1d 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1577,6 +1577,7 @@ extern uint16 _disaster_delay;
extern byte _trees_tick_ctr;
extern byte _age_cargo_skip_counter; // From misc_sl.cpp
extern uint8 _old_diff_level;
+extern uint8 _old_units;
static const OldChunks main_chunk[] = {
OCL_ASSERT( OC_TTD, 0 ),
OCL_ASSERT( OC_TTO, 0 ),
@@ -1705,7 +1706,7 @@ static const OldChunks main_chunk[] = {
OCL_NULL( 1 ), ///< Station tick counter, no longer in use
OCL_VAR ( OC_UINT8, 1, &_settings_game.locale.currency ),
- OCL_VAR ( OC_UINT8, 1, &_settings_game.locale.units ),
+ OCL_VAR ( OC_UINT8, 1, &_old_units ),
OCL_VAR ( OC_FILE_U8 | OC_VAR_U32, 1, &_cur_company_tick_index ),
OCL_NULL( 2 ), ///< Date stuff, calculated automatically
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 7b7d0342c..13129832b 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -249,8 +249,9 @@
* 181 25012
* 182 25296
* 183 25363
+ * 184 xxxxx
*/
-extern const uint16 SAVEGAME_VERSION = 183; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 184; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 92f7d4440..efd958095 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -39,13 +39,6 @@
#include "querystring_gui.h"
-static const StringID _units_dropdown[] = {
- STR_GAME_OPTIONS_MEASURING_UNITS_IMPERIAL,
- STR_GAME_OPTIONS_MEASURING_UNITS_METRIC,
- STR_GAME_OPTIONS_MEASURING_UNITS_SI,
- INVALID_STRING_ID
-};
-
static const StringID _driveside_dropdown[] = {
STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT,
STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_RIGHT,
@@ -204,16 +197,6 @@ struct GameOptionsWindow : Window {
break;
}
- case WID_GO_DISTANCE_DROPDOWN: { // Setup distance unit dropdown
- list = new DropDownList();
- *selected_index = this->opt->locale.units;
- const StringID *items = _units_dropdown;
- for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
- list->push_back(new DropDownListStringItem(*items, i, false));
- }
- break;
- }
-
case WID_GO_ROADSIDE_DROPDOWN: { // Setup road-side dropdown
list = new DropDownList();
*selected_index = this->opt->vehicle.road_side;
@@ -321,7 +304,6 @@ struct GameOptionsWindow : Window {
{
switch (widget) {
case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break;
- case WID_GO_DISTANCE_DROPDOWN: SetDParam(0, STR_GAME_OPTIONS_MEASURING_UNITS_IMPERIAL + this->opt->locale.units); break;
case WID_GO_ROADSIDE_DROPDOWN: SetDParam(0, STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT + this->opt->vehicle.road_side); break;
case WID_GO_TOWNNAME_DROPDOWN: SetDParam(0, TownName(this->opt->game_creation.town_name)); break;
case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
@@ -495,11 +477,6 @@ struct GameOptionsWindow : Window {
ReInitAllWindows();
break;
- case WID_GO_DISTANCE_DROPDOWN: // Measuring units
- this->opt->locale.units = index;
- MarkWholeScreenDirty();
- break;
-
case WID_GO_ROADSIDE_DROPDOWN: // Road side
if (this->opt->vehicle.road_side != index) { // only change if setting changed
uint i;
@@ -605,9 +582,6 @@ static const NWidgetPart _nested_game_options_widgets[] = {
EndContainer(),
NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
- NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_MEASURING_UNITS_FRAME, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_DISTANCE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_MEASURING_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0),
- EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_TOWNNAME_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
EndContainer(),
@@ -1413,6 +1387,17 @@ uint SettingsPage::Draw(GameSettings *settings_ptr, int left, int right, int bas
}
+static SettingEntry _settings_ui_localisation[] = {
+ SettingEntry("locale.units_velocity"),
+ SettingEntry("locale.units_power"),
+ SettingEntry("locale.units_weight"),
+ SettingEntry("locale.units_volume"),
+ SettingEntry("locale.units_force"),
+ SettingEntry("locale.units_height"),
+};
+/** Localisation options sub-page */
+static SettingsPage _settings_ui_localisation_page = {_settings_ui_localisation, lengthof(_settings_ui_localisation)};
+
static SettingEntry _settings_ui_display[] = {
SettingEntry("gui.date_format_in_default_names"),
SettingEntry("gui.population_in_label"),
@@ -1487,6 +1472,7 @@ static SettingEntry _settings_ui_news[] = {
static SettingsPage _settings_ui_news_page = {_settings_ui_news, lengthof(_settings_ui_news)};
static SettingEntry _settings_ui[] = {
+ SettingEntry(&_settings_ui_localisation_page, STR_CONFIG_SETTING_LOCALISATION),
SettingEntry(&_settings_ui_display_page, STR_CONFIG_SETTING_DISPLAY_OPTIONS),
SettingEntry(&_settings_ui_interaction_page, STR_CONFIG_SETTING_INTERACTION),
SettingEntry(&_settings_ui_sound_page, STR_CONFIG_SETTING_SOUND),
diff --git a/src/settings_type.h b/src/settings_type.h
index 45aa157e9..7731e40c9 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -194,7 +194,12 @@ struct MusicSettings {
/** Settings related to currency/unit systems. */
struct LocaleSettings {
byte currency; ///< currency we currently use
- byte units; ///< unit system we show everything
+ byte units_velocity; ///< unit system for velocity
+ byte units_power; ///< unit system for power
+ byte units_weight; ///< unit system for weight
+ byte units_volume; ///< unit system for volume
+ byte units_force; ///< unit system for force
+ byte units_height; ///< unit system for height
char *digit_group_separator; ///< thousand separator for non-currencies
char *digit_group_separator_currency; ///< thousand separator for currencies
char *digit_decimal_separator; ///< decimal separator
diff --git a/src/strings.cpp b/src/strings.cpp
index 5ea914035..bf65faf8c 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -673,49 +673,59 @@ struct UnitConversion {
}
};
+/** Information about a specific unit system. */
struct Units {
- UnitConversion c_velocity; ///< Conversion for velocity
- StringID velocity; ///< String for velocity
- UnitConversion c_power; ///< Conversion for power
- StringID power; ///< String for power
- UnitConversion c_weight; ///< Conversion for weight
- StringID s_weight; ///< Short string for weight
- StringID l_weight; ///< Long string for weight
- UnitConversion c_volume; ///< Conversion for volume
- StringID s_volume; ///< Short string for volume
- StringID l_volume; ///< Long string for volume
- UnitConversion c_force; ///< Conversion for force
- StringID force; ///< String for force
- UnitConversion c_height; ///< Conversion for height
- StringID height; ///< String for height
+ UnitConversion c; ///< Conversion
+ StringID s; ///< String for the unit
};
-/* Unit conversions */
-static const Units _units[] = {
- { // Imperial (Original, mph, hp, metric ton, litre, kN, ft)
- { 1, 0}, STR_UNITS_VELOCITY_IMPERIAL,
- { 1, 0}, STR_UNITS_POWER_IMPERIAL,
- { 1, 0}, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC,
- {1000, 0}, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
- { 1, 0}, STR_UNITS_FORCE_SI,
- { 3, 0}, STR_UNITS_HEIGHT_IMPERIAL, // "Wrong" conversion factor for more nicer GUI values
- },
- { // Metric (km/h, hp, metric ton, litre, kN, metre)
- { 103, 6}, STR_UNITS_VELOCITY_METRIC,
- {4153, 12}, STR_UNITS_POWER_METRIC,
- { 1, 0}, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC,
- {1000, 0}, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
- { 1, 0}, STR_UNITS_FORCE_SI,
- { 1, 0}, STR_UNITS_HEIGHT_SI,
- },
- { // SI (m/s, kilowatt, kilogram, cubic metre, kilonewton, metre)
- {1831, 12}, STR_UNITS_VELOCITY_SI,
- {6109, 13}, STR_UNITS_POWER_SI,
- {1000, 0}, STR_UNITS_WEIGHT_SHORT_SI, STR_UNITS_WEIGHT_LONG_SI,
- { 1, 0}, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI,
- { 1, 0}, STR_UNITS_FORCE_SI,
- { 1, 0}, STR_UNITS_HEIGHT_SI,
- },
+/** Information about a specific unit system with a long variant. */
+struct UnitsLong {
+ UnitConversion c; ///< Conversion
+ StringID s; ///< String for the short variant of the unit
+ StringID l; ///< String for the long variant of the unit
+};
+
+/** 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 },
+};
+
+/** 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 },
+};
+
+/** Unit conversions for weight. */
+static const UnitsLong _units_weight[] = {
+ { {4515, 12}, STR_UNITS_WEIGHT_SHORT_IMPERIAL, STR_UNITS_WEIGHT_LONG_IMPERIAL },
+ { { 1, 0}, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC },
+ { {1000, 0}, STR_UNITS_WEIGHT_SHORT_SI, STR_UNITS_WEIGHT_LONG_SI },
+};
+
+/** Unit conversions for volume. */
+static const UnitsLong _units_volume[] = {
+ { {4227, 4}, STR_UNITS_VOLUME_SHORT_IMPERIAL, STR_UNITS_VOLUME_LONG_IMPERIAL },
+ { {1000, 0}, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC },
+ { { 1, 0}, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI },
+};
+
+/** 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 },
+};
+
+/** 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 },
};
/**
@@ -728,7 +738,7 @@ uint ConvertSpeedToDisplaySpeed(uint speed)
/* For historical reasons we don't want to mess with the
* conversion for speed. So, don't round it and keep the
* original conversion factors instead of the real ones. */
- return _units[_settings_game.locale.units].c_velocity.ToDisplay(speed, false);
+ return _units_velocity[_settings_game.locale.units_velocity].c.ToDisplay(speed, false);
}
/**
@@ -738,7 +748,7 @@ uint ConvertSpeedToDisplaySpeed(uint speed)
*/
uint ConvertDisplaySpeedToSpeed(uint speed)
{
- return _units[_settings_game.locale.units].c_velocity.FromDisplay(speed);
+ return _units_velocity[_settings_game.locale.units_velocity].c.FromDisplay(speed);
}
/**
@@ -748,7 +758,7 @@ uint ConvertDisplaySpeedToSpeed(uint speed)
*/
uint ConvertKmhishSpeedToDisplaySpeed(uint speed)
{
- return _units[_settings_game.locale.units].c_velocity.ToDisplay(speed * 10, false) / 16;
+ return _units_velocity[_settings_game.locale.units_velocity].c.ToDisplay(speed * 10, false) / 16;
}
/**
@@ -758,7 +768,7 @@ uint ConvertKmhishSpeedToDisplaySpeed(uint speed)
*/
uint ConvertDisplaySpeedToKmhishSpeed(uint speed)
{
- return _units[_settings_game.locale.units].c_velocity.FromDisplay(speed * 16, true, 10);
+ return _units_velocity[_settings_game.locale.units_velocity].c.FromDisplay(speed * 16, true, 10);
}
/**
* Parse most format codes within a string and write the result to a buffer.
@@ -1092,11 +1102,11 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
int64 amount = 0;
switch (cargo_str) {
case STR_TONS:
- amount = _units[_settings_game.locale.units].c_weight.ToDisplay(args->GetInt64());
+ amount = _units_weight[_settings_game.locale.units_weight].c.ToDisplay(args->GetInt64());
break;
case STR_LITERS:
- amount = _units[_settings_game.locale.units].c_volume.ToDisplay(args->GetInt64());
+ amount = _units_volume[_settings_game.locale.units_volume].c.ToDisplay(args->GetInt64());
break;
default: {
@@ -1119,18 +1129,18 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
StringID cargo_str = CargoSpec::Get(cargo)->units_volume;
switch (cargo_str) {
case STR_TONS: {
- assert(_settings_game.locale.units < lengthof(_units));
- int64 args_array[] = {_units[_settings_game.locale.units].c_weight.ToDisplay(args->GetInt64())};
+ assert(_settings_game.locale.units_weight < lengthof(_units_weight));
+ int64 args_array[] = {_units_weight[_settings_game.locale.units_weight].c.ToDisplay(args->GetInt64())};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].l_weight), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_weight[_settings_game.locale.units_weight].l), &tmp_params, last);
break;
}
case STR_LITERS: {
- assert(_settings_game.locale.units < lengthof(_units));
- int64 args_array[] = {_units[_settings_game.locale.units].c_volume.ToDisplay(args->GetInt64())};
+ assert(_settings_game.locale.units_volume < lengthof(_units_volume));
+ int64 args_array[] = {_units_volume[_settings_game.locale.units_volume].c.ToDisplay(args->GetInt64())};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].l_volume), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_volume[_settings_game.locale.units_volume].l), &tmp_params, last);
break;
}
@@ -1213,65 +1223,66 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
break;
case SCC_FORCE: { // {FORCE}
- assert(_settings_game.locale.units < lengthof(_units));
- int64 args_array[1] = {_units[_settings_game.locale.units].c_force.ToDisplay(args->GetInt64())};
+ assert(_settings_game.locale.units_force < lengthof(_units_force));
+ int64 args_array[1] = {_units_force[_settings_game.locale.units_force].c.ToDisplay(args->GetInt64())};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].force), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_force[_settings_game.locale.units_force].s), &tmp_params, last);
break;
}
case SCC_HEIGHT: { // {HEIGHT}
- int64 args_array[] = {_units[_settings_game.locale.units].c_height.ToDisplay(args->GetInt64())};
+ assert(_settings_game.locale.units_height < lengthof(_units_height));
+ int64 args_array[] = {_units_height[_settings_game.locale.units_height].c.ToDisplay(args->GetInt64())};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].height), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_height[_settings_game.locale.units_height].s), &tmp_params, last);
break;
}
case SCC_POWER: { // {POWER}
- assert(_settings_game.locale.units < lengthof(_units));
- int64 args_array[1] = {_units[_settings_game.locale.units].c_power.ToDisplay(args->GetInt64())};
+ assert(_settings_game.locale.units_power < lengthof(_units_power));
+ int64 args_array[1] = {_units_power[_settings_game.locale.units_power].c.ToDisplay(args->GetInt64())};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].power), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_power[_settings_game.locale.units_power].s), &tmp_params, last);
break;
}
case SCC_VELOCITY: { // {VELOCITY}
- assert(_settings_game.locale.units < lengthof(_units));
+ assert(_settings_game.locale.units_velocity < lengthof(_units_velocity));
int64 args_array[] = {ConvertKmhishSpeedToDisplaySpeed(args->GetInt64(SCC_VELOCITY))};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].velocity), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_velocity[_settings_game.locale.units_velocity].s), &tmp_params, last);
break;
}
case SCC_VOLUME_SHORT: { // {VOLUME_SHORT}
- assert(_settings_game.locale.units < lengthof(_units));
- int64 args_array[1] = {_units[_settings_game.locale.units].c_volume.ToDisplay(args->GetInt64())};
+ assert(_settings_game.locale.units_volume < lengthof(_units_volume));
+ int64 args_array[1] = {_units_volume[_settings_game.locale.units_volume].c.ToDisplay(args->GetInt64())};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].s_volume), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_volume[_settings_game.locale.units_volume].s), &tmp_params, last);
break;
}
case SCC_VOLUME_LONG: { // {VOLUME_LONG}
- assert(_settings_game.locale.units < lengthof(_units));
- int64 args_array[1] = {_units[_settings_game.locale.units].c_volume.ToDisplay(args->GetInt64(SCC_VOLUME_LONG))};
+ assert(_settings_game.locale.units_volume < lengthof(_units_volume));
+ int64 args_array[1] = {_units_volume[_settings_game.locale.units_volume].c.ToDisplay(args->GetInt64(SCC_VOLUME_LONG))};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].l_volume), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_volume[_settings_game.locale.units_volume].l), &tmp_params, last);
break;
}
case SCC_WEIGHT_SHORT: { // {WEIGHT_SHORT}
- assert(_settings_game.locale.units < lengthof(_units));
- int64 args_array[1] = {_units[_settings_game.locale.units].c_weight.ToDisplay(args->GetInt64())};
+ assert(_settings_game.locale.units_weight < lengthof(_units_weight));
+ int64 args_array[1] = {_units_weight[_settings_game.locale.units_weight].c.ToDisplay(args->GetInt64())};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].s_weight), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_weight[_settings_game.locale.units_weight].s), &tmp_params, last);
break;
}
case SCC_WEIGHT_LONG: { // {WEIGHT_LONG}
- assert(_settings_game.locale.units < lengthof(_units));
- int64 args_array[1] = {_units[_settings_game.locale.units].c_weight.ToDisplay(args->GetInt64(SCC_WEIGHT_LONG))};
+ assert(_settings_game.locale.units_weight < lengthof(_units_weight));
+ int64 args_array[1] = {_units_weight[_settings_game.locale.units_weight].c.ToDisplay(args->GetInt64(SCC_WEIGHT_LONG))};
StringParameters tmp_params(args_array);
- buff = FormatString(buff, GetStringPtr(_units[_settings_game.locale.units].l_weight), &tmp_params, last);
+ buff = FormatString(buff, GetStringPtr(_units_weight[_settings_game.locale.units_weight].l), &tmp_params, last);
break;
}
diff --git a/src/table/gameopt_settings.ini b/src/table/gameopt_settings.ini
index 42f906d32..baf7c3542 100644
--- a/src/table/gameopt_settings.ini
+++ b/src/table/gameopt_settings.ini
@@ -10,6 +10,7 @@
static const uint GAME_DIFFICULTY_NUM = 18;
static uint16 _old_diff_custom[GAME_DIFFICULTY_NUM];
uint8 _old_diff_level; ///< Old difficulty level from old savegames
+uint8 _old_units; ///< Old units from old savegames
/* Most of these strings are used both for gameopt-backward compatability
* and the settings tables. The rest is here for consistency. */
@@ -44,6 +45,7 @@ SDTG_GENERAL = SDTG_GENERAL($name, $sdt_cmd, $sle_cmd, $type, $flags, $guiflags,
SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat),
SDT_NULL = SDT_NULL($length, $from, $to),
SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat),
+SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat),
SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $load, $cat),
SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat),
SDT_END = SDT_END()
@@ -112,11 +114,11 @@ max = CURRENCY_END - 1
full = _locale_currencies
cat = SC_BASIC
-[SDT_OMANY]
-base = GameSettings
-var = locale.units
+[SDTG_OMANY]
+name = ""units""
+var = _old_units
type = SLE_UINT8
-flags = SLF_NO_NETWORK_SYNC
+flags = SLF_NOT_IN_CONFIG
def = 1
max = 2
full = _locale_units
diff --git a/src/table/settings.ini b/src/table/settings.ini
index 70363b600..0b723a0ae 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -64,6 +64,7 @@ const SettingDesc _settings[] = {
[templates]
SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat),
SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat),
+SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat),
SDTC_BOOL = SDTC_BOOL( $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat),
SDTC_LIST = SDTC_LIST( $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat),
SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat),
@@ -2325,17 +2326,114 @@ full = _locale_currencies
proc = RedrawScreen
cat = SC_BASIC
+[SDTG_OMANY]
+name = ""units""
+var = _old_units
+type = SLE_UINT8
+from = 97
+to = 183
+flags = SLF_NOT_IN_CONFIG
+def = 1
+max = 2
+full = _locale_units
+proc = RedrawScreen
+cat = SC_BASIC
+
[SDT_OMANY]
base = GameSettings
-var = locale.units
+var = locale.units_velocity
type = SLE_UINT8
-from = 97
+from = 184
+flags = SLF_NO_NETWORK_SYNC
+guiflags = SGF_MULTISTRING
+def = 1
+max = 2
+full = _locale_units
+proc = RedrawScreen
+cat = SC_BASIC
+str = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY
+strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_HELPTEXT
+strval = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_IMPERIAL
+
+[SDT_OMANY]
+base = GameSettings
+var = locale.units_power
+type = SLE_UINT8
+from = 184
+flags = SLF_NO_NETWORK_SYNC
+guiflags = SGF_MULTISTRING
+def = 1
+max = 2
+full = _locale_units
+proc = RedrawScreen
+cat = SC_BASIC
+str = STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER
+strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_HELPTEXT
+strval = STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_IMPERIAL
+
+[SDT_OMANY]
+base = GameSettings
+var = locale.units_weight
+type = SLE_UINT8
+from = 184
+flags = SLF_NO_NETWORK_SYNC
+guiflags = SGF_MULTISTRING
+def = 1
+max = 2
+full = _locale_units
+proc = RedrawScreen
+cat = SC_BASIC
+str = STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT
+strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT_HELPTEXT
+strval = STR_CONFIG_SETTING_LOCALISATION_UNITS_WEIGHT_IMPERIAL
+
+[SDT_OMANY]
+base = GameSettings
+var = locale.units_volume
+type = SLE_UINT8
+from = 184
flags = SLF_NO_NETWORK_SYNC
+guiflags = SGF_MULTISTRING
+def = 1
+max = 2
+full = _locale_units
+proc = RedrawScreen
+cat = SC_BASIC
+str = STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME
+strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME_HELPTEXT
+strval = STR_CONFIG_SETTING_LOCALISATION_UNITS_VOLUME_IMPERIAL
+
+[SDT_OMANY]
+base = GameSettings
+var = locale.units_force
+type = SLE_UINT8
+from = 184
+flags = SLF_NO_NETWORK_SYNC
+guiflags = SGF_MULTISTRING
+def = 2
+max = 2
+full = _locale_units
+proc = RedrawScreen
+cat = SC_BASIC
+str = STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE
+strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE_HELPTEXT
+strval = STR_CONFIG_SETTING_LOCALISATION_UNITS_FORCE_IMPERIAL
+
+[SDT_OMANY]
+base = GameSettings
+var = locale.units_height
+type = SLE_UINT8
+from = 184
+flags = SLF_NO_NETWORK_SYNC
+guiflags = SGF_MULTISTRING
def = 1
max = 2
full = _locale_units
proc = RedrawScreen
cat = SC_BASIC
+str = STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT
+strhelp = STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_HELPTEXT
+strval = STR_CONFIG_SETTING_LOCALISATION_UNITS_HEIGHT_IMPERIAL
[SDT_STR]
base = GameSettings