Fix #12147: reset all saved settings to their default before loading a game (#12210)

This commit is contained in:
Patric Stout
2024-03-02 16:05:43 +01:00
committed by GitHub
parent aff09306de
commit 8f22066b9a
3 changed files with 39 additions and 4 deletions

View File

@@ -768,6 +768,11 @@ bool IntSettingDesc::IsDefaultValue(void *object) const
return this->def == object_value;
}
void IntSettingDesc::ResetToDefault(void *object) const
{
this->Write(object, this->def);
}
std::string StringSettingDesc::FormatValue(const void *object) const
{
const std::string &str = this->Read(object);
@@ -800,6 +805,11 @@ bool StringSettingDesc::IsDefaultValue(void *object) const
return this->def == str;
}
void StringSettingDesc::ResetToDefault(void *object) const
{
this->Write(object, this->def);
}
bool ListSettingDesc::IsSameValue(const IniItem *, void *) const
{
/* Checking for equality is way more expensive than just writing the value. */
@@ -812,6 +822,12 @@ bool ListSettingDesc::IsDefaultValue(void *) const
return false;
}
void ListSettingDesc::ResetToDefault(void *) const
{
/* Resetting a list to default is not supported. */
NOT_REACHED();
}
/**
* Loads all items from a 'grpname' section into a list
* The list parameter can be a nullptr pointer, in this case nothing will be