IniFile SConfig::LoadGameIni(const std::string& id, u16 revision) { IniFile game_ini; for (const std::string& filename : GetGameIniFilenames(id, revision)) game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true); for (const std::string& filename : GetGameIniFilenames(id, revision)) game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true); return game_ini; }
IniFile SConfig::LoadLocalGameIni(const std::string& id, u16 revision) { IniFile game_ini; for (const std::string& filename : GetGameIniFilenames(id, revision)) game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true); return game_ini; }
IniFile SCoreStartupParameter::LoadDefaultGameIni(const std::string& id, int revision) { IniFile game_ini; for (const std::string& filename : GetGameIniFilenames(id, revision)) game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true); return game_ini; }
void Load(Config::Layer* layer) override { IniFile ini; if (layer->GetLayer() == Config::LayerType::GlobalGame) { for (const std::string& filename : GetGameIniFilenames(m_id, m_revision)) ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true); } else { for (const std::string& filename : GetGameIniFilenames(m_id, m_revision)) ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true); } const std::list<IniFile::Section>& system_sections = ini.GetSections(); for (const auto& section : system_sections) { LoadFromSystemSection(layer, section); } LoadControllerConfig(layer); }
void INIGameConfigLayerLoader::Save(Config::Layer* layer) { if (layer->GetLayer() != Config::LayerType::LocalGame) return; IniFile ini; for (const std::string& file_name : GetGameIniFilenames(m_id, m_revision)) ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + file_name, true); for (const auto& config : layer->GetLayerMap()) { const Config::ConfigLocation& location = config.first; const std::optional<std::string>& value = config.second; if (!IsSettingSaveable(location)) continue; const auto ini_location = GetINILocationFromConfig(location); if (ini_location.first.empty() && ini_location.second.empty()) continue; if (value) { IniFile::Section* ini_section = ini.GetOrCreateSection(ini_location.first); ini_section->Set(ini_location.second, *value); } else { ini.DeleteKey(ini_location.first, ini_location.second); } } // Try to save to the revision specific INI first, if it exists. const std::string gameini_with_rev = File::GetUserPath(D_GAMESETTINGS_IDX) + m_id + StringFromFormat("r%d", m_revision) + ".ini"; if (File::Exists(gameini_with_rev)) { ini.Save(gameini_with_rev); return; } // Otherwise, save to the game INI. We don't try any INI broader than that because it will // likely cause issues with cheat codes and game patches. const std::string gameini = File::GetUserPath(D_GAMESETTINGS_IDX) + m_id + ".ini"; ini.Save(gameini); }