diff --git a/src/settings.cpp b/src/settings.cpp index 3b6a635fb2..9327672762 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -480,9 +480,6 @@ void IntSettingDesc::SetValueDParams(uint first_param, int32_t value) const } else { if ((this->flags & SF_GUI_DROPDOWN) != 0) { SetDParam(first_param++, this->str_val - this->min + value); - } else if ((this->flags & SF_GUI_NEGATIVE_IS_SPECIAL) != 0) { - SetDParam(first_param++, this->str_val + ((value >= 0) ? 1 : 0)); - value = abs(value); } else { SetDParam(first_param++, this->str_val + ((value == 0 && (this->flags & SF_GUI_0_IS_SPECIAL) != 0) ? 1 : 0)); } diff --git a/src/settings_internal.h b/src/settings_internal.h index 12b4b27ebe..f74127a8ae 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -16,7 +16,6 @@ enum SettingFlag : uint16_t { SF_NONE = 0, SF_GUI_0_IS_SPECIAL = 1 << 0, ///< A value of zero is possible and has a custom string (the one after "strval"). - SF_GUI_NEGATIVE_IS_SPECIAL = 1 << 1, ///< A negative value has another string (the one after "strval"). SF_GUI_DROPDOWN = 1 << 2, ///< The value represents a limited number of string-options (internally integer) presented as dropdown. SF_GUI_CURRENCY = 1 << 3, ///< The number represents money, so when reading value multiply by exchange rate. SF_NETWORK_ONLY = 1 << 4, ///< This setting only applies to network games. diff --git a/src/settings_table.cpp b/src/settings_table.cpp index 248f7867dc..224f9a1174 100644 --- a/src/settings_table.cpp +++ b/src/settings_table.cpp @@ -108,6 +108,13 @@ static void SettingsValueVelocityUnit(const IntSettingDesc &, uint first_param, SetDParam(first_param, val); } +/** A negative value has another string (the one after "strval"). */ +static void SettingsValueAbsolute(const IntSettingDesc &sd, uint first_param, int32_t value) +{ + SetDParam(first_param, sd.str_val + ((value >= 0) ? 1 : 0)); + SetDParam(first_param + 1, abs(value)); +} + /** Reposition the main toolbar as the setting changed. */ static void v_PositionMainToolbar(int32_t) { diff --git a/src/table/settings/company_settings.ini b/src/table/settings/company_settings.ini index de92167478..9c3b7a64ba 100644 --- a/src/table/settings/company_settings.ini +++ b/src/table/settings/company_settings.ini @@ -11,6 +11,7 @@ static void UpdateAllServiceInterval(int32_t new_value); static bool CanUpdateServiceInterval(VehicleType type, int32_t &new_value); static void UpdateServiceInterval(VehicleType type, int32_t new_value); +static void SettingsValueAbsolute(const IntSettingDesc &sd, uint first_param, int32_t value); static const SettingVariant _company_settings_table[] = { [post-amble] @@ -52,13 +53,14 @@ cat = SC_BASIC [SDT_VAR] var = engine_renew_months type = SLE_INT16 -flags = SF_PER_COMPANY | SF_GUI_NEGATIVE_IS_SPECIAL +flags = SF_PER_COMPANY def = 6 min = -12 max = 12 str = STR_CONFIG_SETTING_AUTORENEW_MONTHS strhelp = STR_CONFIG_SETTING_AUTORENEW_MONTHS_HELPTEXT strval = STR_CONFIG_SETTING_AUTORENEW_MONTHS_VALUE_BEFORE +val_cb = SettingsValueAbsolute [SDT_VAR] var = engine_renew_money