MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetValueParams

Method GetValueParams

src/settings.cpp:445–461  ·  view source on GitHub ↗

* Get parameters for drawing the value of the setting. * @param value Setting value to set params for. */

Source from the content-addressed store, hash-verified

443 * @param value Setting value to set params for.
444 */
445std::pair<StringParameter, StringParameter> IntSettingDesc::GetValueParams(int32_t value) const
446{
447 if (this->get_value_params_cb != nullptr) {
448 return this->get_value_params_cb(*this, value);
449 }
450
451 if (this->IsBoolSetting()) {
452 return {value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF, {}};
453 }
454
455 if (this->flags.Test(SettingFlag::GuiDropdown)) {
456 auto [min_val, _] = this->GetRange();
457 return {this->str_val - min_val + value, value};
458 }
459
460 return {this->str_val + ((value == 0 && this->flags.Test(SettingFlag::GuiZeroIsSpecial)) ? 1 : 0), value};
461}
462
463/**
464 * Get the default value of the setting.

Callers 5

DrawSettingMethod · 0.45
DrawSettingMethod · 0.45
DrawWidgetMethod · 0.45
OptionsPanelClickMethod · 0.45

Calls 3

IsBoolSettingMethod · 0.95
GetRangeMethod · 0.95
TestMethod · 0.80

Tested by

no test coverage detected