From d73a6ea3b7fc95df1bee9cc51d507edd908e5326 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 6 Feb 2015 19:28:43 +0100 Subject: [PATCH] Move some BootManager game INI code to CoreParameter --- Source/Core/Core/BootManager.cpp | 11 +----- Source/Core/Core/CoreParameter.cpp | 36 +++++++++++-------- Source/Core/Core/CoreParameter.h | 8 +++-- Source/Core/DolphinWX/Cheats/CheatsWindow.cpp | 7 ++-- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 34b2ca8d56..d6f92bfafb 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -96,16 +96,7 @@ bool BootCore(const std::string& _rFilename) return false; // Load game specific settings - std::string unique_id = StartUp.GetUniqueID(); - std::string revision_specific = StartUp.m_strRevisionSpecificUniqueID; - StartUp.m_strGameIniDefault = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + unique_id + ".ini"; - if (revision_specific != "") - StartUp.m_strGameIniDefaultRevisionSpecific = File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + revision_specific + ".ini"; - else - StartUp.m_strGameIniDefaultRevisionSpecific = ""; - StartUp.m_strGameIniLocal = File::GetUserPath(D_GAMESETTINGS_IDX) + unique_id + ".ini"; - - if (unique_id.size() == 6) + if (StartUp.GetUniqueID().size() == 6) { IniFile game_ini = StartUp.LoadGameIni(); diff --git a/Source/Core/Core/CoreParameter.cpp b/Source/Core/Core/CoreParameter.cpp index c5234359f8..ff2d5b88bd 100644 --- a/Source/Core/Core/CoreParameter.cpp +++ b/Source/Core/Core/CoreParameter.cpp @@ -375,28 +375,36 @@ void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::stri } } -IniFile SCoreStartupParameter::LoadGameIni() const -{ - IniFile game_ini; - game_ini.Load(m_strGameIniDefault); - if (m_strGameIniDefaultRevisionSpecific != "") - game_ini.Load(m_strGameIniDefaultRevisionSpecific, true); - game_ini.Load(m_strGameIniLocal, true); - return game_ini; -} - IniFile SCoreStartupParameter::LoadDefaultGameIni() const { IniFile game_ini; - game_ini.Load(m_strGameIniDefault); - if (m_strGameIniDefaultRevisionSpecific != "") - game_ini.Load(m_strGameIniDefaultRevisionSpecific, true); + LoadDefaultGameIni(&game_ini); return game_ini; } IniFile SCoreStartupParameter::LoadLocalGameIni() const { IniFile game_ini; - game_ini.Load(m_strGameIniLocal); + LoadLocalGameIni(&game_ini); return game_ini; } + +IniFile SCoreStartupParameter::LoadGameIni() const +{ + IniFile game_ini; + LoadDefaultGameIni(&game_ini); + LoadLocalGameIni(&game_ini); + return game_ini; +} + +void SCoreStartupParameter::LoadDefaultGameIni(IniFile* game_ini) const +{ + game_ini->Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + GetUniqueID() + ".ini", true); + if (!m_strRevisionSpecificUniqueID.empty()) + game_ini->Load(File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP + m_strRevisionSpecificUniqueID + ".ini", true); +} + +void SCoreStartupParameter::LoadLocalGameIni(IniFile* game_ini) const +{ + game_ini->Load(File::GetUserPath(D_GAMESETTINGS_IDX) + GetUniqueID() + ".ini", true); +} diff --git a/Source/Core/Core/CoreParameter.h b/Source/Core/Core/CoreParameter.h index 2449d32a75..1546a10e18 100644 --- a/Source/Core/Core/CoreParameter.h +++ b/Source/Core/Core/CoreParameter.h @@ -249,9 +249,6 @@ struct SCoreStartupParameter std::string m_strUniqueID; std::string m_strRevisionSpecificUniqueID; std::string m_strName; - std::string m_strGameIniDefault; - std::string m_strGameIniDefaultRevisionSpecific; - std::string m_strGameIniLocal; std::string m_perfDir; @@ -262,7 +259,12 @@ struct SCoreStartupParameter bool AutoSetup(EBootBS2 _BootBS2); const std::string &GetUniqueID() const { return m_strUniqueID; } void CheckMemcardPath(std::string& memcardPath, std::string gameRegion, bool isSlotA); + IniFile LoadDefaultGameIni() const; IniFile LoadLocalGameIni() const; IniFile LoadGameIni() const; + +private: + void LoadDefaultGameIni(IniFile* game_ini) const; + void LoadLocalGameIni(IniFile* game_ini) const; }; diff --git a/Source/Core/DolphinWX/Cheats/CheatsWindow.cpp b/Source/Core/DolphinWX/Cheats/CheatsWindow.cpp index 8fb895b1c7..5b2854686c 100644 --- a/Source/Core/DolphinWX/Cheats/CheatsWindow.cpp +++ b/Source/Core/DolphinWX/Cheats/CheatsWindow.cpp @@ -159,9 +159,10 @@ void wxCheatsWindow::OnEvent_Close(wxCloseEvent& ev) void wxCheatsWindow::UpdateGUI() { // load code - m_gameini_default = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadDefaultGameIni(); - m_gameini_local = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadLocalGameIni(); - m_gameini_local_path = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIniLocal; + SCoreStartupParameter parameters = SConfig::GetInstance().m_LocalCoreStartupParameter; + m_gameini_default = parameters.LoadDefaultGameIni(); + m_gameini_local = parameters.LoadLocalGameIni(); + m_gameini_local_path = File::GetUserPath(D_GAMESETTINGS_IDX) + parameters.GetUniqueID() + ".ini"; Load_ARCodes(); Load_GeckoCodes();