diff --git a/src/settings.cpp b/src/settings.cpp index 1162eee2d4..40b372212c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -459,13 +459,14 @@ StringID IntSettingDesc::GetHelp() const */ void IntSettingDesc::SetValueDParams(uint first_param, int32_t value) const { + auto [min_val, _] = this->GetRange(); if (this->set_value_dparams_cb != nullptr) { this->set_value_dparams_cb(*this, first_param, value); } else if (this->IsBoolSetting()) { SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF); } else { if ((this->flags & SF_GUI_DROPDOWN) != 0) { - SetDParam(first_param++, this->str_val - this->min + value); + SetDParam(first_param++, this->str_val - min_val + value); } else { SetDParam(first_param++, this->str_val + ((value == 0 && (this->flags & SF_GUI_0_IS_SPECIAL) != 0) ? 1 : 0)); } @@ -482,6 +483,15 @@ int32_t IntSettingDesc::GetDefaultValue() const return this->get_def_cb != nullptr ? this->get_def_cb(*this) : this->def; } +/** + * Get the min/max range for the setting. + * @return The min/max range. + */ +std::tuple IntSettingDesc::GetRange() const +{ + return this->get_range_cb != nullptr ? this->get_range_cb(*this) : std::tuple(this->min, this->max); +} + /** * Make the value valid and then write it to the setting. * See #MakeValidValid and #Write for more details. @@ -505,6 +515,7 @@ void IntSettingDesc::MakeValueValidAndWrite(const void *object, int32_t val) con */ void IntSettingDesc::MakeValueValid(int32_t &val) const { + auto [min_val, max_val] = this->GetRange(); /* We need to take special care of the uint32_t type as we receive from the function * a signed integer. While here also bail out on 64-bit settings as those are not * supported. Unsigned 8 and 16-bit variables are safe since they fit into a signed @@ -522,8 +533,8 @@ void IntSettingDesc::MakeValueValid(int32_t &val) const if (!(this->flags & SF_GUI_0_IS_SPECIAL) || val != 0) { if (!(this->flags & SF_GUI_DROPDOWN)) { /* Clamp value-type setting to its valid range */ - val = Clamp(val, this->min, this->max); - } else if (val < this->min || val > (int32_t)this->max) { + val = Clamp(val, min_val, max_val); + } else if (val < min_val || val > static_cast(max_val)) { /* Reset invalid discrete setting (where different values change gameplay) to its default value */ val = this->GetDefaultValue(); } @@ -532,17 +543,17 @@ void IntSettingDesc::MakeValueValid(int32_t &val) const } case SLE_VAR_U32: { /* Override the minimum value. No value below this->min, except special value 0 */ - uint32_t uval = (uint32_t)val; + uint32_t uval = static_cast(val); if (!(this->flags & SF_GUI_0_IS_SPECIAL) || uval != 0) { if (!(this->flags & SF_GUI_DROPDOWN)) { /* Clamp value-type setting to its valid range */ - uval = ClampU(uval, this->min, this->max); - } else if (uval < (uint)this->min || uval > this->max) { + uval = ClampU(uval, min_val, max_val); + } else if (uval < static_cast(min_val) || uval > max_val) { /* Reset invalid discrete setting to its default value */ - uval = (uint32_t)this->GetDefaultValue(); + uval = static_cast(this->GetDefaultValue()); } } - val = (int32_t)uval; + val = static_cast(uval); return; } case SLE_VAR_I64: @@ -1918,8 +1929,9 @@ void IConsoleGetSetting(const char *name, bool force_newgame) } else if (sd->IsIntSetting()) { std::string value = sd->FormatValue(object); const IntSettingDesc *int_setting = sd->AsIntSetting(); + auto [min_val, max_val] = int_setting->GetRange(); IConsolePrint(CC_INFO, "Current value for '{}' is '{}' (min: {}{}, max: {}).", - sd->GetName(), value, (sd->flags & SF_GUI_0_IS_SPECIAL) ? "(0) " : "", int_setting->min, int_setting->max); + sd->GetName(), value, (sd->flags & SF_GUI_0_IS_SPECIAL) ? "(0) " : "", min_val, max_val); } } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index f5c166d0ac..a37aa1fb1d 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1621,6 +1621,7 @@ void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, bool editable = sd->IsEditable(); SetDParam(0, STR_CONFIG_SETTING_VALUE); + auto [min_val, max_val] = sd->GetRange(); int32_t value = sd->Read(ResolveObject(settings_ptr, sd)); if (sd->IsBoolSetting()) { /* Draw checkbox for boolean-value either on/off */ @@ -1631,7 +1632,7 @@ void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, } else { /* Draw [<][>] boxes for settings of an integer-type */ DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state, - editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : sd->min), editable && (uint32_t)value != sd->max); + editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : min_val), editable && static_cast(value) != max_val); } sd->SetValueDParams(1, value); DrawString(text_left, text_right, y + (SETTING_HEIGHT - GetCharacterHeight(FS_NORMAL)) / 2, sd->GetTitle(), highlight ? TC_WHITE : TC_LIGHT_BLUE); @@ -2607,6 +2608,7 @@ struct GameSettingsWindow : Window { return; } + auto [min_val, max_val] = sd->GetRange(); int32_t value = sd->Read(ResolveObject(settings_ptr, sd)); /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */ @@ -2638,7 +2640,7 @@ struct GameSettingsWindow : Window { this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED); DropDownList list; - for (int i = sd->min; i <= (int)sd->max; i++) { + for (int32_t i = min_val; i <= static_cast(max_val); i++) { sd->SetValueDParams(0, i); list.push_back(MakeDropDownListStringItem(STR_JUST_STRING2, i)); } @@ -2658,7 +2660,7 @@ struct GameSettingsWindow : Window { * 50-steps you should be able to get from min to max, * unless specified otherwise in the 'interval' variable * of the current setting. */ - uint32_t step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval; + uint32_t step = (sd->interval == 0) ? ((max_val - min_val) / 50) : sd->interval; if (step == 0) step = 1; /* don't allow too fast scrolling */ @@ -2670,16 +2672,16 @@ struct GameSettingsWindow : Window { /* Increase or decrease the value and clamp it to extremes */ if (x >= SETTING_BUTTON_WIDTH / 2) { value += step; - if (sd->min < 0) { - assert((int32_t)sd->max >= 0); - if (value > (int32_t)sd->max) value = (int32_t)sd->max; + if (min_val < 0) { + assert(static_cast(max_val) >= 0); + if (value > static_cast(max_val)) value = static_cast(max_val); } else { - if ((uint32_t)value > sd->max) value = (int32_t)sd->max; + if (static_cast(value) > max_val) value = static_cast(max_val); } - if (value < sd->min) value = sd->min; // skip between "disabled" and minimum + if (value < min_val) value = min_val; // skip between "disabled" and minimum } else { value -= step; - if (value < sd->min) value = (sd->flags & SF_GUI_0_IS_SPECIAL) ? 0 : sd->min; + if (value < min_val) value = (sd->flags & SF_GUI_0_IS_SPECIAL) ? 0 : min_val; } /* Set up scroller timeout for numeric values */ @@ -2706,7 +2708,7 @@ struct GameSettingsWindow : Window { if (sd->flags & SF_GUI_CURRENCY) value64 *= GetCurrency().rate; CharSetFilter charset_filter = CS_NUMERAL; //default, only numeric input allowed - if (sd->min < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input + if (min_val < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input this->valuewindow_entry = pe; SetDParam(0, value64); diff --git a/src/settings_internal.h b/src/settings_internal.h index bad51456dd..73801837db 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -151,6 +151,7 @@ struct IntSettingDesc : SettingDesc { typedef StringID GetHelpCallback(const IntSettingDesc &sd); typedef void SetValueDParamsCallback(const IntSettingDesc &sd, uint first_param, int32_t value); typedef int32_t GetDefaultValueCallback(const IntSettingDesc &sd); + typedef std::tuple GetRangeCallback(const IntSettingDesc &sd); /** * A check to be performed before the setting gets changed. The passed integer may be @@ -181,12 +182,12 @@ struct IntSettingDesc : SettingDesc { Tmin min, Tmax max, Tinterval interval, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback, GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, SetValueDParamsCallback set_value_dparams_cb, - GetDefaultValueCallback get_def_cb) : + GetDefaultValueCallback get_def_cb, GetRangeCallback get_range_cb) : SettingDesc(save, flags, startup), str(str), str_help(str_help), str_val(str_val), cat(cat), pre_check(pre_check), post_callback(post_callback), get_title_cb(get_title_cb), get_help_cb(get_help_cb), set_value_dparams_cb(set_value_dparams_cb), - get_def_cb(get_def_cb) { + get_def_cb(get_def_cb), get_range_cb(get_range_cb) { if constexpr (std::is_base_of_v) { this->def = def.base(); } else { @@ -226,11 +227,13 @@ struct IntSettingDesc : SettingDesc { GetHelpCallback *get_help_cb; SetValueDParamsCallback *set_value_dparams_cb; GetDefaultValueCallback *get_def_cb; ///< Callback to set the correct default value + GetRangeCallback *get_range_cb; StringID GetTitle() const; StringID GetHelp() const; void SetValueDParams(uint first_param, int32_t value) const; int32_t GetDefaultValue() const; + std::tuple GetRange() const; /** * Check whether this setting is a boolean type setting. @@ -263,7 +266,7 @@ struct BoolSettingDesc : IntSettingDesc { GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, SetValueDParamsCallback set_value_dparams_cb, GetDefaultValueCallback get_def_cb) : IntSettingDesc(save, flags, startup, def ? 1 : 0, 0, 1, 0, str, str_help, str_val, cat, - pre_check, post_callback, get_title_cb, get_help_cb, set_value_dparams_cb, get_def_cb) {} + pre_check, post_callback, get_title_cb, get_help_cb, set_value_dparams_cb, get_def_cb, nullptr) {} static std::optional ParseSingleValue(const char *str); @@ -282,7 +285,7 @@ struct OneOfManySettingDesc : IntSettingDesc { GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, SetValueDParamsCallback set_value_dparams_cb, GetDefaultValueCallback get_def_cb, std::initializer_list many, OnConvert *many_cnvt) : IntSettingDesc(save, flags, startup, def, 0, max, 0, str, str_help, str_val, cat, - pre_check, post_callback, get_title_cb, get_help_cb, set_value_dparams_cb, get_def_cb), many_cnvt(many_cnvt) + pre_check, post_callback, get_title_cb, get_help_cb, set_value_dparams_cb, get_def_cb, nullptr), many_cnvt(many_cnvt) { for (auto one : many) this->many.push_back(one); } diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble index 464ccfe853..a9006f3078 100644 --- a/src/table/settings.h.preamble +++ b/src/table/settings.h.preamble @@ -58,8 +58,8 @@ static StringID SettingHelpWallclock(const IntSettingDesc &sd); /* Macros for various objects to go in the configuration file. * This section is for global variables */ -#define SDTG_VAR(name, type, flags, var, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, from, to, cat, extra, startup)\ - NSD(Int, SLEG_GENERAL(name, SL_VAR, var, type, 1, from, to, extra), flags, startup, def, min, max, interval, str, strhelp, strval, cat, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook) +#define SDTG_VAR(name, type, flags, var, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, get_range_hook, from, to, cat, extra, startup)\ + NSD(Int, SLEG_GENERAL(name, SL_VAR, var, type, 1, from, to, extra), flags, startup, def, min, max, interval, str, strhelp, strval, cat, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, get_range_hook) #define SDTG_BOOL(name, flags, var, def, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, from, to, cat, extra, startup)\ NSD(Bool, SLEG_GENERAL(name, SL_VAR, var, SLE_BOOL, 1, from, to, extra), flags, startup, def, str, strhelp, strval, cat, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook) @@ -78,8 +78,8 @@ static StringID SettingHelpWallclock(const IntSettingDesc &sd); /* Macros for various objects to go in the configuration file. * This section is for structures where their various members are saved */ -#define SDT_VAR(base, var, type, flags, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, from, to, cat, extra, startup)\ - NSD(Int, SLE_GENERAL(SL_VAR, base, var, type, 1, from, to, extra), flags, startup, def, min, max, interval, str, strhelp, strval, cat, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook) +#define SDT_VAR(base, var, type, flags, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, get_range_hook, from, to, cat, extra, startup)\ + NSD(Int, SLE_GENERAL(SL_VAR, base, var, type, 1, from, to, extra), flags, startup, def, min, max, interval, str, strhelp, strval, cat, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, get_range_hook) #define SDT_VAR_NAME(base, var, type, flags, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, from, to, cat, extra, startup, name)\ NSD(Int, SLE_GENERAL_NAME(SL_VAR, name, base, var, type, 1, from, to, extra), flags, startup, def, min, max, interval, str, strhelp, strval, cat, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook) @@ -100,8 +100,8 @@ static StringID SettingHelpWallclock(const IntSettingDesc &sd); NSD(ManyOfMany, SLE_GENERAL(SL_VAR, base, var, type, 1, from, to, extra), flags, startup, def, str, strhelp, strval, cat, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, full, nullptr) -#define SDTC_VAR(var, type, flags, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, from, to, cat, extra, startup)\ - SDTG_VAR(#var, type, flags, _settings_client.var, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, from, to, cat, extra, startup) +#define SDTC_VAR(var, type, flags, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, get_range_hook, from, to, cat, extra, startup)\ + SDTG_VAR(#var, type, flags, _settings_client.var, def, min, max, interval, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, get_range_hook, from, to, cat, extra, startup) #define SDTC_BOOL(var, flags, def, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, from, to, cat, extra, startup)\ SDTG_BOOL(#var, flags, _settings_client.var, def, str, strhelp, strval, pre_check, post_callback, get_title_hook, get_help_hook, set_value_dparams_hook, get_def_hook, from, to, cat, extra, startup) diff --git a/src/table/settings/company_settings.ini b/src/table/settings/company_settings.ini index 6e2b547922..2f84637cba 100644 --- a/src/table/settings/company_settings.ini +++ b/src/table/settings/company_settings.ini @@ -20,7 +20,7 @@ static const SettingVariant _company_settings_table[] = { }; [templates] SDT_BOOL = SDT_BOOL(CompanySettings, $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR(CompanySettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR(CompanySettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for CompanySettings.$var exceeds storage size"); @@ -37,6 +37,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/currency_settings.ini b/src/table/settings/currency_settings.ini index 2bc3c2328a..4a749c820a 100644 --- a/src/table/settings/currency_settings.ini +++ b/src/table/settings/currency_settings.ini @@ -11,7 +11,7 @@ static const SettingVariant _currency_settings_table[] = { [post-amble] }; [templates] -SDT_VAR = SDT_VAR (CurrencySpec, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR (CurrencySpec, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), SDT_SSTR = SDT_SSTR(CurrencySpec, $var, $type, $flags, $def, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), [validation] @@ -29,6 +29,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/difficulty_settings.ini b/src/table/settings/difficulty_settings.ini index 2b99c563f5..510d552f39 100644 --- a/src/table/settings/difficulty_settings.ini +++ b/src/table/settings/difficulty_settings.ini @@ -20,9 +20,9 @@ static const SettingVariant _difficulty_settings_table[] = { [post-amble] }; [templates] -SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), SDT_BOOL = SDT_BOOL(GameSettings, $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR (GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR (GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -40,6 +40,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/economy_settings.ini b/src/table/settings/economy_settings.ini index 7024082811..53d202703d 100644 --- a/src/table/settings/economy_settings.ini +++ b/src/table/settings/economy_settings.ini @@ -17,7 +17,7 @@ static const SettingVariant _economy_settings_table[] = { }; [templates] SDT_BOOL = SDT_BOOL(GameSettings, $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR (GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR (GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for GameSettings.$var exceeds storage size"); @@ -34,6 +34,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/game_settings.ini b/src/table/settings/game_settings.ini index c29bf636ab..88646ca815 100644 --- a/src/table/settings/game_settings.ini +++ b/src/table/settings/game_settings.ini @@ -27,11 +27,11 @@ static const SettingVariant _game_settings_table[] = { }; [templates] SDTG_BOOL = SDTG_BOOL($name, $flags, $var, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), SDTC_BOOL = SDTC_BOOL( $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDT_BOOL = SDT_BOOL(GameSettings, $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDT_OMANY = SDT_OMANY(GameSettings, $var, $type, $flags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $load, $cat, $extra, $startup), -SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -50,6 +50,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index 78dadf1c44..edac87e2b9 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -27,7 +27,7 @@ static const SettingVariant _gui_settings_table[] = { [templates] SDTC_BOOL = SDTC_BOOL( $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDTC_VAR = SDTC_VAR( $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDTC_VAR = SDTC_VAR( $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDTC_OMANY = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -45,6 +45,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/linkgraph_settings.ini b/src/table/settings/linkgraph_settings.ini index 0d19e7dba6..a7234c1e61 100644 --- a/src/table/settings/linkgraph_settings.ini +++ b/src/table/settings/linkgraph_settings.ini @@ -12,7 +12,7 @@ static const SettingVariant _linkgraph_settings_table[] = { [post-amble] }; [templates] -SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for GameSettings.$var exceeds storage size"); @@ -29,6 +29,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/misc_settings.ini b/src/table/settings/misc_settings.ini index 0da92b33bd..45051908e0 100644 --- a/src/table/settings/misc_settings.ini +++ b/src/table/settings/misc_settings.ini @@ -29,7 +29,7 @@ SDTG_MMANY = SDTG_MMANY($name, $type, $flags, $var, $def, SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $var, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDTG_SSTR = SDTG_SSTR($name, $type, $flags, $var, $def, 0, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), SDTG_BOOL = SDTG_BOOL($name, $flags, $var, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -47,6 +47,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/multimedia_settings.ini b/src/table/settings/multimedia_settings.ini index 8d766a62d6..98e0cdcf1e 100644 --- a/src/table/settings/multimedia_settings.ini +++ b/src/table/settings/multimedia_settings.ini @@ -14,7 +14,7 @@ static const SettingVariant _multimedia_settings_table[] = { [templates] SDTC_BOOL = SDTC_BOOL( $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDTC_LIST = SDTC_LIST( $var, $type, $flags, $def, $from, $to, $cat, $extra, $startup), -SDTC_VAR = SDTC_VAR( $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDTC_VAR = SDTC_VAR( $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDTC_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -31,6 +31,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/network_settings.ini b/src/table/settings/network_settings.ini index 8514492843..54cac2b5a3 100644 --- a/src/table/settings/network_settings.ini +++ b/src/table/settings/network_settings.ini @@ -18,7 +18,7 @@ static const SettingVariant _network_settings_table[] = { [templates] SDTC_BOOL = SDTC_BOOL( $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDTC_VAR = SDTC_VAR( $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDTC_VAR = SDTC_VAR( $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDTC_OMANY = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -36,6 +36,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/old_gameopt_settings.ini b/src/table/settings/old_gameopt_settings.ini index 4daf62a57c..1786302d6e 100644 --- a/src/table/settings/old_gameopt_settings.ini +++ b/src/table/settings/old_gameopt_settings.ini @@ -31,12 +31,12 @@ static const SettingVariant _old_gameopt_settings_table[] = { }; [templates] SDTG_LIST = SDTG_LIST($name, $type, $flags, $var, $def, $length, $from, $to, $cat, $extra, $startup), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), SDT_NULL = SDT_NULL( $length, $from, $to), SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $var, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDT_OMANY = SDT_OMANY(GameSettings, $var, $type, $flags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $load, $cat, $extra, $startup), -SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -57,6 +57,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/pathfinding_settings.ini b/src/table/settings/pathfinding_settings.ini index 8d7521b661..ef7f91185d 100644 --- a/src/table/settings/pathfinding_settings.ini +++ b/src/table/settings/pathfinding_settings.ini @@ -13,7 +13,7 @@ static const SettingVariant _pathfinding_settings_table[] = { }; [templates] SDT_BOOL = SDT_BOOL(GameSettings, $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for GameSettings.$var exceeds storage size"); @@ -30,6 +30,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/script_settings.ini b/src/table/settings/script_settings.ini index 9affe3e61b..bf25847b9c 100644 --- a/src/table/settings/script_settings.ini +++ b/src/table/settings/script_settings.ini @@ -15,7 +15,7 @@ static const SettingVariant _script_settings_table[] = { [templates] SDT_BOOL = SDT_BOOL(GameSettings, $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDT_OMANY = SDT_OMANY(GameSettings, $var, $type, $flags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $load, $cat, $extra, $startup), -SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_OMANY = static_assert($max <= MAX_$type, "Maximum value for GameSettings.$var exceeds storage size"); @@ -33,6 +33,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/win32_settings.ini b/src/table/settings/win32_settings.ini index d54f10e109..fbf949fe0d 100644 --- a/src/table/settings/win32_settings.ini +++ b/src/table/settings/win32_settings.ini @@ -18,7 +18,7 @@ static const SettingVariant _win32_settings_table[] = { #endif /* _WIN32 */ [templates] SDTG_BOOL = SDTG_BOOL($name, $flags, $var, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDTG_VAR = SDTG_VAR($name, $type, $flags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -35,6 +35,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/window_settings.ini b/src/table/settings/window_settings.ini index 4984abe200..6da3c6ab17 100644 --- a/src/table/settings/window_settings.ini +++ b/src/table/settings/window_settings.ini @@ -14,7 +14,7 @@ static const SettingVariant _window_settings_table[] = { }; [templates] SDT_BOOL = SDT_BOOL(WindowDesc, $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR(WindowDesc, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR(WindowDesc, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for WindowDesc.$var exceeds storage size"); @@ -31,6 +31,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION diff --git a/src/table/settings/world_settings.ini b/src/table/settings/world_settings.ini index 6b5d1466e0..ab30a3e500 100644 --- a/src/table/settings/world_settings.ini +++ b/src/table/settings/world_settings.ini @@ -20,7 +20,7 @@ static const SettingVariant _world_settings_table[] = { [templates] SDT_BOOL = SDT_BOOL(GameSettings, $var, $flags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), SDT_OMANY = SDT_OMANY(GameSettings, $var, $type, $flags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $load, $cat, $extra, $startup), -SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $str_cb, $help_cb, $val_cb, $def_cb, $range_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_OMANY = static_assert($max <= MAX_$type, "Maximum value for GameSettings.$var exceeds storage size"); @@ -38,6 +38,7 @@ str_cb = nullptr help_cb = nullptr val_cb = nullptr def_cb = nullptr +range_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION