mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
Change: Show correct default value and unit for vehicle service interval setting
This commit is contained in:
parent
fd80a1ec66
commit
339b0ea0ff
@ -1832,7 +1832,11 @@ STR_CONFIG_SETTING_SERVINT_AIRCRAFT :Default service
|
||||
STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT :Set the default service interval for new aircraft, if no explicit service interval is set for the vehicle
|
||||
STR_CONFIG_SETTING_SERVINT_SHIPS :Default service interval for ships: {STRING2}
|
||||
STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT :Set the default service interval for new ships, if no explicit service interval is set for the vehicle
|
||||
STR_CONFIG_SETTING_SERVINT_VALUE :{COMMA}{NBSP}Day{P 0 "" s}/Minute{P 0 "" s}/%
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_SERVINT_VALUE_DAYS :{COMMA}{NBSP}Day{P 0 "" s}
|
||||
STR_CONFIG_SETTING_SERVINT_VALUE_MINUTES :{COMMA}{NBSP}Minute{P 0 "" s}
|
||||
STR_CONFIG_SETTING_SERVINT_VALUE_PERCENTAGE :{COMMA}{NBSP}%
|
||||
|
||||
###setting-zero-is-special
|
||||
STR_CONFIG_SETTING_SERVINT_DISABLED :Disabled
|
||||
|
||||
|
@ -2498,7 +2498,9 @@ struct GameSettingsWindow : Window {
|
||||
DrawString(tr, STR_CONFIG_SETTING_TYPE);
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
sd->SetValueDParams(0, sd->def);
|
||||
int32_t def_val = sd->def;
|
||||
if (sd->get_def_cb != nullptr) sd->get_def_cb(def_val);
|
||||
sd->SetValueDParams(0, def_val);
|
||||
DrawString(tr, STR_CONFIG_SETTING_DEFAULT_VALUE);
|
||||
tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
|
||||
|
||||
|
@ -116,6 +116,28 @@ static void SettingsValueAbsolute(const IntSettingDesc &sd, uint first_param, in
|
||||
SetDParam(first_param + 1, 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)
|
||||
{
|
||||
VehicleDefaultSettings *vds;
|
||||
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
|
||||
vds = &_settings_client.company.vehicle;
|
||||
} else {
|
||||
vds = &Company::Get(_current_company)->settings.vehicle;
|
||||
}
|
||||
|
||||
if (value == 0) {
|
||||
SetDParam(first_param, sd.str_val + 3);
|
||||
} else if (vds->servint_ispercent) {
|
||||
SetDParam(first_param, sd.str_val + 2);
|
||||
} else if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
|
||||
SetDParam(first_param, sd.str_val + 1);
|
||||
} else {
|
||||
SetDParam(first_param, sd.str_val);
|
||||
}
|
||||
SetDParam(first_param + 1, value);
|
||||
}
|
||||
|
||||
/** Reposition the main toolbar as the setting changed. */
|
||||
static void v_PositionMainToolbar(int32_t)
|
||||
{
|
||||
|
@ -12,6 +12,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 void ServiceIntervalSettingsValueText(const IntSettingDesc &sd, uint first_param, int32_t value);
|
||||
static void GetDefaultServiceInterval(VehicleType type, int32_t &new_value);
|
||||
|
||||
static const SettingVariant _company_settings_table[] = {
|
||||
@ -96,10 +97,11 @@ max = MAX_SERVINT_DAYS
|
||||
interval = 1
|
||||
str = STR_CONFIG_SETTING_SERVINT_TRAINS
|
||||
strhelp = STR_CONFIG_SETTING_SERVINT_TRAINS_HELPTEXT
|
||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE_DAYS
|
||||
pre_cb = [](auto &new_value) { return CanUpdateServiceInterval(VEH_TRAIN, new_value); }
|
||||
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_TRAIN, new_value); }
|
||||
def_cb = [](auto &new_value) { GetDefaultServiceInterval(VEH_TRAIN, new_value); }
|
||||
val_cb = ServiceIntervalSettingsValueText
|
||||
|
||||
[SDT_VAR]
|
||||
var = vehicle.servint_roadveh
|
||||
@ -111,10 +113,11 @@ max = MAX_SERVINT_DAYS
|
||||
interval = 1
|
||||
str = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES
|
||||
strhelp = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES_HELPTEXT
|
||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE_DAYS
|
||||
pre_cb = [](auto &new_value) { return CanUpdateServiceInterval(VEH_ROAD, new_value); }
|
||||
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_ROAD, new_value); }
|
||||
def_cb = [](auto &new_value) { GetDefaultServiceInterval(VEH_ROAD, new_value); }
|
||||
val_cb = ServiceIntervalSettingsValueText
|
||||
|
||||
[SDT_VAR]
|
||||
var = vehicle.servint_ships
|
||||
@ -126,10 +129,11 @@ max = MAX_SERVINT_DAYS
|
||||
interval = 1
|
||||
str = STR_CONFIG_SETTING_SERVINT_SHIPS
|
||||
strhelp = STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT
|
||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE_DAYS
|
||||
pre_cb = [](auto &new_value) { return CanUpdateServiceInterval(VEH_SHIP, new_value); }
|
||||
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_SHIP, new_value); }
|
||||
def_cb = [](auto &new_value) { GetDefaultServiceInterval(VEH_SHIP, new_value); }
|
||||
val_cb = ServiceIntervalSettingsValueText
|
||||
|
||||
[SDT_VAR]
|
||||
var = vehicle.servint_aircraft
|
||||
@ -141,7 +145,8 @@ max = MAX_SERVINT_DAYS
|
||||
interval = 1
|
||||
str = STR_CONFIG_SETTING_SERVINT_AIRCRAFT
|
||||
strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT
|
||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE
|
||||
strval = STR_CONFIG_SETTING_SERVINT_VALUE_DAYS
|
||||
pre_cb = [](auto &new_value) { return CanUpdateServiceInterval(VEH_AIRCRAFT, new_value); }
|
||||
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_AIRCRAFT, new_value); }
|
||||
def_cb = [](auto &new_value) { GetDefaultServiceInterval(VEH_AIRCRAFT, new_value); }
|
||||
val_cb = ServiceIntervalSettingsValueText
|
||||
|
Loading…
Reference in New Issue
Block a user