Codechange: Use local parameters for formatting settings values. (#13487)
This commit is contained in:
@@ -96,7 +96,7 @@ static StringID SettingHelpWallclock(const IntSettingDesc &sd)
|
||||
}
|
||||
|
||||
/** Setting values for velocity unit localisation */
|
||||
static void SettingsValueVelocityUnit(const IntSettingDesc &, uint first_param, int32_t value)
|
||||
static std::pair<StringParameter, StringParameter> SettingsValueVelocityUnit(const IntSettingDesc &, int32_t value)
|
||||
{
|
||||
StringID val;
|
||||
switch (value) {
|
||||
@@ -107,18 +107,17 @@ static void SettingsValueVelocityUnit(const IntSettingDesc &, uint first_param,
|
||||
case 4: val = STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_KNOTS; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
SetDParam(first_param, val);
|
||||
return {val, {}};
|
||||
}
|
||||
|
||||
/** A negative value has another string (the one after "strval"). */
|
||||
static void SettingsValueAbsolute(const IntSettingDesc &sd, uint first_param, int32_t value)
|
||||
static std::pair<StringParameter, StringParameter> SettingsValueAbsolute(const IntSettingDesc &sd, int32_t value)
|
||||
{
|
||||
SetDParam(first_param, sd.str_val + ((value >= 0) ? 1 : 0));
|
||||
SetDParam(first_param + 1, abs(value));
|
||||
return {sd.str_val + ((value >= 0) ? 1 : 0), abs(value)};
|
||||
}
|
||||
|
||||
/** Service Interval Settings Default Value displays the correct units or as a percentage */
|
||||
static void ServiceIntervalSettingsValueText(const IntSettingDesc &sd, uint first_param, int32_t value)
|
||||
static std::pair<StringParameter, StringParameter> ServiceIntervalSettingsValueText(const IntSettingDesc &sd, int32_t value)
|
||||
{
|
||||
VehicleDefaultSettings *vds;
|
||||
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
|
||||
@@ -127,16 +126,17 @@ static void ServiceIntervalSettingsValueText(const IntSettingDesc &sd, uint firs
|
||||
vds = &Company::Get(_current_company)->settings.vehicle;
|
||||
}
|
||||
|
||||
StringID str;
|
||||
if (value == 0) {
|
||||
SetDParam(first_param, sd.str_val + 3);
|
||||
str = sd.str_val + 3;
|
||||
} else if (vds->servint_ispercent) {
|
||||
SetDParam(first_param, sd.str_val + 2);
|
||||
str = sd.str_val + 2;
|
||||
} else if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
|
||||
SetDParam(first_param, sd.str_val + 1);
|
||||
str = sd.str_val + 1;
|
||||
} else {
|
||||
SetDParam(first_param, sd.str_val);
|
||||
str = sd.str_val;
|
||||
}
|
||||
SetDParam(first_param + 1, value);
|
||||
return {str, value};
|
||||
}
|
||||
|
||||
/** Reposition the main toolbar as the setting changed. */
|
||||
|
||||
Reference in New Issue
Block a user