mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 07:27:59 -05:00
fix legacy custom settings not being loaded
This commit is contained in:
parent
2999fb242a
commit
f0b6a7074a
1 changed files with 5 additions and 4 deletions
|
@ -92,7 +92,7 @@ public:
|
|||
matjson::Object savedata;
|
||||
bool restartRequired = false;
|
||||
|
||||
void loadSettingValueFromSave(std::string_view key) {
|
||||
void loadSettingValueFromSave(std::string const& key) {
|
||||
if (this->savedata.contains(key) && this->settings.contains(key)) {
|
||||
auto& sett = this->settings.at(key);
|
||||
if (!sett.v3) return;
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
void saveSettingValueToSave(std::string_view key) {
|
||||
void saveSettingValueToSave(std::string const& key) {
|
||||
if (this->settings.contains(key)) {
|
||||
auto& sett = this->settings.at(key);
|
||||
// Store the value in an intermediary so if `save` fails the existing
|
||||
|
@ -118,11 +118,11 @@ public:
|
|||
this->savedata[key] = value;
|
||||
}
|
||||
else {
|
||||
log::error("Unable to save setting '{}' for mod {}", key, m_impl->modID);
|
||||
log::error("Unable to save setting '{}' for mod {}", key, this->modID);
|
||||
}
|
||||
}
|
||||
catch(matjson::JsonException const& e) {
|
||||
log::error("Unable to save setting '{}' for mod {} (JSON exception): {}", key, m_impl->modID, e.what());
|
||||
log::error("Unable to save setting '{}' for mod {} (JSON exception): {}", key, this->modID, e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +205,7 @@ Result<> ModSettingsManager::registerLegacyCustomSetting(std::string_view key, s
|
|||
if (auto custom = typeinfo_pointer_cast<LegacyCustomSettingV3>(sett.v3)) {
|
||||
if (!custom->getValue()) {
|
||||
custom->setValue(std::move(ptr));
|
||||
m_impl->loadSettingValueFromSave(id);
|
||||
}
|
||||
else {
|
||||
return Err("Setting '{}' in mod {} has already been registed", id, m_impl->modID);
|
||||
|
|
Loading…
Reference in a new issue