Add setting flag to run string setting change callbacks on config load
This commit is contained in:
@@ -662,6 +662,10 @@ void StringSettingDesc::ParseValue(const IniItem *item, void *object) const
|
|||||||
{
|
{
|
||||||
std::string str = (item == nullptr) ? this->def : item->value.value_or("");
|
std::string str = (item == nullptr) ? this->def : item->value.value_or("");
|
||||||
this->MakeValueValid(str);
|
this->MakeValueValid(str);
|
||||||
|
if (this->flags & SF_RUN_CALLBACKS_ON_PARSE) {
|
||||||
|
if (this->pre_check != nullptr && !this->pre_check(str)) str = this->def;
|
||||||
|
if (this->post_callback != nullptr) this->post_callback(str);
|
||||||
|
}
|
||||||
this->Write(object, str);
|
this->Write(object, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ enum SettingFlag : uint32 {
|
|||||||
SF_ENUM = 1 << 14, ///< the setting can take one of the values given by an array of struct SettingDescEnumEntry
|
SF_ENUM = 1 << 14, ///< the setting can take one of the values given by an array of struct SettingDescEnumEntry
|
||||||
SF_NO_NEWGAME = 1 << 15, ///< the setting does not apply and is not shown in a new game context
|
SF_NO_NEWGAME = 1 << 15, ///< the setting does not apply and is not shown in a new game context
|
||||||
SF_DEC1SCALE = 1 << 16, ///< also display a float representation of the scale of a decimal1 scale parameter
|
SF_DEC1SCALE = 1 << 16, ///< also display a float representation of the scale of a decimal1 scale parameter
|
||||||
|
SF_RUN_CALLBACKS_ON_PARSE = 1 << 17, ///< run callbacks when parsing from config file
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(SettingFlag)
|
DECLARE_ENUM_AS_BIT_SET(SettingFlag)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user