diff --git a/UnleashedRecomp/config.cpp b/UnleashedRecomp/config.cpp index 1d93021..5643640 100644 --- a/UnleashedRecomp/config.cpp +++ b/UnleashedRecomp/config.cpp @@ -14,7 +14,7 @@ void Config::Load() { auto toml = toml::parse_file(configPath.string()); - for (auto def : Definitions) + for (auto def : g_configDefs) { def->ReadValue(toml); #if _DEBUG @@ -38,7 +38,7 @@ void Config::Save() std::string result; std::string section; - for (auto def : Definitions) + for (auto def : g_configDefs) { auto isFirstSection = section.empty(); auto isDefWithSection = section != def->GetSection(); diff --git a/UnleashedRecomp/config.h b/UnleashedRecomp/config.h index 063ced0..6a71f3c 100644 --- a/UnleashedRecomp/config.h +++ b/UnleashedRecomp/config.h @@ -5,8 +5,6 @@ class Config { public: - inline static std::vector Definitions{}; - CONFIG_DEFINE_ENUM("System", ELanguage, Language, ELanguage::English); CONFIG_DEFINE("System", bool, Hints, true); CONFIG_DEFINE("System", bool, ControlTutorial, true); diff --git a/UnleashedRecomp/config_detail.h b/UnleashedRecomp/config_detail.h index 5b31540..e02e5a9 100644 --- a/UnleashedRecomp/config_detail.h +++ b/UnleashedRecomp/config_detail.h @@ -42,6 +42,8 @@ public: virtual std::string ToString() const = 0; }; +inline static std::vector g_configDefs{}; + template class ConfigDef : public ConfigDefBase { @@ -61,7 +63,7 @@ public: ConfigDef(std::string section, std::string name, T defaultValue) : Section(section), Name(name), DefaultValue(defaultValue) { - Config::Definitions.emplace_back(this); + g_configDefs.emplace_back(this); } ConfigDef(std::string section, std::string name, T defaultValue, std::unordered_map enumTemplate) @@ -70,19 +72,19 @@ public: for (const auto& pair : EnumTemplate) EnumTemplateReverse[pair.second] = pair.first; - Config::Definitions.emplace_back(this); + g_configDefs.emplace_back(this); } ConfigDef(std::string section, std::string name, T defaultValue, std::function*)> readCallback) : Section(section), Name(name), DefaultValue(defaultValue), ReadCallback(readCallback) { - Config::Definitions.emplace_back(this); + g_configDefs.emplace_back(this); } ConfigDef(std::string section, std::string name, T defaultValue, std::function*, const toml::v3::table&)> readImpl) : Section(section), Name(name), DefaultValue(defaultValue), ReadImpl(readImpl) { - Config::Definitions.emplace_back(this); + g_configDefs.emplace_back(this); } void ReadValue(toml::v3::ex::parse_result& toml) override