Skip to content

Commit

Permalink
fix: user config no longer overrides base config
Browse files Browse the repository at this point in the history
  • Loading branch information
shad0wshayd3 committed Nov 13, 2024
1 parent 8b03e42 commit 9c9e481
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 39 deletions.
9 changes: 7 additions & 2 deletions include/REX/REX/INI.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace REX::INI
void StoreLoadImpl(std::string_view& a_fileBase, std::string_view& a_fileUser, std::vector<ISetting*>& a_settings);
void StoreSaveImpl(std::string_view& a_fileBase, std::vector<ISetting*>& a_settings);
template <class T>
void SettingLoadImpl(void* a_file, T& a_value, T& a_valueDefault, std::string_view& a_section, std::string_view& a_key);
void SettingLoadImpl(void* a_file, T& a_value, T& a_valueDefault, bool a_useDefault, std::string_view& a_section, std::string_view& a_key);
template <class T>
void SettingSaveImpl(void* a_file, T& a_value, std::string_view& a_section, std::string_view& a_key);
}
Expand Down Expand Up @@ -44,7 +44,12 @@ namespace REX::INI
public:
virtual void Load(void* a_file) override
{
detail::SettingLoadImpl(a_file, this->m_value, this->m_valueDefault, m_section, m_key);
Load(a_file, true);
}

virtual void Load(void* a_file, bool a_useDefault) override
{
detail::SettingLoadImpl(a_file, this->m_value, this->m_valueDefault, a_useDefault, m_section, m_key);
}

virtual void Save(void* a_file) override
Expand Down
9 changes: 7 additions & 2 deletions include/REX/REX/JSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace REX::JSON
void StoreLoadImpl(std::string_view& a_fileBase, std::string_view& a_fileUser, std::vector<ISetting*>& a_settings);
void StoreSaveImpl(std::string_view& a_fileBase, std::vector<ISetting*>& a_settings);
template <class T>
void SettingLoadImpl(void* a_file, T& a_value, T& a_valueDefault, std::string_view& a_path);
void SettingLoadImpl(void* a_file, T& a_value, T& a_valueDefault, bool a_useDefault, std::string_view& a_path);
template <class T>
void SettingSaveImpl(void* a_file, T& a_value, std::string_view& a_path);
}
Expand Down Expand Up @@ -43,7 +43,12 @@ namespace REX::JSON
public:
virtual void Load(void* a_file) override
{
detail::SettingLoadImpl(a_file, this->m_value, this->m_valueDefault, m_path);
Load(a_file, true);
}

virtual void Load(void* a_file, bool a_useDefault) override
{
detail::SettingLoadImpl(a_file, this->m_value, this->m_valueDefault, a_useDefault, m_path);
}

virtual void Save(void* a_file) override
Expand Down
1 change: 1 addition & 0 deletions include/REX/REX/Setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace REX
{
public:
virtual void Load(void* a_file) = 0;
virtual void Load(void* a_file, bool a_useDefault) = 0;
virtual void Save(void* a_file) = 0;
};

Expand Down
9 changes: 7 additions & 2 deletions include/REX/REX/TOML.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace REX::TOML
void StoreLoadImpl(std::string_view& a_fileBase, std::string_view& a_fileUser, std::vector<ISetting*>& a_settings);
void StoreSaveImpl(std::string_view& a_fileBase, std::vector<ISetting*>& a_settings);
template <class T>
void SettingLoadImpl(void* a_file, T& a_value, T& a_valueDefault, std::string_view& a_path);
void SettingLoadImpl(void* a_file, T& a_value, T& a_valueDefault, bool a_useDefault, std::string_view& a_path);
template <class T>
void SettingSaveImpl(void* a_file, T& a_value, std::string_view& a_path);
}
Expand Down Expand Up @@ -43,7 +43,12 @@ namespace REX::TOML
public:
virtual void Load(void* a_file) override
{
detail::SettingLoadImpl(a_file, this->m_value, this->m_valueDefault, m_path);
Load(a_file, true);
}

virtual void Load(void* a_file, bool a_useDefault) override
{
detail::SettingLoadImpl(a_file, this->m_value, this->m_valueDefault, a_useDefault, m_path);
}

virtual void Save(void* a_file) override
Expand Down
Loading

0 comments on commit 9c9e481

Please sign in to comment.