Don't read/store settings directly from/to SYSCONF

Instead of directly reading/storing settings from/to the SYSCONF, we
now store Wii settings to Dolphin's own configuration, and apply them
on boot. This prevents issues with settings not being saved, being
overridden and lost (if the user opens a dialog that writes to the
SYSCONF while a game is running).

This also fixes restoring settings from the config cache after a
graceful shutdown; for some reason, settings were only restored
after a normal shutdown.

Fixes issue 9825 and 9826
This commit is contained in:
Léo Lam
2016-10-07 21:57:07 +02:00
parent 39fd6dcd5b
commit afd2f58e29
17 changed files with 175 additions and 129 deletions

View File

@ -26,7 +26,8 @@
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Common/SysConf.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Core/BootManager.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
@ -35,7 +36,6 @@
#include "Core/HW/Sram.h"
#include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "Core/Host.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h"
#include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "VideoCommon/VideoBackendBase.h"
@ -153,9 +153,6 @@ void ConfigCache::RestoreConfig(SConfig* config)
config->SelectedLanguage = iSelectedLanguage;
config->iCPUCore = iCPUCore;
config->m_SYSCONF->SetData("IPL.PGS", bProgressive);
config->m_SYSCONF->SetData("IPL.E60", bPAL60);
// Only change these back if they were actually set by game ini, since they can be changed while a
// game is running.
if (bSetVolume)
@ -294,9 +291,6 @@ bool BootCore(const std::string& _rFilename)
// Wii settings
if (StartUp.bWii)
{
// Flush possible changes to SYSCONF to file
SConfig::GetInstance().m_SYSCONF->Save();
int source;
for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
{
@ -385,19 +379,8 @@ bool BootCore(const std::string& _rFilename)
StartUp.bPAL60 = false;
}
SConfig::GetInstance().m_SYSCONF->SetData("IPL.PGS", StartUp.bProgressive);
SConfig::GetInstance().m_SYSCONF->SetData("IPL.E60", StartUp.bPAL60);
if (StartUp.bWii)
{
// Disable WiiConnect24's standby mode. If it is enabled, it prevents us from receiving
// shutdown commands in the State Transition Manager (STM).
// TODO: remove this if and once Dolphin supports WC24 standby mode.
SConfig::GetInstance().m_SYSCONF->SetData<u8>("IPL.IDL", 0x00);
NOTICE_LOG(BOOT, "Disabling WC24 'standby' (shutdown to idle) to avoid hanging on shutdown");
RestoreBTInfoSection();
}
SConfig::GetInstance().SaveSettingsToSysconf();
// Run the game
// Init the core
@ -413,10 +396,14 @@ bool BootCore(const std::string& _rFilename)
void Stop()
{
Core::Stop();
RestoreConfig();
}
SConfig& StartUp = SConfig::GetInstance();
StartUp.m_strUniqueID = "00000000";
config_cache.RestoreConfig(&StartUp);
void RestoreConfig()
{
SConfig::GetInstance().LoadSettingsFromSysconf();
SConfig::GetInstance().m_strUniqueID = "00000000";
config_cache.RestoreConfig(&SConfig::GetInstance());
}
} // namespace