From 41afe78a44b490a0a288450a6ffde8e08a1ebae0 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 13 May 2017 22:29:55 +0100 Subject: [PATCH] Config: Integrate --- Source/Core/Core/BootManager.cpp | 16 ++++++++++++++++ Source/Core/Core/ConfigManager.cpp | 6 ++++++ Source/Core/UICommon/UICommon.cpp | 5 +++++ Source/UnitTests/Core/CoreTimingTest.cpp | 3 +++ Source/UnitTests/Core/MMIOTest.cpp | 3 +++ 5 files changed, 33 insertions(+) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 295ac883de..21dfe22ffa 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -24,12 +24,16 @@ #include #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" +#include "Core/Config/Config.h" +#include "Core/ConfigLoaders/GameConfigLoader.h" +#include "Core/ConfigLoaders/NetPlayConfigLoader.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/EXI/EXI.h" @@ -238,6 +242,12 @@ bool BootCore(const std::string& filename, SConfig::EBootBS2 type) // Load game specific settings if (type == SConfig::BOOT_DEFAULT) { + std::string game_id = SConfig::GetInstance().GetGameID(); + u16 revision = SConfig::GetInstance().GetRevision(); + + Config::AddLoadLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision)); + Config::AddLoadLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision)); + IniFile game_ini = StartUp.LoadGameIni(); // General settings @@ -322,6 +332,7 @@ bool BootCore(const std::string& filename, SConfig::EBootBS2 type) // Movie settings if (Movie::IsPlayingInput() && Movie::IsConfigSaved()) { + Config::AddLayer(std::make_unique(Config::LayerType::Movie)); StartUp.bCPUThread = Movie::IsDualCore(); StartUp.bDSPHLE = Movie::IsDSPHLE(); StartUp.bProgressive = Movie::IsProgressive(); @@ -347,6 +358,7 @@ bool BootCore(const std::string& filename, SConfig::EBootBS2 type) if (NetPlay::IsNetPlayRunning()) { + Config::AddLoadLayer(ConfigLoaders::GenerateNetPlayConfigLoader(g_NetPlaySettings)); StartUp.bCPUThread = g_NetPlaySettings.m_CPUthread; StartUp.bEnableCheats = g_NetPlaySettings.m_EnableCheats; StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE; @@ -409,6 +421,10 @@ void Stop() void RestoreConfig() { + Config::RemoveLayer(Config::LayerType::Movie); + Config::RemoveLayer(Config::LayerType::Netplay); + Config::RemoveLayer(Config::LayerType::GlobalGame); + Config::RemoveLayer(Config::LayerType::LocalGame); SConfig::GetInstance().LoadSettingsFromSysconf(); SConfig::GetInstance().ResetRunningGameMetadata(); config_cache.RestoreConfig(&SConfig::GetInstance()); diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 0a1917791d..b2d6bb59d8 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -11,6 +11,7 @@ #include "Common/CDUtils.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" @@ -21,6 +22,7 @@ #include "Core/Analytics.h" #include "Core/Boot/Boot.h" #include "Core/Boot/Boot_DOL.h" +#include "Core/Config/Config.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/FifoPlayer/FifoDataFile.h" @@ -87,6 +89,8 @@ void SConfig::SaveSettings() SaveUSBPassthroughSettings(ini); ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX)); + + Config::Save(); } namespace @@ -395,6 +399,8 @@ void SConfig::SaveSettingsToSysconf() void SConfig::LoadSettings() { + Config::Load(); + INFO_LOG(BOOT, "Loading Settings from %s", File::GetUserPath(F_DOLPHINCONFIG_IDX).c_str()); IniFile ini; ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index bfdbf19d12..ba4aa4a390 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -7,10 +7,12 @@ #endif #include "Common/CommonPaths.h" +#include "Common/Config/Config.h" #include "Common/FileUtil.h" #include "Common/Logging/LogManager.h" #include "Common/MsgHandler.h" +#include "Core/ConfigLoaders/BaseConfigLoader.h" #include "Core/ConfigManager.h" #include "Core/HW/Wiimote.h" @@ -26,6 +28,8 @@ namespace UICommon void Init() { LogManager::Init(); + Config::Init(); + Config::AddLoadLayer(ConfigLoaders::GenerateBaseConfigLoader()); SConfig::Init(); VideoBackendBase::PopulateList(); WiimoteReal::LoadSettings(); @@ -41,6 +45,7 @@ void Shutdown() WiimoteReal::Shutdown(); VideoBackendBase::ClearList(); SConfig::Shutdown(); + Config::Shutdown(); LogManager::Shutdown(); } diff --git a/Source/UnitTests/Core/CoreTimingTest.cpp b/Source/UnitTests/Core/CoreTimingTest.cpp index fcec99c87d..f4cac5a6b6 100644 --- a/Source/UnitTests/Core/CoreTimingTest.cpp +++ b/Source/UnitTests/Core/CoreTimingTest.cpp @@ -7,6 +7,7 @@ #include #include +#include "Core/Config/Config.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -36,6 +37,7 @@ public: ScopeInit() { Core::DeclareAsCPUThread(); + Config::Init(); SConfig::Init(); PowerPC::Init(PowerPC::CORE_INTERPRETER); CoreTiming::Init(); @@ -45,6 +47,7 @@ public: CoreTiming::Shutdown(); PowerPC::Shutdown(); SConfig::Shutdown(); + Config::Shutdown(); Core::UndeclareAsCPUThread(); } }; diff --git a/Source/UnitTests/Core/MMIOTest.cpp b/Source/UnitTests/Core/MMIOTest.cpp index fd48c786b2..f6b8cfad1e 100644 --- a/Source/UnitTests/Core/MMIOTest.cpp +++ b/Source/UnitTests/Core/MMIOTest.cpp @@ -6,6 +6,7 @@ #include #include "Common/CommonTypes.h" +#include "Core/Config/Config.h" #include "Core/HW/MMIO.h" // Tests that the UniqueID function returns a "unique enough" identifier @@ -29,6 +30,7 @@ TEST(UniqueID, UniqueEnough) TEST(IsMMIOAddress, SpecialAddresses) { + Config::Init(); SConfig::Init(); SConfig::GetInstance().bWii = true; @@ -51,6 +53,7 @@ TEST(IsMMIOAddress, SpecialAddresses) EXPECT_TRUE(MMIO::IsMMIOAddress(0x0D800F10)); // Mirror of Wii MMIOs SConfig::Shutdown(); + Config::Shutdown(); } class MappingTest : public testing::Test