yuzu-emu
/
yuzu
Archived
1
0
Fork 0

config: Don't merge the maps

Me shooting myself in the foot 3 days in advance.
This commit is contained in:
lat9nq 2023-05-09 01:29:08 -04:00
parent 640e7db60e
commit ea4afbfc54
2 changed files with 10 additions and 11 deletions

View File

@ -19,10 +19,6 @@ namespace FS = Common::FS;
Config::Config(const std::string& config_name, ConfigType config_type) Config::Config(const std::string& config_name, ConfigType config_type)
: type(config_type), global{config_type == ConfigType::GlobalConfig} { : type(config_type), global{config_type == ConfigType::GlobalConfig} {
settings_map = Settings::values.linkage.by_category;
settings_map.merge(UISettings::values.linkage.by_category);
Initialize(config_name); Initialize(config_name);
} }
@ -1311,14 +1307,22 @@ const std::string& Config::GetConfigFilePath() const {
return qt_config_loc; return qt_config_loc;
} }
static auto FindRelevantList(Settings::Category category) {
auto& map = Settings::values.linkage.by_category;
if (map.contains(category)) {
return Settings::values.linkage.by_category[category];
}
return UISettings::values.linkage.by_category[category];
}
void Config::ReadCategory(Settings::Category category) { void Config::ReadCategory(Settings::Category category) {
const auto& settings = settings_map[category]; const auto& settings = FindRelevantList(category);
std::for_each(settings.begin(), settings.end(), std::for_each(settings.begin(), settings.end(),
[&](const auto& setting) { ReadSettingGeneric(setting); }); [&](const auto& setting) { ReadSettingGeneric(setting); });
} }
void Config::WriteCategory(Settings::Category category) { void Config::WriteCategory(Settings::Category category) {
const auto& settings = settings_map[category]; const auto& settings = FindRelevantList(category);
std::for_each(settings.begin(), settings.end(), std::for_each(settings.begin(), settings.end(),
[&](const auto& setting) { WriteSettingGeneric(setting); }); [&](const auto& setting) { WriteSettingGeneric(setting); });
} }
@ -1346,11 +1350,8 @@ void Config::ReadSettingGeneric(Settings::BasicSetting* const setting) {
void Config::WriteSettingGeneric(Settings::BasicSetting* const setting) const { void Config::WriteSettingGeneric(Settings::BasicSetting* const setting) const {
if (!setting->Save()) { if (!setting->Save()) {
LOG_DEBUG(Frontend, "Skipping \"{}\" marked for not saving", setting->GetLabel());
return; return;
} }
LOG_DEBUG(Frontend, "Saving {} setting \"{}\"...", global ? "global" : "custom",
setting->GetLabel());
const QVariant value = QVariant::fromValue(QString::fromStdString(setting->ToString())); const QVariant value = QVariant::fromValue(QString::fromStdString(setting->ToString()));
const QVariant default_value = const QVariant default_value =
QVariant::fromValue(QString::fromStdString(setting->DefaultToString())); QVariant::fromValue(QString::fromStdString(setting->DefaultToString()));

View File

@ -204,8 +204,6 @@ private:
void ReadSettingGeneric(Settings::BasicSetting* const setting); void ReadSettingGeneric(Settings::BasicSetting* const setting);
void WriteSettingGeneric(Settings::BasicSetting* const setting) const; void WriteSettingGeneric(Settings::BasicSetting* const setting) const;
std::map<Settings::Category, std::forward_list<Settings::BasicSetting*>> settings_map;
const ConfigType type; const ConfigType type;
std::unique_ptr<QSettings> qt_config; std::unique_ptr<QSettings> qt_config;
std::string qt_config_loc; std::string qt_config_loc;