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] [post-amble]
}; };
[templates] [templates]
SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $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($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $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] [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] [defaults]
flags = 0 flags = 0
@ -38,7 +38,6 @@ startup = false
[SDT_BOOL] [SDT_BOOL]
base = CompanySettings
var = engine_renew var = engine_renew
def = true def = true
str = STR_CONFIG_SETTING_AUTORENEW_VEHICLE str = STR_CONFIG_SETTING_AUTORENEW_VEHICLE
@ -46,7 +45,6 @@ strhelp = STR_CONFIG_SETTING_AUTORENEW_VEHICLE_HELPTEXT
cat = SC_BASIC cat = SC_BASIC
[SDT_VAR] [SDT_VAR]
base = CompanySettings
var = engine_renew_months var = engine_renew_months
type = SLE_INT16 type = SLE_INT16
guiflags = SGF_PER_COMPANY | SGF_DISPLAY_ABS 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 strval = STR_CONFIG_SETTING_AUTORENEW_MONTHS_VALUE_BEFORE
[SDT_VAR] [SDT_VAR]
base = CompanySettings
var = engine_renew_money var = engine_renew_money
type = SLE_UINT type = SLE_UINT
guiflags = SGF_PER_COMPANY | SGF_CURRENCY guiflags = SGF_PER_COMPANY | SGF_CURRENCY
@ -70,12 +67,10 @@ strhelp = STR_CONFIG_SETTING_AUTORENEW_MONEY_HELPTEXT
strval = STR_JUST_CURRENCY_LONG strval = STR_JUST_CURRENCY_LONG
[SDT_BOOL] [SDT_BOOL]
base = CompanySettings
var = renew_keep_length var = renew_keep_length
def = false def = false
[SDT_BOOL] [SDT_BOOL]
base = CompanySettings
var = vehicle.servint_ispercent var = vehicle.servint_ispercent
def = false def = false
str = STR_CONFIG_SETTING_SERVINT_ISPERCENT str = STR_CONFIG_SETTING_SERVINT_ISPERCENT
@ -83,7 +78,6 @@ strhelp = STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT
post_cb = UpdateServiceInterval post_cb = UpdateServiceInterval
[SDT_VAR] [SDT_VAR]
base = CompanySettings
var = vehicle.servint_trains var = vehicle.servint_trains
type = SLE_UINT16 type = SLE_UINT16
guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED 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); } post_cb = [](auto new_value) { UpdateServiceInterval(VEH_TRAIN, new_value); }
[SDT_VAR] [SDT_VAR]
base = CompanySettings
var = vehicle.servint_roadveh var = vehicle.servint_roadveh
type = SLE_UINT16 type = SLE_UINT16
guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED 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); } post_cb = [](auto new_value) { UpdateServiceInterval(VEH_ROAD, new_value); }
[SDT_VAR] [SDT_VAR]
base = CompanySettings
var = vehicle.servint_ships var = vehicle.servint_ships
type = SLE_UINT16 type = SLE_UINT16
guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED 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); } post_cb = [](auto new_value) { UpdateServiceInterval(VEH_SHIP, new_value); }
[SDT_VAR] [SDT_VAR]
base = CompanySettings
var = vehicle.servint_aircraft var = vehicle.servint_aircraft
type = SLE_UINT16 type = SLE_UINT16
guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED guiflags = SGF_PER_COMPANY | SGF_0ISDISABLED

@ -9,11 +9,11 @@ static const SettingTable _currency_settings{
[post-amble] [post-amble]
}; };
[templates] [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_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($base, $var, $type, $flags, $guiflags, $def, $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] [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] [defaults]
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
@ -34,7 +34,6 @@ startup = false
[SDT_VAR] [SDT_VAR]
base = CurrencySpec
var = rate var = rate
type = SLE_UINT16 type = SLE_UINT16
def = 1 def = 1
@ -42,14 +41,12 @@ min = 0
max = UINT16_MAX max = UINT16_MAX
[SDT_SSTR] [SDT_SSTR]
base = CurrencySpec
var = separator var = separator
type = SLE_STRQ type = SLE_STRQ
def = ""."" def = "".""
cat = SC_BASIC cat = SC_BASIC
[SDT_VAR] [SDT_VAR]
base = CurrencySpec
var = to_euro var = to_euro
type = SLE_INT32 type = SLE_INT32
def = 0 def = 0
@ -57,13 +54,11 @@ min = MIN_YEAR
max = MAX_YEAR max = MAX_YEAR
[SDT_SSTR] [SDT_SSTR]
base = CurrencySpec
var = prefix var = prefix
type = SLE_STRQ type = SLE_STRQ
def = nullptr def = nullptr
[SDT_SSTR] [SDT_SSTR]
base = CurrencySpec
var = suffix var = suffix
type = SLE_STRQ type = SLE_STRQ
def = "" credits"" def = "" credits""

@ -41,15 +41,15 @@ SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $mi
SDT_NULL = SDT_NULL( $length, $from, $to), 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), 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), 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_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($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $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] [validation]
SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); 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"); 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"); 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_OMANY = static_assert($max <= MAX_$type, "Maximum value for GameSettings.$var exceeds storage size");
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 GameSettings.$var exceeds storage size");
[defaults] [defaults]
flags = 0 flags = 0
@ -104,7 +104,6 @@ max = SP_CUSTOM
cat = SC_BASIC cat = SC_BASIC
[SDT_OMANY] [SDT_OMANY]
base = GameSettings
var = locale.currency var = locale.currency
type = SLE_UINT8 type = SLE_UINT8
flags = SLF_NO_NETWORK_SYNC 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 # 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. # these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI.
[SDT_OMANY] [SDT_OMANY]
base = GameSettings
var = game_creation.town_name var = game_creation.town_name
type = SLE_UINT8 type = SLE_UINT8
def = 0 def = 0
@ -135,7 +133,6 @@ full = _town_names
cat = SC_BASIC cat = SC_BASIC
[SDT_OMANY] [SDT_OMANY]
base = GameSettings
var = game_creation.landscape var = game_creation.landscape
type = SLE_UINT8 type = SLE_UINT8
def = 0 def = 0
@ -145,7 +142,6 @@ load = ConvertLandscape
cat = SC_BASIC cat = SC_BASIC
[SDT_VAR] [SDT_VAR]
base = GameSettings
var = game_creation.snow_line_height var = game_creation.snow_line_height
type = SLE_UINT8 type = SLE_UINT8
def = DEF_SNOWLINE_HEIGHT * TILE_HEIGHT def = DEF_SNOWLINE_HEIGHT * TILE_HEIGHT
@ -174,7 +170,6 @@ full = _autosave_interval
cat = SC_BASIC cat = SC_BASIC
[SDT_OMANY] [SDT_OMANY]
base = GameSettings
var = vehicle.road_side var = vehicle.road_side
type = SLE_UINT8 type = SLE_UINT8
def = 1 def = 1

File diff suppressed because it is too large Load Diff

@ -10,14 +10,13 @@ static const SettingTable _window_settings{
[post-amble] [post-amble]
}; };
[templates] [templates]
SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $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($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $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] [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] [defaults]
base = WindowDesc
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
guiflags = SGF_NONE guiflags = SGF_NONE
interval = 0 interval = 0

Loading…
Cancel
Save