mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
Merge 9f4f8b1d2b into 01ae24e46e
This commit is contained in:
commit
1fd904c9ad
|
|
@ -50,6 +50,7 @@ class IConfigVar : virtual public ICommandVar {
|
||||||
virtual std::string config_value() const = 0;
|
virtual std::string config_value() const = 0;
|
||||||
virtual void LoadConfigValue(std::shared_ptr<cpptoml::base> result) = 0;
|
virtual void LoadConfigValue(std::shared_ptr<cpptoml::base> result) = 0;
|
||||||
virtual void LoadGameConfigValue(std::shared_ptr<cpptoml::base> result) = 0;
|
virtual void LoadGameConfigValue(std::shared_ptr<cpptoml::base> result) = 0;
|
||||||
|
virtual void ResetGameConfigValue() = 0;
|
||||||
virtual void ResetConfigValueToDefault() = 0;
|
virtual void ResetConfigValueToDefault() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -95,6 +96,7 @@ class ConfigVar : public CommandVar<T>, virtual public IConfigVar {
|
||||||
// one that will be stored when the global config is written next time. After
|
// one that will be stored when the global config is written next time. After
|
||||||
// overriding, however, the next game config loaded may still change it.
|
// overriding, however, the next game config loaded may still change it.
|
||||||
void OverrideConfigValue(T val);
|
void OverrideConfigValue(T val);
|
||||||
|
void ResetGameConfigValue() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string category_;
|
std::string category_;
|
||||||
|
|
@ -278,6 +280,13 @@ void ConfigVar<T>::OverrideConfigValue(T val) {
|
||||||
this->commandline_value_.reset();
|
this->commandline_value_.reset();
|
||||||
UpdateValue();
|
UpdateValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void ConfigVar<T>::ResetGameConfigValue() {
|
||||||
|
game_config_value_.reset();
|
||||||
|
UpdateValue();
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void ConfigVar<T>::ResetConfigValueToDefault() {
|
void ConfigVar<T>::ResetConfigValueToDefault() {
|
||||||
SetConfigValue(this->default_value_);
|
SetConfigValue(this->default_value_);
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,16 @@ void ReadGameConfig(const std::filesystem::path& file_path) {
|
||||||
XELOGI("Loaded game config: {}", xe::path_to_utf8(file_path));
|
XELOGI("Loaded game config: {}", xe::path_to_utf8(file_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResetGameConfigValues() {
|
||||||
|
if (!cvar::ConfigVars) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (auto& it : *cvar::ConfigVars) {
|
||||||
|
auto config_var = static_cast<cvar::IConfigVar*>(it.second);
|
||||||
|
config_var->ResetGameConfigValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SaveConfig() {
|
void SaveConfig() {
|
||||||
if (config_path.empty()) {
|
if (config_path.empty()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -238,6 +248,8 @@ void SetupConfig(const std::filesystem::path& config_folder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGameConfig(const std::string_view title_id) {
|
void LoadGameConfig(const std::string_view title_id) {
|
||||||
|
ResetGameConfigValues();
|
||||||
|
|
||||||
const auto game_config_folder = config_folder / "config";
|
const auto game_config_folder = config_folder / "config";
|
||||||
const auto game_config_path =
|
const auto game_config_path =
|
||||||
game_config_folder / (std::string(title_id) + game_config_suffix);
|
game_config_folder / (std::string(title_id) + game_config_suffix);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue