Codechange: Move settings string formatting into IntSettingDesc members.
This commit is contained in:
@@ -447,6 +447,47 @@ size_t BoolSettingDesc::ParseValue(const char *str) const
|
||||
return this->def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the setting.
|
||||
* The string should include a {STRING2} to show the current value.
|
||||
* @return The title string.
|
||||
*/
|
||||
StringID IntSettingDesc::GetTitle() const
|
||||
{
|
||||
return this->str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the help text of the setting.
|
||||
* @return The requested help text.
|
||||
*/
|
||||
StringID IntSettingDesc::GetHelp() const
|
||||
{
|
||||
return this->str_help;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the DParams for drawing the value of the setting.
|
||||
* @param first_param First DParam to use
|
||||
* @param value Setting value to set params for.
|
||||
*/
|
||||
void IntSettingDesc::SetValueDParams(uint first_param, int32_t value) const
|
||||
{
|
||||
if (this->IsBoolSetting()) {
|
||||
SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
|
||||
} 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));
|
||||
}
|
||||
SetDParam(first_param++, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the value valid and then write it to the setting.
|
||||
* See #MakeValidValid and #Write for more details.
|
||||
|
||||
Reference in New Issue
Block a user