diff --git a/Source/Android/jni/Cheats/ARCheat.cpp b/Source/Android/jni/Cheats/ARCheat.cpp index a3af52827a..5214ee390c 100644 --- a/Source/Android/jni/Cheats/ARCheat.cpp +++ b/Source/Android/jni/Cheats/ARCheat.cpp @@ -137,12 +137,12 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_ARCheat_loadCodes(JNIEnv* e jint revision) { const std::string game_id = GetJString(env, jGameID); - IniFile game_ini_local; + Common::IniFile game_ini_local; // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI // will always be stored in GS/${GAMEID}.ini game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + game_id + ".ini"); - const IniFile game_ini_default = SConfig::LoadDefaultGameIni(game_id, revision); + const Common::IniFile game_ini_default = SConfig::LoadDefaultGameIni(game_id, revision); const std::vector codes = ActionReplay::LoadCodes(game_ini_default, game_ini_local); @@ -167,7 +167,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_ARCh const std::string game_id = GetJString(env, jGameID); const std::string ini_path = File::GetUserPath(D_GAMESETTINGS_IDX) + game_id + ".ini"; - IniFile game_ini_local; + Common::IniFile game_ini_local; game_ini_local.Load(ini_path); ActionReplay::SaveCodes(&game_ini_local, vector); game_ini_local.Save(ini_path); diff --git a/Source/Android/jni/Cheats/GeckoCheat.cpp b/Source/Android/jni/Cheats/GeckoCheat.cpp index 8b09dc6130..70261b6dc2 100644 --- a/Source/Android/jni/Cheats/GeckoCheat.cpp +++ b/Source/Android/jni/Cheats/GeckoCheat.cpp @@ -146,12 +146,12 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_GeckoCheat_loadCodes(JNIEnv jint revision) { const std::string game_id = GetJString(env, jGameID); - IniFile game_ini_local; + Common::IniFile game_ini_local; // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI // will always be stored in GS/${GAMEID}.ini game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + game_id + ".ini"); - const IniFile game_ini_default = SConfig::LoadDefaultGameIni(game_id, revision); + const Common::IniFile game_ini_default = SConfig::LoadDefaultGameIni(game_id, revision); const std::vector codes = Gecko::LoadCodes(game_ini_default, game_ini_local); @@ -175,7 +175,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_Geck const std::string game_id = GetJString(env, jGameID); const std::string ini_path = File::GetUserPath(D_GAMESETTINGS_IDX) + game_id + ".ini"; - IniFile game_ini_local; + Common::IniFile game_ini_local; game_ini_local.Load(ini_path); Gecko::SaveCodes(game_ini_local, vector); game_ini_local.Save(ini_path); diff --git a/Source/Android/jni/Cheats/PatchCheat.cpp b/Source/Android/jni/Cheats/PatchCheat.cpp index fb5be8d5b5..b9cb89ce60 100644 --- a/Source/Android/jni/Cheats/PatchCheat.cpp +++ b/Source/Android/jni/Cheats/PatchCheat.cpp @@ -124,12 +124,12 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_loadCodes(JNIEnv jint revision) { const std::string game_id = GetJString(env, jGameID); - IniFile game_ini_local; + Common::IniFile game_ini_local; // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI // will always be stored in GS/${GAMEID}.ini game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + game_id + ".ini"); - const IniFile game_ini_default = SConfig::LoadDefaultGameIni(game_id, revision); + const Common::IniFile game_ini_default = SConfig::LoadDefaultGameIni(game_id, revision); std::vector patches; PatchEngine::LoadPatchSection("OnFrame", &patches, game_ini_default, game_ini_local); @@ -154,7 +154,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_Patc const std::string game_id = GetJString(env, jGameID); const std::string ini_path = File::GetUserPath(D_GAMESETTINGS_IDX) + game_id + ".ini"; - IniFile game_ini_local; + Common::IniFile game_ini_local; game_ini_local.Load(ini_path); PatchEngine::SavePatchSection(&game_ini_local, vector); game_ini_local.Save(ini_path); diff --git a/Source/Android/jni/IniFile.cpp b/Source/Android/jni/IniFile.cpp index 56856feb9c..7172094bdf 100644 --- a/Source/Android/jni/IniFile.cpp +++ b/Source/Android/jni/IniFile.cpp @@ -7,6 +7,8 @@ #include "jni/AndroidCommon/AndroidCommon.h" #include "jni/AndroidCommon/IDCache.h" +using Common::IniFile; + static IniFile::Section* GetSectionPointer(JNIEnv* env, jobject obj) { return reinterpret_cast( diff --git a/Source/Android/jni/Input/EmulatedController.cpp b/Source/Android/jni/Input/EmulatedController.cpp index 6c8d64e22f..3d2676812f 100644 --- a/Source/Android/jni/Input/EmulatedController.cpp +++ b/Source/Android/jni/Input/EmulatedController.cpp @@ -91,7 +91,7 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro ControllerEmu::EmulatedController* controller = EmulatedControllerFromJava(env, obj); // Loading an empty IniFile section clears everything. - IniFile::Section section; + Common::IniFile::Section section; controller->LoadConfig(§ion); controller->UpdateReferences(g_controller_interface); @@ -103,7 +103,7 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro { ControllerEmu::EmulatedController* controller = EmulatedControllerFromJava(env, obj); - IniFile ini; + Common::IniFile ini; ini.Load(GetJString(env, j_path)); controller->LoadConfig(ini.GetOrCreateSection("Profile")); @@ -118,7 +118,7 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro File::CreateFullPath(path); - IniFile ini; + Common::IniFile ini; EmulatedControllerFromJava(env, obj)->SaveConfig(ini.GetOrCreateSection("Profile")); ini.Save(path); diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index 41f1917fef..2aed1b805f 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -15,6 +15,8 @@ #include "Common/FileUtil.h" #include "Common/StringUtil.h" +namespace Common +{ void IniFile::ParseLine(std::string_view line, std::string* keyOut, std::string* valueOut) { if (line.empty() || line.front() == '#') @@ -369,3 +371,4 @@ bool IniFile::Save(const std::string& filename) return 0; } */ +} // namespace Common diff --git a/Source/Core/Common/IniFile.h b/Source/Core/Common/IniFile.h index 9de68a3246..c37be55f43 100644 --- a/Source/Core/Common/IniFile.h +++ b/Source/Core/Common/IniFile.h @@ -13,6 +13,8 @@ #include "Common/CommonTypes.h" #include "Common/StringUtil.h" +namespace Common +{ struct CaseInsensitiveStringCompare { // Allow heterogenous lookup. @@ -166,3 +168,4 @@ private: static const std::string& NULL_STRING; }; +} // namespace Common diff --git a/Source/Core/Core/ActionReplay.cpp b/Source/Core/Core/ActionReplay.cpp index 05b87e11b4..39a05d00b8 100644 --- a/Source/Core/Core/ActionReplay.cpp +++ b/Source/Core/Core/ActionReplay.cpp @@ -169,18 +169,17 @@ void AddCode(ARCode code) } } -void LoadAndApplyCodes(const IniFile& global_ini, const IniFile& local_ini) +void LoadAndApplyCodes(const Common::IniFile& global_ini, const Common::IniFile& local_ini) { ApplyCodes(LoadCodes(global_ini, local_ini)); } // Parses the Action Replay section of a game ini file. -std::vector LoadCodes(const IniFile& global_ini, const IniFile& local_ini) +std::vector LoadCodes(const Common::IniFile& global_ini, const Common::IniFile& local_ini) { std::vector codes; - const IniFile* inis[2] = {&global_ini, &local_ini}; - for (const IniFile* ini : inis) + for (const auto* ini : {&global_ini, &local_ini}) { std::vector lines; std::vector encrypted_lines; @@ -250,7 +249,7 @@ std::vector LoadCodes(const IniFile& global_ini, const IniFile& local_in return codes; } -void SaveCodes(IniFile* local_ini, std::span codes) +void SaveCodes(Common::IniFile* local_ini, std::span codes) { std::vector lines; std::vector enabled_lines; diff --git a/Source/Core/Core/ActionReplay.h b/Source/Core/Core/ActionReplay.h index 4681bb887c..3b05c1117c 100644 --- a/Source/Core/Core/ActionReplay.h +++ b/Source/Core/Core/ActionReplay.h @@ -10,7 +10,10 @@ #include "Common/CommonTypes.h" +namespace Common +{ class IniFile; +} namespace Core { @@ -47,10 +50,10 @@ void SetSyncedCodesAsActive(); void UpdateSyncedCodes(std::span codes); std::vector ApplyAndReturnCodes(std::span codes); void AddCode(ARCode new_code); -void LoadAndApplyCodes(const IniFile& global_ini, const IniFile& local_ini); +void LoadAndApplyCodes(const Common::IniFile& global_ini, const Common::IniFile& local_ini); -std::vector LoadCodes(const IniFile& global_ini, const IniFile& local_ini); -void SaveCodes(IniFile* local_ini, std::span codes); +std::vector LoadCodes(const Common::IniFile& global_ini, const Common::IniFile& local_ini); +void SaveCodes(Common::IniFile* local_ini, std::span codes); using EncryptedLine = std::string; std::variant DeserializeLine(const std::string& line); diff --git a/Source/Core/Core/CheatCodes.h b/Source/Core/Core/CheatCodes.h index ff0d898655..fc73b10f56 100644 --- a/Source/Core/Core/CheatCodes.h +++ b/Source/Core/Core/CheatCodes.h @@ -9,7 +9,7 @@ #include "Common/IniFile.h" template -void ReadEnabledOrDisabled(const IniFile& ini, const std::string& section, bool enabled, +void ReadEnabledOrDisabled(const Common::IniFile& ini, const std::string& section, bool enabled, std::vector* codes) { std::vector lines; @@ -30,7 +30,8 @@ void ReadEnabledOrDisabled(const IniFile& ini, const std::string& section, bool } template -void ReadEnabledAndDisabled(const IniFile& ini, const std::string& section, std::vector* codes) +void ReadEnabledAndDisabled(const Common::IniFile& ini, const std::string& section, + std::vector* codes) { ReadEnabledOrDisabled(ini, section + "_Enabled", true, codes); ReadEnabledOrDisabled(ini, section + "_Disabled", false, codes); diff --git a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp index 6b8ed12e7b..5356449cdb 100644 --- a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp @@ -113,14 +113,14 @@ public: LoadFromSYSCONF(layer); for (const auto& system : system_to_ini) { - IniFile ini; + Common::IniFile ini; ini.Load(File::GetUserPath(system.second)); - const std::list& system_sections = ini.GetSections(); + const auto& system_sections = ini.GetSections(); for (const auto& section : system_sections) { const std::string section_name = section.GetName(); - const IniFile::Section::SectionMap& section_map = section.GetValues(); + const auto& section_map = section.GetValues(); for (const auto& value : section_map) { @@ -141,7 +141,7 @@ public: { SaveToSYSCONF(layer->GetLayer()); - std::map inis; + std::map inis; for (const auto& system : system_to_ini) { @@ -176,7 +176,7 @@ public: if (value) { - IniFile::Section* ini_section = ini->second.GetOrCreateSection(location.section); + auto* ini_section = ini->second.GetOrCreateSection(location.section); ini_section->Set(location.key, *value); } else diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp index 7b6466b20f..2ca46691d2 100644 --- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp @@ -175,7 +175,7 @@ public: void Load(Config::Layer* layer) override { - IniFile ini; + Common::IniFile ini; if (layer->GetLayer() == Config::LayerType::GlobalGame) { for (const std::string& filename : GetGameIniFilenames(m_id, m_revision)) @@ -187,7 +187,7 @@ public: ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true); } - const std::list& system_sections = ini.GetSections(); + const auto& system_sections = ini.GetSections(); for (const auto& section : system_sections) { @@ -234,11 +234,11 @@ private: continue; } - IniFile profile_ini; + Common::IniFile profile_ini; profile_ini.Load(ini_path); - const IniFile::Section* ini_section = profile_ini.GetOrCreateSection("Profile"); - const IniFile::Section::SectionMap& section_map = ini_section->GetValues(); + const auto* ini_section = profile_ini.GetOrCreateSection("Profile"); + const auto& section_map = ini_section->GetValues(); for (const auto& value : section_map) { Config::Location location{std::get<2>(use_data), std::get<1>(use_data) + num, @@ -250,12 +250,12 @@ private: } } - void LoadFromSystemSection(Config::Layer* layer, const IniFile::Section& section) const + void LoadFromSystemSection(Config::Layer* layer, const Common::IniFile::Section& section) const { const std::string section_name = section.GetName(); // Regular key,value pairs - const IniFile::Section::SectionMap& section_map = section.GetValues(); + const auto& section_map = section.GetValues(); for (const auto& value : section_map) { @@ -280,7 +280,7 @@ void INIGameConfigLayerLoader::Save(Config::Layer* layer) if (layer->GetLayer() != Config::LayerType::LocalGame) return; - IniFile ini; + Common::IniFile ini; for (const std::string& file_name : GetGameIniFilenames(m_id, m_revision)) ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + file_name, true); @@ -298,7 +298,7 @@ void INIGameConfigLayerLoader::Save(Config::Layer* layer) if (value) { - IniFile::Section* ini_section = ini.GetOrCreateSection(ini_location.first); + auto* ini_section = ini.GetOrCreateSection(ini_location.first); ini_section->Set(ini_location.second, *value); } else diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index f2eefe171c..cf33a27b2b 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -393,40 +393,40 @@ DiscIO::Language SConfig::GetLanguageAdjustedForRegion(bool wii, DiscIO::Region return language; } -IniFile SConfig::LoadDefaultGameIni() const +Common::IniFile SConfig::LoadDefaultGameIni() const { return LoadDefaultGameIni(GetGameID(), m_revision); } -IniFile SConfig::LoadLocalGameIni() const +Common::IniFile SConfig::LoadLocalGameIni() const { return LoadLocalGameIni(GetGameID(), m_revision); } -IniFile SConfig::LoadGameIni() const +Common::IniFile SConfig::LoadGameIni() const { return LoadGameIni(GetGameID(), m_revision); } -IniFile SConfig::LoadDefaultGameIni(const std::string& id, std::optional revision) +Common::IniFile SConfig::LoadDefaultGameIni(const std::string& id, std::optional revision) { - IniFile game_ini; + Common::IniFile game_ini; for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision)) game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true); return game_ini; } -IniFile SConfig::LoadLocalGameIni(const std::string& id, std::optional revision) +Common::IniFile SConfig::LoadLocalGameIni(const std::string& id, std::optional revision) { - IniFile game_ini; + Common::IniFile game_ini; for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision)) game_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true); return game_ini; } -IniFile SConfig::LoadGameIni(const std::string& id, std::optional revision) +Common::IniFile SConfig::LoadGameIni(const std::string& id, std::optional revision) { - IniFile game_ini; + Common::IniFile game_ini; for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision)) game_ini.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true); for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision)) diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 5f3f325983..5af0075134 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -14,7 +14,10 @@ #include "Common/Common.h" #include "Common/CommonTypes.h" +namespace Common +{ class IniFile; +} namespace Core { @@ -81,13 +84,13 @@ struct SConfig DiscIO::Language GetCurrentLanguage(bool wii) const; DiscIO::Language GetLanguageAdjustedForRegion(bool wii, DiscIO::Region region) const; - IniFile LoadDefaultGameIni() const; - IniFile LoadLocalGameIni() const; - IniFile LoadGameIni() const; + Common::IniFile LoadDefaultGameIni() const; + Common::IniFile LoadLocalGameIni() const; + Common::IniFile LoadGameIni() const; - static IniFile LoadDefaultGameIni(const std::string& id, std::optional revision); - static IniFile LoadLocalGameIni(const std::string& id, std::optional revision); - static IniFile LoadGameIni(const std::string& id, std::optional revision); + static Common::IniFile LoadDefaultGameIni(const std::string& id, std::optional revision); + static Common::IniFile LoadLocalGameIni(const std::string& id, std::optional revision); + static Common::IniFile LoadGameIni(const std::string& id, std::optional revision); SConfig(const SConfig&) = delete; SConfig& operator=(const SConfig&) = delete; diff --git a/Source/Core/Core/GeckoCodeConfig.cpp b/Source/Core/Core/GeckoCodeConfig.cpp index e4fc7c4c68..350edc3e31 100644 --- a/Source/Core/Core/GeckoCodeConfig.cpp +++ b/Source/Core/Core/GeckoCodeConfig.cpp @@ -127,11 +127,11 @@ std::vector DownloadCodes(std::string gametdb_id, bool* succeeded, bo return gcodes; } -std::vector LoadCodes(const IniFile& globalIni, const IniFile& localIni) +std::vector LoadCodes(const Common::IniFile& globalIni, const Common::IniFile& localIni) { std::vector gcodes; - for (const IniFile* ini : {&globalIni, &localIni}) + for (const auto* ini : {&globalIni, &localIni}) { std::vector lines; ini->GetLines("Gecko", &lines, false); @@ -239,7 +239,7 @@ static void SaveGeckoCode(std::vector& lines, const GeckoCode& gcod lines.push_back('*' + note); } -void SaveCodes(IniFile& inifile, const std::vector& gcodes) +void SaveCodes(Common::IniFile& inifile, const std::vector& gcodes) { std::vector lines; std::vector enabled_lines; diff --git a/Source/Core/Core/GeckoCodeConfig.h b/Source/Core/Core/GeckoCodeConfig.h index 2497ab603e..941e6246f5 100644 --- a/Source/Core/Core/GeckoCodeConfig.h +++ b/Source/Core/Core/GeckoCodeConfig.h @@ -9,14 +9,17 @@ #include "Core/GeckoCode.h" +namespace Common +{ class IniFile; +} namespace Gecko { -std::vector LoadCodes(const IniFile& globalIni, const IniFile& localIni); +std::vector LoadCodes(const Common::IniFile& globalIni, const Common::IniFile& localIni); std::vector DownloadCodes(std::string gametdb_id, bool* succeeded, bool use_https = true); -void SaveCodes(IniFile& inifile, const std::vector& gcodes); +void SaveCodes(Common::IniFile& inifile, const std::vector& gcodes); std::optional DeserializeLine(const std::string& line); } // namespace Gecko diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index b305db6fa9..bfff976d0f 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -251,7 +251,7 @@ bool IsPressed(int id, bool held) // TODO: Remove this at a future date when we're confident most configs are migrated. static void LoadLegacyConfig(ControllerEmu::EmulatedController* controller) { - IniFile inifile; + Common::IniFile inifile; if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Hotkeys.ini")) { if (!inifile.Exists("Hotkeys") && inifile.Exists("Hotkeys1")) diff --git a/Source/Core/Core/IOS/USB/USB_KBD.cpp b/Source/Core/Core/IOS/USB/USB_KBD.cpp index 35e34b07fc..5dcdb109c0 100644 --- a/Source/Core/Core/IOS/USB/USB_KBD.cpp +++ b/Source/Core/Core/IOS/USB/USB_KBD.cpp @@ -191,7 +191,7 @@ USB_KBD::USB_KBD(Kernel& ios, const std::string& device_name) : Device(ios, devi std::optional USB_KBD::Open(const OpenRequest& request) { INFO_LOG_FMT(IOS, "USB_KBD: Open"); - IniFile ini; + Common::IniFile ini; ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_keyboard_layout, KBD_LAYOUT_QWERTY); diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index cf5f5571b9..91f494f8df 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -2027,10 +2027,10 @@ bool NetPlayServer::SyncCodes() // Find all INI files const auto game_id = game->GetGameID(); const auto revision = game->GetRevision(); - IniFile globalIni; + Common::IniFile globalIni; for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(game_id, revision)) globalIni.Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + filename, true); - IniFile localIni; + Common::IniFile localIni; for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(game_id, revision)) localIni.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + filename, true); diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index 21187dd9b6..069d8565c0 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -101,11 +101,9 @@ std::string SerializeLine(const PatchEntry& entry) } void LoadPatchSection(const std::string& section, std::vector* patches, - const IniFile& globalIni, const IniFile& localIni) + const Common::IniFile& globalIni, const Common::IniFile& localIni) { - const IniFile* inis[2] = {&globalIni, &localIni}; - - for (const IniFile* ini : inis) + for (const auto* ini : {&globalIni, &localIni}) { std::vector lines; Patch currentPatch; @@ -151,7 +149,7 @@ void LoadPatchSection(const std::string& section, std::vector* patches, } } -void SavePatchSection(IniFile* local_ini, const std::vector& patches) +void SavePatchSection(Common::IniFile* local_ini, const std::vector& patches) { std::vector lines; std::vector lines_enabled; @@ -176,7 +174,7 @@ void SavePatchSection(IniFile* local_ini, const std::vector& patches) local_ini->SetLines("OnFrame", lines); } -static void LoadSpeedhacks(const std::string& section, IniFile& ini) +static void LoadSpeedhacks(const std::string& section, Common::IniFile& ini) { std::vector keys; ini.GetKeys(section, &keys); @@ -210,9 +208,10 @@ int GetSpeedhackCycles(const u32 addr) void LoadPatches() { - IniFile merged = SConfig::GetInstance().LoadGameIni(); - IniFile globalIni = SConfig::GetInstance().LoadDefaultGameIni(); - IniFile localIni = SConfig::GetInstance().LoadLocalGameIni(); + const auto& sconfig = SConfig::GetInstance(); + Common::IniFile merged = sconfig.LoadGameIni(); + Common::IniFile globalIni = sconfig.LoadDefaultGameIni(); + Common::IniFile localIni = sconfig.LoadLocalGameIni(); LoadPatchSection("OnFrame", &s_on_frame, globalIni, localIni); diff --git a/Source/Core/Core/PatchEngine.h b/Source/Core/Core/PatchEngine.h index 4218e65fcb..9232e4b099 100644 --- a/Source/Core/Core/PatchEngine.h +++ b/Source/Core/Core/PatchEngine.h @@ -9,7 +9,10 @@ #include "Common/CommonTypes.h" +namespace Common +{ class IniFile; +} namespace PatchEngine { @@ -47,8 +50,8 @@ int GetSpeedhackCycles(const u32 addr); std::optional DeserializeLine(std::string line); std::string SerializeLine(const PatchEntry& entry); void LoadPatchSection(const std::string& section, std::vector* patches, - const IniFile& globalIni, const IniFile& localIni); -void SavePatchSection(IniFile* local_ini, const std::vector& patches); + const Common::IniFile& globalIni, const Common::IniFile& localIni); +void SavePatchSection(Common::IniFile* local_ini, const std::vector& patches); void LoadPatches(); void AddMemoryPatch(std::size_t index); diff --git a/Source/Core/DolphinQt/Config/ARCodeWidget.cpp b/Source/Core/DolphinQt/Config/ARCodeWidget.cpp index f201dcce9d..6a18a16937 100644 --- a/Source/Core/DolphinQt/Config/ARCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/ARCodeWidget.cpp @@ -33,13 +33,14 @@ ARCodeWidget::ARCodeWidget(std::string game_id, u16 game_revision, bool restart_ if (!m_game_id.empty()) { - IniFile game_ini_local; + Common::IniFile game_ini_local; // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI // will always be stored in GS/${GAMEID}.ini game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); - const IniFile game_ini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); + const Common::IniFile game_ini_default = + SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); m_ar_codes = ActionReplay::LoadCodes(game_ini_default, game_ini_local); } @@ -185,7 +186,7 @@ void ARCodeWidget::SaveCodes() const auto ini_path = std::string(File::GetUserPath(D_GAMESETTINGS_IDX)).append(m_game_id).append(".ini"); - IniFile game_ini_local; + Common::IniFile game_ini_local; game_ini_local.Load(ini_path); ActionReplay::SaveCodes(&game_ini_local, m_ar_codes); game_ini_local.Save(ini_path); diff --git a/Source/Core/DolphinQt/Config/GameConfigWidget.h b/Source/Core/DolphinQt/Config/GameConfigWidget.h index f71ccbccd9..44ae2375f5 100644 --- a/Source/Core/DolphinQt/Config/GameConfigWidget.h +++ b/Source/Core/DolphinQt/Config/GameConfigWidget.h @@ -63,6 +63,6 @@ private: const UICommon::GameFile& m_game; std::string m_game_id; - IniFile m_gameini_local; - IniFile m_gameini_default; + Common::IniFile m_gameini_local; + Common::IniFile m_gameini_default; }; diff --git a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp index d3fc411498..b94a544424 100644 --- a/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp +++ b/Source/Core/DolphinQt/Config/GeckoCodeWidget.cpp @@ -40,13 +40,14 @@ GeckoCodeWidget::GeckoCodeWidget(std::string game_id, std::string gametdb_id, u1 if (!m_game_id.empty()) { - IniFile game_ini_local; + Common::IniFile game_ini_local; // We don't use LoadLocalGameIni() here because user cheat codes that are installed via the UI // will always be stored in GS/${GAMEID}.ini game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); - const IniFile game_ini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); + const Common::IniFile game_ini_default = + SConfig::LoadDefaultGameIni(m_game_id, m_game_revision); m_gecko_codes = Gecko::LoadCodes(game_ini_default, game_ini_local); } @@ -245,7 +246,7 @@ void GeckoCodeWidget::SaveCodes() const auto ini_path = std::string(File::GetUserPath(D_GAMESETTINGS_IDX)).append(m_game_id).append(".ini"); - IniFile game_ini_local; + Common::IniFile game_ini_local; game_ini_local.Load(ini_path); Gecko::SaveCodes(game_ini_local, m_gecko_codes); game_ini_local.Save(ini_path); diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp index c04d41280d..bb1a00d88d 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp @@ -299,7 +299,7 @@ void MappingWindow::OnLoadProfilePressed() const QString profile_path = m_profiles_combo->currentData().toString(); - IniFile ini; + Common::IniFile ini; ini.Load(profile_path.toStdString()); m_controller->LoadConfig(ini.GetOrCreateSection("Profile")); @@ -322,7 +322,7 @@ void MappingWindow::OnSaveProfilePressed() File::CreateFullPath(profile_path); - IniFile ini; + Common::IniFile ini; m_controller->SaveConfig(ini.GetOrCreateSection("Profile")); ini.Save(profile_path); @@ -542,7 +542,7 @@ void MappingWindow::OnDefaultFieldsPressed() void MappingWindow::OnClearFieldsPressed() { // Loading an empty inifile section clears everything. - IniFile::Section sec; + Common::IniFile::Section sec; // Keep the currently selected device. const auto default_device = m_controller->GetDefaultDevice(); diff --git a/Source/Core/DolphinQt/Config/PatchesWidget.cpp b/Source/Core/DolphinQt/Config/PatchesWidget.cpp index 2c08d932c0..a8abbf72ba 100644 --- a/Source/Core/DolphinQt/Config/PatchesWidget.cpp +++ b/Source/Core/DolphinQt/Config/PatchesWidget.cpp @@ -21,10 +21,11 @@ PatchesWidget::PatchesWidget(const UICommon::GameFile& game) : m_game_id(game.GetGameID()), m_game_revision(game.GetRevision()) { - IniFile game_ini_local; + Common::IniFile game_ini_local; game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); - IniFile game_ini_default = SConfig::GetInstance().LoadDefaultGameIni(m_game_id, m_game_revision); + Common::IniFile game_ini_default = + SConfig::GetInstance().LoadDefaultGameIni(m_game_id, m_game_revision); PatchEngine::LoadPatchSection("OnFrame", &m_patches, game_ini_default, game_ini_local); @@ -128,7 +129,7 @@ void PatchesWidget::SavePatches() { const std::string ini_path = File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"; - IniFile game_ini_local; + Common::IniFile game_ini_local; game_ini_local.Load(ini_path); PatchEngine::SavePatchSection(&game_ini_local, m_patches); game_ini_local.Save(ini_path); diff --git a/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp b/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp index c21ae91e6f..2412bef831 100644 --- a/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/BreakpointWidget.cpp @@ -337,7 +337,7 @@ void BreakpointWidget::OnEditBreakpoint(u32 address, bool is_instruction_bp) void BreakpointWidget::OnLoad() { - IniFile ini; + Common::IniFile ini; if (!ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini", false)) { @@ -367,7 +367,7 @@ void BreakpointWidget::OnLoad() void BreakpointWidget::OnSave() { - IniFile ini; + Common::IniFile ini; ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini", false); ini.SetLines("BreakPoints", m_system.GetPowerPC().GetBreakPoints().GetStrings()); diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp index 2be4a2a2f7..16d327835e 100644 --- a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp @@ -289,7 +289,7 @@ void WatchWidget::OnNewWatch() void WatchWidget::OnLoad() { - IniFile ini; + Common::IniFile ini; std::vector watches; @@ -317,7 +317,7 @@ void WatchWidget::OnLoad() void WatchWidget::OnSave() { - IniFile ini; + Common::IniFile ini; ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini", false); ini.SetLines("Watches", m_system.GetPowerPC().GetDebugInterface().SaveWatchesToStrings()); diff --git a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp index b9bfc2802c..dc08148b79 100644 --- a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp +++ b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp @@ -353,7 +353,7 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow( } else { - IniFile ini; + Common::IniFile ini; ini.Load(File::GetUserPath(D_CONFIG_IDX) + "WiimoteNew.ini"); const std::string section_name = "Wiimote" + std::to_string(num + 1); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp index 0b69c7e6c2..2896acd070 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp @@ -50,7 +50,7 @@ void ControlGroup::AddDeadzoneSetting(SettingValue* value, double maximu ControlGroup::~ControlGroup() = default; -void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev, +void ControlGroup::LoadConfig(Common::IniFile::Section* sec, const std::string& defdev, const std::string& base) { const std::string group(base + name + "/"); @@ -103,7 +103,7 @@ void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev, } } -void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev, +void ControlGroup::SaveConfig(Common::IniFile::Section* sec, const std::string& defdev, const std::string& base) { const std::string group(base + name + "/"); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h index fb10bab074..f51fff6015 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h @@ -68,9 +68,9 @@ public: DefaultValue default_value = DefaultValue::AlwaysEnabled); virtual ~ControlGroup(); - virtual void LoadConfig(IniFile::Section* sec, const std::string& defdev = "", + virtual void LoadConfig(Common::IniFile::Section* sec, const std::string& defdev = "", const std::string& base = ""); - virtual void SaveConfig(IniFile::Section* sec, const std::string& defdev = "", + virtual void SaveConfig(Common::IniFile::Section* sec, const std::string& defdev = "", const std::string& base = ""); void SetControlExpression(int index, const std::string& expression); diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp index dc9830de3f..0f6f004d10 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp @@ -139,7 +139,7 @@ void EmulatedController::SetDefaultDevice(ciface::Core::DeviceQualifier devq) } } -void EmulatedController::LoadConfig(IniFile::Section* sec, const std::string& base) +void EmulatedController::LoadConfig(Common::IniFile::Section* sec, const std::string& base) { const auto lock = GetStateLock(); std::string defdev = GetDefaultDevice().ToString(); @@ -153,7 +153,7 @@ void EmulatedController::LoadConfig(IniFile::Section* sec, const std::string& ba cg->LoadConfig(sec, defdev, base); } -void EmulatedController::SaveConfig(IniFile::Section* sec, const std::string& base) +void EmulatedController::SaveConfig(Common::IniFile::Section* sec, const std::string& base) { const auto lock = GetStateLock(); const std::string defdev = GetDefaultDevice().ToString(); @@ -168,7 +168,7 @@ void EmulatedController::LoadDefaults(const ControllerInterface& ciface) { const auto lock = GetStateLock(); // load an empty inifile section, clears everything - IniFile::Section sec; + Common::IniFile::Section sec; LoadConfig(&sec); const std::string& default_device_string = ciface.GetDefaultDeviceString(); diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h index e7e957e608..2f505622eb 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h @@ -182,8 +182,8 @@ public: virtual void LoadDefaults(const ControllerInterface& ciface); - virtual void LoadConfig(IniFile::Section* sec, const std::string& base = ""); - virtual void SaveConfig(IniFile::Section* sec, const std::string& base = ""); + virtual void LoadConfig(Common::IniFile::Section* sec, const std::string& base = ""); + virtual void SaveConfig(Common::IniFile::Section* sec, const std::string& base = ""); bool IsDefaultDeviceConnected() const; const ciface::Core::DeviceQualifier& GetDefaultDevice() const; diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h index d123117eb0..67d2fce1c7 100644 --- a/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h +++ b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h @@ -60,8 +60,10 @@ public: virtual ~NumericSettingBase() = default; - virtual void LoadFromIni(const IniFile::Section& section, const std::string& group_name) = 0; - virtual void SaveToIni(IniFile::Section& section, const std::string& group_name) const = 0; + virtual void LoadFromIni(const Common::IniFile::Section& section, + const std::string& group_name) = 0; + virtual void SaveToIni(Common::IniFile::Section& section, + const std::string& group_name) const = 0; virtual InputReference& GetInputReference() = 0; virtual const InputReference& GetInputReference() const = 0; @@ -111,7 +113,7 @@ public: void SetToDefault() override { m_value.SetValue(m_default_value); } - void LoadFromIni(const IniFile::Section& section, const std::string& group_name) override + void LoadFromIni(const Common::IniFile::Section& section, const std::string& group_name) override { std::string str_value; if (section.Get(group_name + m_details.ini_name, &str_value)) @@ -125,7 +127,7 @@ public: } } - void SaveToIni(IniFile::Section& section, const std::string& group_name) const override + void SaveToIni(Common::IniFile::Section& section, const std::string& group_name) const override { if (IsSimpleValue()) { diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp index ce9259f06f..a476cce9ed 100644 --- a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp +++ b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp @@ -226,8 +226,8 @@ void ReshapableInput::SetCenter(ReshapableInput::ReshapeData center) m_center = center; } -void ReshapableInput::LoadConfig(IniFile::Section* section, const std::string& default_device, - const std::string& base_name) +void ReshapableInput::LoadConfig(Common::IniFile::Section* section, + const std::string& default_device, const std::string& base_name) { ControlGroup::LoadConfig(section, default_device, base_name); @@ -269,8 +269,8 @@ void ReshapableInput::LoadConfig(IniFile::Section* section, const std::string& d } } -void ReshapableInput::SaveConfig(IniFile::Section* section, const std::string& default_device, - const std::string& base_name) +void ReshapableInput::SaveConfig(Common::IniFile::Section* section, + const std::string& default_device, const std::string& base_name) { ControlGroup::SaveConfig(section, default_device, base_name); diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.h b/Source/Core/InputCommon/ControllerEmu/StickGate.h index 831762fda3..c618a0a4b4 100644 --- a/Source/Core/InputCommon/ControllerEmu/StickGate.h +++ b/Source/Core/InputCommon/ControllerEmu/StickGate.h @@ -117,8 +117,8 @@ protected: virtual Control* GetModifierInput() const; private: - void LoadConfig(IniFile::Section*, const std::string&, const std::string&) override; - void SaveConfig(IniFile::Section*, const std::string&, const std::string&) override; + void LoadConfig(Common::IniFile::Section*, const std::string&, const std::string&) override; + void SaveConfig(Common::IniFile::Section*, const std::string&, const std::string&) override; CalibrationData m_calibration; SettingValue m_deadzone_setting; diff --git a/Source/Core/InputCommon/DynamicInputTextureManager.cpp b/Source/Core/InputCommon/DynamicInputTextureManager.cpp index 8a325f8f7e..d3b47089a6 100644 --- a/Source/Core/InputCommon/DynamicInputTextureManager.cpp +++ b/Source/Core/InputCommon/DynamicInputTextureManager.cpp @@ -39,7 +39,7 @@ void DynamicInputTextureManager::Load() } } -void DynamicInputTextureManager::GenerateTextures(const IniFile& file, +void DynamicInputTextureManager::GenerateTextures(const Common::IniFile& file, const std::vector& controller_names) { bool any_dirty = false; diff --git a/Source/Core/InputCommon/DynamicInputTextureManager.h b/Source/Core/InputCommon/DynamicInputTextureManager.h index 8d7eeb8472..e4cba93ffa 100644 --- a/Source/Core/InputCommon/DynamicInputTextureManager.h +++ b/Source/Core/InputCommon/DynamicInputTextureManager.h @@ -20,7 +20,8 @@ public: DynamicInputTextureManager(); ~DynamicInputTextureManager(); void Load(); - void GenerateTextures(const IniFile& file, const std::vector& controller_names); + void GenerateTextures(const Common::IniFile& file, + const std::vector& controller_names); private: std::vector m_configuration; diff --git a/Source/Core/InputCommon/DynamicInputTextures/DITConfiguration.cpp b/Source/Core/InputCommon/DynamicInputTextures/DITConfiguration.cpp index fcdf879e8d..8b12fdff10 100644 --- a/Source/Core/InputCommon/DynamicInputTextures/DITConfiguration.cpp +++ b/Source/Core/InputCommon/DynamicInputTextures/DITConfiguration.cpp @@ -11,6 +11,7 @@ #include "Common/CommonPaths.h" #include "Common/FileUtil.h" +#include "Common/IniFile.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" #include "Core/ConfigManager.h" @@ -86,7 +87,7 @@ Configuration::Configuration(const std::string& json_file) Configuration::~Configuration() = default; -bool Configuration::GenerateTextures(const IniFile& file, +bool Configuration::GenerateTextures(const Common::IniFile& file, const std::vector& controller_names) const { bool any_dirty = false; @@ -98,7 +99,7 @@ bool Configuration::GenerateTextures(const IniFile& file, return any_dirty; } -bool Configuration::GenerateTexture(const IniFile& file, +bool Configuration::GenerateTexture(const Common::IniFile& file, const std::vector& controller_names, const Data& texture_data) const { diff --git a/Source/Core/InputCommon/DynamicInputTextures/DITConfiguration.h b/Source/Core/InputCommon/DynamicInputTextures/DITConfiguration.h index 635e1883a1..4835fa6619 100644 --- a/Source/Core/InputCommon/DynamicInputTextures/DITConfiguration.h +++ b/Source/Core/InputCommon/DynamicInputTextures/DITConfiguration.h @@ -4,13 +4,16 @@ #pragma once #include -#include #include #include "Common/CommonTypes.h" -#include "Common/IniFile.h" #include "InputCommon/DynamicInputTextures/DITData.h" +namespace Common +{ +class IniFile; +} + namespace InputCommon::DynamicInputTextures { class Configuration @@ -18,11 +21,12 @@ class Configuration public: explicit Configuration(const std::string& json_file); ~Configuration(); - bool GenerateTextures(const IniFile& file, + bool GenerateTextures(const Common::IniFile& file, const std::vector& controller_names) const; private: - bool GenerateTexture(const IniFile& file, const std::vector& controller_names, + bool GenerateTexture(const Common::IniFile& file, + const std::vector& controller_names, const Data& texture_data) const; std::vector m_dynamic_input_textures; diff --git a/Source/Core/InputCommon/InputConfig.cpp b/Source/Core/InputCommon/InputConfig.cpp index 9605aa8c33..64610ba768 100644 --- a/Source/Core/InputCommon/InputConfig.cpp +++ b/Source/Core/InputCommon/InputConfig.cpp @@ -29,7 +29,7 @@ InputConfig::~InputConfig() = default; bool InputConfig::LoadConfig(InputClass type) { - IniFile inifile; + Common::IniFile inifile; bool useProfile[MAX_BBMOTES] = {false, false, false, false, false}; static constexpr std::array num = {"1", "2", "3", "4", "BB"}; std::string profile[MAX_BBMOTES]; @@ -57,8 +57,8 @@ bool InputConfig::LoadConfig(InputClass type) break; } - IniFile game_ini = SConfig::GetInstance().LoadGameIni(); - IniFile::Section* control_section = game_ini.GetOrCreateSection("Controls"); + Common::IniFile game_ini = SConfig::GetInstance().LoadGameIni(); + auto* control_section = game_ini.GetOrCreateSection("Controls"); for (int i = 0; i < 4; i++) { @@ -95,7 +95,7 @@ bool InputConfig::LoadConfig(InputClass type) std::vector controller_names; for (auto& controller : m_controllers) { - IniFile::Section config; + Common::IniFile::Section config; // Load settings from ini if (useProfile[n]) { @@ -146,7 +146,7 @@ void InputConfig::SaveConfig() { std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + m_ini_name + ".ini"; - IniFile inifile; + Common::IniFile inifile; inifile.Load(ini_filename); std::vector controller_names; @@ -212,7 +212,7 @@ bool InputConfig::IsControllerControlledByGamepadDevice(int index) const controller.name == "Keyboard Mouse")); // Windows Keyboard/Mouse } -void InputConfig::GenerateControllerTextures(const IniFile& file) +void InputConfig::GenerateControllerTextures(const Common::IniFile& file) { std::vector controller_names; for (auto& controller : m_controllers) diff --git a/Source/Core/InputCommon/InputConfig.h b/Source/Core/InputCommon/InputConfig.h index 2c3f290576..a0d0203df6 100644 --- a/Source/Core/InputCommon/InputConfig.h +++ b/Source/Core/InputCommon/InputConfig.h @@ -11,6 +11,11 @@ #include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/DynamicInputTextureManager.h" +namespace Common +{ +class IniFile; +} + namespace ControllerEmu { class EmulatedController; @@ -53,7 +58,7 @@ public: void RegisterHotplugCallback(); void UnregisterHotplugCallback(); - void GenerateControllerTextures(const IniFile& file); + void GenerateControllerTextures(const Common::IniFile& file); private: ControllerInterface::HotplugCallbackHandle m_hotplug_callback_handle; diff --git a/Source/Core/InputCommon/InputProfile.cpp b/Source/Core/InputCommon/InputProfile.cpp index 492b45975e..81d04cf75a 100644 --- a/Source/Core/InputCommon/InputProfile.cpp +++ b/Source/Core/InputCommon/InputProfile.cpp @@ -78,7 +78,7 @@ void ProfileCycler::UpdateToProfile(const std::string& profile_filename, std::string base; SplitPath(profile_filename, nullptr, &base, nullptr); - IniFile ini_file; + Common::IniFile ini_file; if (ini_file.Load(profile_filename)) { Core::DisplayMessage("Loading input profile '" + base + "' for device '" + @@ -180,8 +180,8 @@ void ProfileCycler::CycleProfileForGame(CycleDirection cycle_direction, std::string ProfileCycler::GetWiimoteInputProfilesForGame(int controller_index) { - IniFile game_ini = SConfig::GetInstance().LoadGameIni(); - const IniFile::Section* const control_section = game_ini.GetOrCreateSection("Controls"); + Common::IniFile game_ini = SConfig::GetInstance().LoadGameIni(); + const auto* const control_section = game_ini.GetOrCreateSection("Controls"); std::string result; control_section->Get(fmt::format("WiimoteProfile{}", controller_index + 1), &result); diff --git a/Source/Core/UICommon/ResourcePack/Manager.cpp b/Source/Core/UICommon/ResourcePack/Manager.cpp index 2d1cf128ec..8d5e934c55 100644 --- a/Source/Core/UICommon/ResourcePack/Manager.cpp +++ b/Source/Core/UICommon/ResourcePack/Manager.cpp @@ -17,11 +17,11 @@ namespace std::vector packs; std::string packs_path; -IniFile GetPackConfig() +Common::IniFile GetPackConfig() { packs_path = File::GetUserPath(D_RESOURCEPACK_IDX) + "/Packs.ini"; - IniFile file; + Common::IniFile file; file.Load(packs_path); return file; @@ -34,7 +34,7 @@ bool Init() const std::vector pack_list = Common::DoFileSearch({File::GetUserPath(D_RESOURCEPACK_IDX)}, {".zip"}); - IniFile file = GetPackConfig(); + Common::IniFile file = GetPackConfig(); auto* order = file.GetOrCreateSection("Order"); @@ -123,7 +123,7 @@ ResourcePack* Add(const std::string& path, int offset) if (!pack.IsValid()) return nullptr; - IniFile file = GetPackConfig(); + Common::IniFile file = GetPackConfig(); auto* order = file.GetOrCreateSection("Order"); @@ -150,7 +150,7 @@ bool Remove(ResourcePack& pack) if (pack_iterator == packs.end()) return false; - IniFile file = GetPackConfig(); + Common::IniFile file = GetPackConfig(); auto* order = file.GetOrCreateSection("Order"); @@ -170,7 +170,7 @@ bool Remove(ResourcePack& pack) void SetInstalled(const ResourcePack& pack, bool installed) { - IniFile file = GetPackConfig(); + Common::IniFile file = GetPackConfig(); auto* install = file.GetOrCreateSection("Installed"); @@ -184,7 +184,7 @@ void SetInstalled(const ResourcePack& pack, bool installed) bool IsInstalled(const ResourcePack& pack) { - IniFile file = GetPackConfig(); + Common::IniFile file = GetPackConfig(); auto* install = file.GetOrCreateSection("Installed"); diff --git a/Source/Core/VideoCommon/PostProcessing.cpp b/Source/Core/VideoCommon/PostProcessing.cpp index 7f4faed582..601d340b0b 100644 --- a/Source/Core/VideoCommon/PostProcessing.cpp +++ b/Source/Core/VideoCommon/PostProcessing.cpp @@ -151,7 +151,7 @@ void PostProcessingConfiguration::LoadOptions(const std::string& code) if (current_strings) { std::string key, value; - IniFile::ParseLine(line, &key, &value); + Common::IniFile::ParseLine(line, &key, &value); if (!(key.empty() && value.empty())) current_strings->m_options.emplace_back(key, value); @@ -238,7 +238,7 @@ void PostProcessingConfiguration::LoadOptions(const std::string& code) void PostProcessingConfiguration::LoadOptionsConfiguration() { - IniFile ini; + Common::IniFile ini; ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); std::string section = m_current_shader + "-options"; @@ -272,7 +272,7 @@ void PostProcessingConfiguration::LoadOptionsConfiguration() void PostProcessingConfiguration::SaveOptionsConfiguration() { - IniFile ini; + Common::IniFile ini; ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); std::string section = m_current_shader + "-options";