Cleanup: set the base in the setting templates, instead of defining the base for every setting

This has the added benefit of not getting mistaken that multiple bases can be used for the same SettingTable
pull/332/head
rubidium42 3 years ago committed by rubidium42
parent 4144e949ed
commit 4c0e083128

@ -13,11 +13,11 @@ static const SettingTable _company_settings{
[post-amble]
};
[templates]
SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_BOOL = SDT_BOOL(CompanySettings, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_VAR = SDT_VAR(CompanySettings, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
[validation]
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size");
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for CompanySettings.$var exceeds storage size");
[defaults]
flags = 0
@ -38,7 +38,6 @@ startup = false
[SDT_BOOL]
base = CompanySettings
var = engine_renew
def = true
str = STR_CONFIG_SETTING_AUTORENEW_VEHICLE
@ -46,7 +45,6 @@ strhelp = STR_CONFIG_SETTING_AUTORENEW_VEHICLE_HELPTEXT
cat = SC_BASIC
[SDT_VAR]
base = CompanySettings
var = engine_renew_months
type = SLE_INT16
guiflags = SGF_PER_COMPANY | SGF_DISPLAY_ABS
@ -58,7 +56,6 @@ strhelp = STR_CONFIG_SETTING_AUTORENEW_MONTHS_HELPTEXT
strval = STR_CONFIG_SETTING_AUTORENEW_MONTHS_VALUE_BEFORE
[SDT_VAR]
base = CompanySettings
var = engine_renew_money
type = SLE_UINT
guiflags = SGF_PER_COMPANY | SGF_CURRENCY
@ -70,12 +67,10 @@ strhelp = STR_CONFIG_SETTING_AUTORENEW_MONEY_HELPTEXT
strval = STR_JUST_CURRENCY_LONG
[SDT_BOOL]
base = CompanySettings
var = renew_keep_length
def = false
[SDT_BOOL]
base = CompanySettings
var = vehicle.servint_ispercent
def = false
str = STR_CONFIG_SETTING_SERVINT_ISPERCENT
@ -83,7 +78,6 @@ strhelp = STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT
post_cb = UpdateServiceInterval
[SDT_VAR]
base = CompanySettings
var = vehicle.servint_trains
type = SLE_UINT16
guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED
@ -97,7 +91,6 @@ pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_TRAIN, new_v
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_TRAIN, new_value); }
[SDT_VAR]
base = CompanySettings
var = vehicle.servint_roadveh
type = SLE_UINT16
guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED
@ -111,7 +104,6 @@ pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_ROAD, new_va
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_ROAD, new_value); }
[SDT_VAR]
base = CompanySettings
var = vehicle.servint_ships
type = SLE_UINT16
guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED
@ -125,7 +117,6 @@ pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_SHIP, new_va
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_SHIP, new_value); }
[SDT_VAR]
base = CompanySettings
var = vehicle.servint_aircraft
type = SLE_UINT16
guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED

@ -9,11 +9,11 @@ static const SettingTable _currency_settings{
[post-amble]
};
[templates]
SDT_VAR = SDT_VAR ($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_SSTR = SDT_SSTR($base, $var, $type, $flags, $guiflags, $def, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_VAR = SDT_VAR (CurrencySpec, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_SSTR = SDT_SSTR(CurrencySpec, $var, $type, $flags, $guiflags, $def, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
[validation]
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size");
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for CurrencySpec.$var exceeds storage size");
[defaults]
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
@ -34,7 +34,6 @@ startup = false
[SDT_VAR]
base = CurrencySpec
var = rate
type = SLE_UINT16
def = 1
@ -42,14 +41,12 @@ min = 0
max = UINT16_MAX
[SDT_SSTR]
base = CurrencySpec
var = separator
type = SLE_STRQ
def = "".""
cat = SC_BASIC
[SDT_VAR]
base = CurrencySpec
var = to_euro
type = SLE_INT32
def = 0
@ -57,13 +54,11 @@ min = MIN_YEAR
max = MAX_YEAR
[SDT_SSTR]
base = CurrencySpec
var = prefix
type = SLE_STRQ
def = nullptr
[SDT_SSTR]
base = CurrencySpec
var = suffix
type = SLE_STRQ
def = "" credits""

@ -36,20 +36,20 @@ static const SettingTable _gameopt_settings{
[post-amble]
};
[templates]
SDTG_LIST = SDTG_LIST($name, $type, $flags, $guiflags, $var, $def, $length, $from, $to, $cat, $extra, $startup),
SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_NULL = SDT_NULL( $length, $from, $to),
SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $load, $cat, $extra, $startup),
SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDTG_LIST = SDTG_LIST($name, $type, $flags, $guiflags, $var, $def, $length, $from, $to, $cat, $extra, $startup),
SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_NULL = SDT_NULL( $length, $from, $to),
SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_OMANY = SDT_OMANY(GameSettings, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $load, $cat, $extra, $startup),
SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
[validation]
SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size");
SDTG_OMANY = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size");
SDTC_OMANY = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size");
SDT_OMANY = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size");
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size");
SDT_OMANY = static_assert($max <= MAX_$type, "Maximum value for GameSettings.$var exceeds storage size");
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for GameSettings.$var exceeds storage size");
[defaults]
flags = 0
@ -104,7 +104,6 @@ max = SP_CUSTOM
cat = SC_BASIC
[SDT_OMANY]
base = GameSettings
var = locale.currency
type = SLE_UINT8
flags = SLF_NO_NETWORK_SYNC
@ -126,7 +125,6 @@ cat = SC_BASIC
# There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow
# these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI.
[SDT_OMANY]
base = GameSettings
var = game_creation.town_name
type = SLE_UINT8
def = 0
@ -135,7 +133,6 @@ full = _town_names
cat = SC_BASIC
[SDT_OMANY]
base = GameSettings
var = game_creation.landscape
type = SLE_UINT8
def = 0
@ -145,7 +142,6 @@ load = ConvertLandscape
cat = SC_BASIC
[SDT_VAR]
base = GameSettings
var = game_creation.snow_line_height
type = SLE_UINT8
def = DEF_SNOWLINE_HEIGHT * TILE_HEIGHT
@ -174,7 +170,6 @@ full = _autosave_interval
cat = SC_BASIC
[SDT_OMANY]
base = GameSettings
var = vehicle.road_side
type = SLE_UINT8
def = 1

File diff suppressed because it is too large Load Diff

@ -10,14 +10,13 @@ static const SettingTable _window_settings{
[post-amble]
};
[templates]
SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_BOOL = SDT_BOOL(WindowDesc, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
SDT_VAR = SDT_VAR(WindowDesc, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
[validation]
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size");
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for WindowDesc.$var exceeds storage size");
[defaults]
base = WindowDesc
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
guiflags = SGF_NONE
interval = 0

Loading…
Cancel
Save