mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Config: Include SYSCONF in base layer
Settings that come from the SYSCONF are now included in Dolphin's config system as part of the base layer. They are handled in a special way compared to other settings to make sure they are only loaded from and saved to the SYSCONF (to avoid different, possibly contradicting sources of truth).
This commit is contained in:
@ -33,7 +33,10 @@
|
||||
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Core/Boot/Boot.h"
|
||||
#include "Core/Config/SYSCONFSettings.h"
|
||||
#include "Core/ConfigLoaders/BaseConfigLoader.h"
|
||||
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
||||
#include "Core/ConfigLoaders/MovieConfigLoader.h"
|
||||
#include "Core/ConfigLoaders/NetPlayConfigLoader.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
@ -83,12 +86,9 @@ private:
|
||||
bool bFastDiscSpeed;
|
||||
bool bDSPHLE;
|
||||
bool bHLE_BS2;
|
||||
bool bProgressive;
|
||||
bool bPAL60;
|
||||
int iSelectedLanguage;
|
||||
int iCPUCore;
|
||||
int Volume;
|
||||
int m_wii_language;
|
||||
float m_EmulationSpeed;
|
||||
float m_OCFactor;
|
||||
bool m_OCEnable;
|
||||
@ -116,8 +116,6 @@ void ConfigCache::SaveConfig(const SConfig& config)
|
||||
bFastDiscSpeed = config.bFastDiscSpeed;
|
||||
bDSPHLE = config.bDSPHLE;
|
||||
bHLE_BS2 = config.bHLE_BS2;
|
||||
bProgressive = config.bProgressive;
|
||||
bPAL60 = config.bPAL60;
|
||||
iSelectedLanguage = config.SelectedLanguage;
|
||||
iCPUCore = config.iCPUCore;
|
||||
Volume = config.m_Volume;
|
||||
@ -125,7 +123,6 @@ void ConfigCache::SaveConfig(const SConfig& config)
|
||||
strBackend = config.m_strVideoBackend;
|
||||
sBackend = config.sBackend;
|
||||
m_strGPUDeterminismMode = config.m_strGPUDeterminismMode;
|
||||
m_wii_language = config.m_wii_language;
|
||||
m_OCFactor = config.m_OCFactor;
|
||||
m_OCEnable = config.m_OCEnable;
|
||||
|
||||
@ -160,8 +157,6 @@ void ConfigCache::RestoreConfig(SConfig* config)
|
||||
config->bFastDiscSpeed = bFastDiscSpeed;
|
||||
config->bDSPHLE = bDSPHLE;
|
||||
config->bHLE_BS2 = bHLE_BS2;
|
||||
config->bProgressive = bProgressive;
|
||||
config->bPAL60 = bPAL60;
|
||||
config->SelectedLanguage = iSelectedLanguage;
|
||||
config->iCPUCore = iCPUCore;
|
||||
|
||||
@ -180,8 +175,6 @@ void ConfigCache::RestoreConfig(SConfig* config)
|
||||
WiimoteReal::ChangeWiimoteSource(i, iWiimoteSource[i]);
|
||||
}
|
||||
}
|
||||
|
||||
config->m_wii_language = m_wii_language;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||
@ -263,8 +256,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
|
||||
core_section->Get("GFXBackend", &StartUp.m_strVideoBackend, StartUp.m_strVideoBackend);
|
||||
core_section->Get("CPUCore", &StartUp.iCPUCore, StartUp.iCPUCore);
|
||||
core_section->Get("HLE_BS2", &StartUp.bHLE_BS2, StartUp.bHLE_BS2);
|
||||
core_section->Get("ProgressiveScan", &StartUp.bProgressive, StartUp.bProgressive);
|
||||
core_section->Get("PAL60", &StartUp.bPAL60, StartUp.bPAL60);
|
||||
core_section->Get("GameCubeLanguage", &StartUp.SelectedLanguage, StartUp.SelectedLanguage);
|
||||
if (core_section->Get("EmulationSpeed", &StartUp.m_EmulationSpeed, StartUp.m_EmulationSpeed))
|
||||
config_cache.bSetEmulationSpeed = true;
|
||||
@ -293,10 +284,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
|
||||
// Wii settings
|
||||
if (StartUp.bWii)
|
||||
{
|
||||
IniFile::Section* wii_section = game_ini.GetOrCreateSection("Wii");
|
||||
wii_section->Get("Widescreen", &StartUp.m_wii_aspect_ratio, !!StartUp.m_wii_aspect_ratio);
|
||||
wii_section->Get("Language", &StartUp.m_wii_language, StartUp.m_wii_language);
|
||||
|
||||
int source;
|
||||
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
|
||||
{
|
||||
@ -325,11 +312,8 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
|
||||
// Movie settings
|
||||
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
|
||||
{
|
||||
Config::AddLayer(std::make_unique<Config::Layer>(Config::LayerType::Movie));
|
||||
StartUp.bCPUThread = Movie::IsDualCore();
|
||||
StartUp.bDSPHLE = Movie::IsDSPHLE();
|
||||
StartUp.bProgressive = Movie::IsProgressive();
|
||||
StartUp.bPAL60 = Movie::IsPAL60();
|
||||
StartUp.bFastDiscSpeed = Movie::IsFastDiscSpeed();
|
||||
StartUp.iCPUCore = Movie::GetCPUMode();
|
||||
StartUp.bSyncGPU = Movie::IsSyncGPU();
|
||||
@ -360,8 +344,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
|
||||
StartUp.iCPUCore = g_NetPlaySettings.m_CPUcore;
|
||||
StartUp.SelectedLanguage = g_NetPlaySettings.m_SelectedLanguage;
|
||||
StartUp.bOverrideGCLanguage = g_NetPlaySettings.m_OverrideGCLanguage;
|
||||
StartUp.bProgressive = g_NetPlaySettings.m_ProgressiveScan;
|
||||
StartUp.bPAL60 = g_NetPlaySettings.m_PAL60;
|
||||
StartUp.m_DSPEnableJIT = g_NetPlaySettings.m_DSPEnableJIT;
|
||||
StartUp.m_OCEnable = g_NetPlaySettings.m_OCEnable;
|
||||
StartUp.m_OCFactor = g_NetPlaySettings.m_OCFactor;
|
||||
@ -388,12 +370,11 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
|
||||
// Some NTSC Wii games such as Doc Louis's Punch-Out!! and
|
||||
// 1942 (Virtual Console) crash if the PAL60 option is enabled
|
||||
if (StartUp.bWii && ntsc)
|
||||
{
|
||||
StartUp.bPAL60 = false;
|
||||
}
|
||||
Config::SetCurrent(Config::SYSCONF_PAL60, false);
|
||||
|
||||
// Ensure any new settings are written to the SYSCONF
|
||||
if (StartUp.bWii)
|
||||
StartUp.SaveSettingsToSysconf();
|
||||
ConfigLoaders::SaveToSYSCONF(Config::GetLayer(Config::LayerType::Meta));
|
||||
|
||||
const bool load_ipl = !StartUp.bWii && !StartUp.bHLE_BS2 &&
|
||||
std::holds_alternative<BootParameters::Disc>(boot->parameters);
|
||||
@ -411,14 +392,41 @@ void Stop()
|
||||
RestoreConfig();
|
||||
}
|
||||
|
||||
// SYSCONF can be modified during emulation by the user and internally, which makes it
|
||||
// a bad idea to just always overwrite it with the settings from the base layer.
|
||||
//
|
||||
// Conversely, we also shouldn't just ignore any changes to SYSCONF, as it may cause
|
||||
// temporary settings (from Movie, Netplay, game INIs, etc.) to stick around.
|
||||
//
|
||||
// To avoid inconveniences in most cases, we always restore only the overridden settings.
|
||||
static void RestoreSYSCONF()
|
||||
{
|
||||
// This layer contains the new SYSCONF settings (including any temporary settings).
|
||||
auto layer = std::make_unique<Config::Layer>(ConfigLoaders::GenerateBaseConfigLoader());
|
||||
for (const auto& setting : Config::SYSCONF_SETTINGS)
|
||||
{
|
||||
std::visit(
|
||||
[&](auto& info) {
|
||||
// If this setting was overridden, then we copy the base layer value back to the SYSCONF.
|
||||
// Otherwise we leave the new value in the SYSCONF.
|
||||
if (Config::GetActiveLayerForConfig(info) != Config::LayerType::Base)
|
||||
layer->Set(info, Config::GetBase(info));
|
||||
},
|
||||
setting.config_info);
|
||||
}
|
||||
// Save the SYSCONF.
|
||||
layer->Save();
|
||||
Config::AddLayer(std::move(layer));
|
||||
}
|
||||
|
||||
void RestoreConfig()
|
||||
{
|
||||
RestoreSYSCONF();
|
||||
Config::ClearCurrentRunLayer();
|
||||
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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user