mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
Codechange: Replace SF_GUI_NEGATIVE_IS_SPECIAL with a settings value callback.
This commit is contained in:
parent
28c83089f6
commit
17dfc1a49a
@ -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));
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user