* Handle changing a value. This performs validation of the input value and * calls the appropriate callbacks, and saves it when the value is changed. * @param object The object the setting is in. * @param newval The new value for the setting. */
| 1609 | * @param newval The new value for the setting. |
| 1610 | */ |
| 1611 | void IntSettingDesc::ChangeValue(const void *object, int32_t newval) const |
| 1612 | { |
| 1613 | int32_t oldval = this->Read(object); |
| 1614 | this->MakeValueValid(newval); |
| 1615 | if (this->pre_check != nullptr && !this->pre_check(newval)) return; |
| 1616 | if (oldval == newval) return; |
| 1617 | |
| 1618 | this->Write(object, newval); |
| 1619 | if (this->post_callback != nullptr) this->post_callback(newval); |
| 1620 | |
| 1621 | if (this->flags.Test(SettingFlag::NoNetwork) || this->flags.Test(SettingFlag::Sandbox)) { |
| 1622 | _gamelog.StartAction(GLAT_SETTING); |
| 1623 | _gamelog.Setting(this->GetName(), oldval, newval); |
| 1624 | _gamelog.StopAction(); |
| 1625 | } |
| 1626 | |
| 1627 | SetWindowClassesDirty(WC_GAME_OPTIONS); |
| 1628 | if (this->flags.Test(SettingFlag::Sandbox)) SetWindowClassesDirty(WC_CHEATS); |
| 1629 | |
| 1630 | if (_save_config) SaveToConfig(); |
| 1631 | } |
| 1632 | |
| 1633 | /** |
| 1634 | * Given a name of setting, return a setting description from the table. |
no test coverage detected