diff --git a/src/settings.cpp b/src/settings.cpp index 564a5b4eb3..cc3c311146 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -662,6 +662,10 @@ void StringSettingDesc::ParseValue(const IniItem *item, void *object) const { std::string str = (item == nullptr) ? this->def : item->value.value_or(""); 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); } diff --git a/src/settings_internal.h b/src/settings_internal.h index 117affd840..ed20bf1e4c 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -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_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_RUN_CALLBACKS_ON_PARSE = 1 << 17, ///< run callbacks when parsing from config file }; DECLARE_ENUM_AS_BIT_SET(SettingFlag)