diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index f20d8f3db5..91f0a3193b 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2718,11 +2718,12 @@ struct GameSettingsWindow : Window { /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */ if (this->last_clicked == pe && !sd->IsBoolSetting() && !(sd->flags & (SF_GUI_DROPDOWN | SF_ENUM))) { int64 value64 = value; - /* Show the correct currency-translated value */ + /* Show the correct currency or velocity translated value */ if (sd->flags & SF_GUI_CURRENCY) value64 *= _currency->rate; + if (sd->flags & SF_GUI_VELOCITY) value64 = ConvertKmhishSpeedToDisplaySpeed((uint)value64); this->valuewindow_entry = pe; - if (sd->flags & SF_DECIMAL1) { + if (sd->flags & SF_DECIMAL1 || (sd->flags & SF_GUI_VELOCITY && _settings_game.locale.units_velocity == 3)) { SetDParam(0, value64); ShowQueryString(STR_JUST_DECIMAL1, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL_DECIMAL, QSF_ENABLE_DEFAULT); } else { @@ -2755,7 +2756,7 @@ struct GameSettingsWindow : Window { int32 value; if (!StrEmpty(str)) { long long llvalue; - if (sd->flags & SF_DECIMAL1) { + if (sd->flags & SF_DECIMAL1 || (sd->flags & SF_GUI_VELOCITY && _settings_game.locale.units_velocity == 3)) { llvalue = atof(str) * 10; } else { llvalue = atoll(str); @@ -2765,6 +2766,9 @@ struct GameSettingsWindow : Window { if (sd->flags & SF_GUI_CURRENCY) llvalue /= _currency->rate; value = (int32)ClampToI32(llvalue); + + /* Save the correct velocity-translated value */ + if (sd->flags & SF_GUI_VELOCITY) value = ConvertDisplaySpeedToKmhishSpeed(value); } else { value = sd->def; } diff --git a/src/settings_internal.h b/src/settings_internal.h index ed20bf1e4c..26edeb914a 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -32,6 +32,7 @@ enum SettingFlag : uint32 { SF_NO_NEWGAME = 1 << 15, ///< the setting does not apply and is not shown in a new game context SF_DEC1SCALE = 1 << 16, ///< also display a float representation of the scale of a decimal1 scale parameter SF_RUN_CALLBACKS_ON_PARSE = 1 << 17, ///< run callbacks when parsing from config file + SF_GUI_VELOCITY = 1 << 18, ///< setting value is a velocity }; DECLARE_ENUM_AS_BIT_SET(SettingFlag) diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index 04f1c7a2ea..40cf04793f 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -1358,6 +1358,7 @@ cat = SC_EXPERT [SDT_VAR] var = vehicle.through_load_speed_limit type = SLE_UINT16 +flags = SF_GUI_VELOCITY def = 15 min = 5 max = 500