Config: Use SettingsInterface for base config

This commit is contained in:
Connor McLaughlin 2021-09-22 17:38:30 +10:00 committed by Kojin
parent 6fa82da1f1
commit c1fc018449
10 changed files with 499 additions and 261 deletions

View File

@ -1037,6 +1037,7 @@ set(pcsx2GuiSources
gui/ThreadingDialogs.cpp
gui/UpdateUI.cpp
gui/wxAppWithHelpers.cpp
gui/wxSettingsInterface.cpp
)
# gui headers
@ -1082,6 +1083,7 @@ set(pcsx2GuiHeaders
gui/Saveslots.h
gui/ThreadingDialogs.h
gui/ThreadingDialogs.cpp
gui/wxSettingsInterface.cpp
)
# Warning: the declaration of the .h are mandatory in case of resources files. It will ensure the creation

View File

@ -20,7 +20,8 @@
#include "common/Path.h"
#include <string>
class IniInterface;
class SettingsInterface;
class SettingsWrapper;
enum class CDVD_SourceType : uint8_t;
@ -191,7 +192,7 @@ struct TraceLogFilters
Enabled = false;
}
void LoadSave( IniInterface& ini );
void LoadSave( SettingsWrapper& ini );
bool operator ==( const TraceLogFilters& right ) const
{
@ -230,7 +231,7 @@ struct Pcsx2Config
// Default is Disabled, with all recs enabled underneath.
ProfilerOptions() : bitset( 0xfffffffe ) {}
void LoadSave( IniInterface& conf );
void LoadSave( SettingsWrapper& wrap);
bool operator ==( const ProfilerOptions& right ) const
{
@ -275,7 +276,7 @@ struct Pcsx2Config
RecompilerOptions();
void ApplySanityCheck();
void LoadSave( IniInterface& conf );
void LoadSave( SettingsWrapper& wrap);
bool operator ==( const RecompilerOptions& right ) const
{
@ -298,7 +299,7 @@ struct Pcsx2Config
SSE_MXCSR sseVUMXCSR;
CpuOptions();
void LoadSave( IniInterface& conf );
void LoadSave( SettingsWrapper& wrap);
void ApplySanityCheck();
bool operator ==( const CpuOptions& right ) const
@ -340,7 +341,7 @@ struct Pcsx2Config
double OffsetX{0.0};
double OffsetY{0.0};
void LoadSave( IniInterface& conf );
void LoadSave( SettingsWrapper& wrap);
int GetVsync() const;
@ -393,7 +394,7 @@ struct Pcsx2Config
BITFIELD_END
GamefixOptions();
void LoadSave( IniInterface& conf );
void LoadSave( SettingsWrapper& wrap);
GamefixOptions& DisableAll();
void Set( const wxString& list, bool enabled=true );
@ -431,7 +432,7 @@ struct Pcsx2Config
u8 EECycleSkip; // EE Cycle skip factor (0, 1, 2, or 3)
SpeedhackOptions();
void LoadSave(IniInterface& conf);
void LoadSave(SettingsWrapper& conf);
SpeedhackOptions& DisableAll();
void Set(SpeedhackId id, bool enabled = true);
@ -463,7 +464,7 @@ struct Pcsx2Config
u32 MemoryViewBytesPerRow;
DebugOptions();
void LoadSave( IniInterface& conf );
void LoadSave( SettingsWrapper& wrap);
bool operator ==( const DebugOptions& right ) const
{
@ -487,7 +488,7 @@ struct Pcsx2Config
double TurboScalar{2.0};
double SlomoScalar{0.5};
void LoadSave(IniInterface& conf);
void LoadSave(SettingsWrapper& wrap);
void SanityCheck();
};
@ -516,7 +517,7 @@ struct Pcsx2Config
std::string Bios;
FilenameOptions();
void LoadSave(IniInterface& conf);
void LoadSave(SettingsWrapper& wrap);
bool operator==(const FilenameOptions& right) const
{
@ -600,13 +601,8 @@ struct Pcsx2Config
LimiterModeType LimiterMode = LimiterModeType::Nominal;
Pcsx2Config();
void LoadSave( IniInterface& ini );
void LoadSaveMemcards( IniInterface& ini );
void Load( const wxString& srcfile );
void Load( const wxInputStream& srcstream );
void Save( const wxString& dstfile );
void Save( const wxOutputStream& deststream );
void LoadSave(SettingsWrapper& wrap);
void LoadSaveMemcards(SettingsWrapper& wrap);
// TODO: Make these std::string when we remove wxFile...
wxString FullpathToBios() const;

View File

@ -17,7 +17,9 @@
#include <wx/fileconf.h>
#include "common/IniInterface.h"
#include "common/SettingsInterface.h"
#include "common/SettingsWrapper.h"
#include "common/StringUtil.h"
#include "Config.h"
#include "GS.h"
#include "CDVD/CDVDaccess.h"
@ -27,17 +29,17 @@
#include "gui/AppConfig.h"
#endif
void TraceLogFilters::LoadSave( IniInterface& ini )
void TraceLogFilters::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"TraceLog" );
SettingsWrapSection("EmuCore/TraceLog");
IniEntry( Enabled );
SettingsWrapEntry(Enabled);
// Retaining backwards compat of the trace log enablers isn't really important, and
// doing each one by hand would be murder. So let's cheat and just save it as an int:
IniEntry( EE.bitset );
IniEntry( IOP.bitset );
SettingsWrapEntry(EE.bitset);
SettingsWrapEntry(IOP.bitset);
}
const wxChar* const tbl_SpeedhackNames[] =
@ -85,29 +87,29 @@ Pcsx2Config::SpeedhackOptions& Pcsx2Config::SpeedhackOptions::DisableAll()
return *this;
}
void Pcsx2Config::SpeedhackOptions::LoadSave(IniInterface& ini)
void Pcsx2Config::SpeedhackOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path(ini, L"Speedhacks");
SettingsWrapSection("EmuCore/Speedhacks");
IniBitfield(EECycleRate);
IniBitfield(EECycleSkip);
IniBitBool(fastCDVD);
IniBitBool(IntcStat);
IniBitBool(WaitLoop);
IniBitBool(vuFlagHack);
IniBitBool(vuThread);
IniBitBool(vu1Instant);
SettingsWrapBitfield(EECycleRate);
SettingsWrapBitfield(EECycleSkip);
SettingsWrapBitBool(fastCDVD);
SettingsWrapBitBool(IntcStat);
SettingsWrapBitBool(WaitLoop);
SettingsWrapBitBool(vuFlagHack);
SettingsWrapBitBool(vuThread);
SettingsWrapBitBool(vu1Instant);
}
void Pcsx2Config::ProfilerOptions::LoadSave( IniInterface& ini )
void Pcsx2Config::ProfilerOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"Profiler" );
SettingsWrapSection("EmuCore/Profiler");
IniBitBool( Enabled );
IniBitBool( RecBlocks_EE );
IniBitBool( RecBlocks_IOP );
IniBitBool( RecBlocks_VU0 );
IniBitBool( RecBlocks_VU1 );
SettingsWrapBitBool(Enabled);
SettingsWrapBitBool(RecBlocks_EE);
SettingsWrapBitBool(RecBlocks_IOP);
SettingsWrapBitBool(RecBlocks_VU0);
SettingsWrapBitBool(RecBlocks_VU1);
}
Pcsx2Config::RecompilerOptions::RecompilerOptions()
@ -156,8 +158,10 @@ void Pcsx2Config::RecompilerOptions::ApplySanityCheck()
bool vuIsOk = true;
if( vuExtraOverflow ) vuIsOk = vuIsOk && vuOverflow;
if( vuSignOverflow ) vuIsOk = vuIsOk && vuExtraOverflow;
if (vuExtraOverflow)
vuIsOk = vuIsOk && vuOverflow;
if (vuSignOverflow)
vuIsOk = vuIsOk && vuExtraOverflow;
if (!vuIsOk)
{
@ -169,28 +173,28 @@ void Pcsx2Config::RecompilerOptions::ApplySanityCheck()
}
}
void Pcsx2Config::RecompilerOptions::LoadSave( IniInterface& ini )
void Pcsx2Config::RecompilerOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"Recompiler" );
SettingsWrapSection("EmuCore/CPU/Recompiler");
IniBitBool( EnableEE );
IniBitBool( EnableIOP );
IniBitBool( EnableEECache );
IniBitBool( EnableVU0 );
IniBitBool( EnableVU1 );
SettingsWrapBitBool(EnableEE);
SettingsWrapBitBool(EnableIOP);
SettingsWrapBitBool(EnableEECache);
SettingsWrapBitBool(EnableVU0);
SettingsWrapBitBool(EnableVU1);
IniBitBool( vuOverflow );
IniBitBool( vuExtraOverflow );
IniBitBool( vuSignOverflow );
IniBitBool( vuUnderflow );
SettingsWrapBitBool(vuOverflow);
SettingsWrapBitBool(vuExtraOverflow);
SettingsWrapBitBool(vuSignOverflow);
SettingsWrapBitBool(vuUnderflow);
IniBitBool( fpuOverflow );
IniBitBool( fpuExtraOverflow );
IniBitBool( fpuFullMode );
SettingsWrapBitBool(fpuOverflow);
SettingsWrapBitBool(fpuExtraOverflow);
SettingsWrapBitBool(fpuFullMode);
IniBitBool( StackFrameChecks );
IniBitBool( PreBlockCheckEE );
IniBitBool( PreBlockCheckIOP );
SettingsWrapBitBool(StackFrameChecks);
SettingsWrapBitBool(PreBlockCheckEE);
SettingsWrapBitBool(PreBlockCheckIOP);
}
Pcsx2Config::CpuOptions::CpuOptions()
@ -207,62 +211,62 @@ void Pcsx2Config::CpuOptions::ApplySanityCheck()
Recompiler.ApplySanityCheck();
}
void Pcsx2Config::CpuOptions::LoadSave( IniInterface& ini )
void Pcsx2Config::CpuOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"CPU" );
SettingsWrapSection("EmuCore/CPU");
IniBitBoolEx( sseMXCSR.DenormalsAreZero, "FPU.DenormalsAreZero" );
IniBitBoolEx( sseMXCSR.FlushToZero, "FPU.FlushToZero" );
IniBitfieldEx( sseMXCSR.RoundingControl, "FPU.Roundmode" );
SettingsWrapBitBoolEx(sseMXCSR.DenormalsAreZero, "FPU.DenormalsAreZero");
SettingsWrapBitBoolEx(sseMXCSR.FlushToZero, "FPU.FlushToZero");
SettingsWrapBitfieldEx(sseMXCSR.RoundingControl, "FPU.Roundmode");
IniBitBoolEx( sseVUMXCSR.DenormalsAreZero, "VU.DenormalsAreZero" );
IniBitBoolEx( sseVUMXCSR.FlushToZero, "VU.FlushToZero" );
IniBitfieldEx( sseVUMXCSR.RoundingControl, "VU.Roundmode" );
SettingsWrapBitBoolEx(sseVUMXCSR.DenormalsAreZero, "VU.DenormalsAreZero");
SettingsWrapBitBoolEx(sseVUMXCSR.FlushToZero, "VU.FlushToZero");
SettingsWrapBitfieldEx(sseVUMXCSR.RoundingControl, "VU.Roundmode");
Recompiler.LoadSave( ini );
Recompiler.LoadSave(wrap);
}
void Pcsx2Config::GSOptions::LoadSave( IniInterface& ini )
void Pcsx2Config::GSOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"GS" );
SettingsWrapSection("EmuCore/GS");
#ifdef PCSX2_DEVBUILD
IniEntry( SynchronousMTGS );
SettingsWrapEntry(SynchronousMTGS);
#endif
IniEntry( VsyncQueueSize );
SettingsWrapEntry(VsyncQueueSize);
IniEntry( FrameLimitEnable );
IniEntry( FrameSkipEnable );
ini.EnumEntry( L"VsyncEnable", VsyncEnable, NULL, VsyncEnable );
SettingsWrapEntry(FrameLimitEnable);
SettingsWrapEntry(FrameSkipEnable);
wrap.EnumEntry(CURRENT_SETTINGS_SECTION, "VsyncEnable", VsyncEnable, NULL, VsyncEnable);
IniEntry( LimitScalar );
IniEntry( FramerateNTSC );
IniEntry( FrameratePAL );
SettingsWrapEntry(LimitScalar);
SettingsWrapEntry(FramerateNTSC);
SettingsWrapEntry(FrameratePAL);
IniEntry( FramesToDraw );
IniEntry( FramesToSkip );
SettingsWrapEntry(FramesToDraw);
SettingsWrapEntry(FramesToSkip);
static const wxChar* AspectRatioNames[] =
static const char* AspectRatioNames[] =
{
L"Stretch",
L"4:3",
L"16:9",
"Stretch",
"4:3",
"16:9",
// WARNING: array must be NULL terminated to compute it size
NULL};
#ifdef PCSX2_CORE
ini.EnumEntry(L"AspectRatio", AspectRatio, AspectRatioNames, AspectRatio);
wrap.EnumEntry("AspectRatio", AspectRatio, AspectRatioNames, AspectRatio);
static const wxChar* FMVAspectRatioSwitchNames[] =
static const char* FMVAspectRatioSwitchNames[] =
{
L"Off",
L"4:3",
L"16:9",
"Off",
"4:3",
"16:9",
// WARNING: array must be NULL terminated to compute it size
NULL};
ini.EnumEntry(L"FMVAspectRatioSwitch", FMVAspectRatioSwitch, FMVAspectRatioSwitchNames, FMVAspectRatioSwitch);
wrap.EnumEntry("FMVAspectRatioSwitch", FMVAspectRatioSwitch, FMVAspectRatioSwitchNames, FMVAspectRatioSwitch);
IniEntry(Zoom);
SettingsWrapEntry(Zoom);
#endif
}
@ -273,12 +277,17 @@ int Pcsx2Config::GSOptions::GetVsync() const
// D3D only support a boolean state. OpenGL waits a number of vsync
// interrupt (negative value for late vsync).
switch (VsyncEnable) {
case VsyncMode::Adaptive: return -1;
case VsyncMode::Off: return 0;
case VsyncMode::On: return 1;
switch (VsyncEnable)
{
case VsyncMode::Adaptive:
return -1;
case VsyncMode::Off:
return 0;
case VsyncMode::On:
return 1;
default: return 0;
default:
return 0;
}
}
@ -334,9 +343,11 @@ void Pcsx2Config::GamefixOptions::Set( const wxString& list, bool enabled )
GamefixId i;
for (i = GamefixId_FIRST; i < pxEnumEnd; ++i)
{
if( token.CmpNoCase( EnumToString(i) ) == 0 ) break;
if (token.CmpNoCase(EnumToString(i)) == 0)
break;
}
if( i < pxEnumEnd ) Set( i );
if (i < pxEnumEnd)
Set(i);
}
}
@ -389,25 +400,25 @@ bool Pcsx2Config::GamefixOptions::Get( GamefixId id ) const
return false; // unreachable, but we still need to suppress warnings >_<
}
void Pcsx2Config::GamefixOptions::LoadSave( IniInterface& ini )
void Pcsx2Config::GamefixOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"Gamefixes" );
SettingsWrapSection("EmuCore/Gamefixes");
IniBitBool( VuAddSubHack );
IniBitBool( FpuMulHack );
IniBitBool( FpuNegDivHack );
IniBitBool( XgKickHack );
IniBitBool( EETimingHack );
IniBitBool( SkipMPEGHack );
IniBitBool( OPHFlagHack );
IniBitBool( DMABusyHack );
IniBitBool( VIFFIFOHack );
IniBitBool( VIF1StallHack );
IniBitBool( GIFFIFOHack );
IniBitBool( GoemonTlbHack );
IniBitBool( IbitHack );
IniBitBool( VUKickstartHack );
IniBitBool( VUOverflowHack );
SettingsWrapBitBool( VuAddSubHack );
SettingsWrapBitBool( FpuMulHack );
SettingsWrapBitBool( FpuNegDivHack );
SettingsWrapBitBool( XgKickHack );
SettingsWrapBitBool( EETimingHack );
SettingsWrapBitBool( SkipMPEGHack );
SettingsWrapBitBool( OPHFlagHack );
SettingsWrapBitBool( DMABusyHack );
SettingsWrapBitBool( VIFFIFOHack );
SettingsWrapBitBool( VIF1StallHack );
SettingsWrapBitBool( GIFFIFOHack );
SettingsWrapBitBool( GoemonTlbHack );
SettingsWrapBitBool( IbitHack );
SettingsWrapBitBool( VUKickstartHack );
SettingsWrapBitBool( VUOverflowHack );
}
@ -422,33 +433,32 @@ Pcsx2Config::DebugOptions::DebugOptions()
MemoryViewBytesPerRow = 16;
}
void Pcsx2Config::DebugOptions::LoadSave( IniInterface& ini )
void Pcsx2Config::DebugOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"Debugger" );
SettingsWrapSection("EmuCore/Debugger");
IniBitBool( ShowDebuggerOnStart );
IniBitBool( AlignMemoryWindowStart );
IniBitfield( FontWidth );
IniBitfield( FontHeight );
IniBitfield( WindowWidth );
IniBitfield( WindowHeight );
IniBitfield( MemoryViewBytesPerRow );
SettingsWrapBitBool(ShowDebuggerOnStart);
SettingsWrapBitBool(AlignMemoryWindowStart);
SettingsWrapBitfield(FontWidth);
SettingsWrapBitfield(FontHeight);
SettingsWrapBitfield(WindowWidth);
SettingsWrapBitfield(WindowHeight);
SettingsWrapBitfield(MemoryViewBytesPerRow);
}
Pcsx2Config::FilenameOptions::FilenameOptions()
{
}
void Pcsx2Config::FilenameOptions::LoadSave(IniInterface& ini)
void Pcsx2Config::FilenameOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path(ini, L"Filenames");
SettingsWrapSection("Filenames");
ini.Entry(L"BIOS", Bios, Bios);
wrap.Entry(CURRENT_SETTINGS_SECTION, "BIOS", Bios, Bios);
}
Pcsx2Config::FolderOptions::FolderOptions()
{
}
void Pcsx2Config::FramerateOptions::SanityCheck()
@ -460,16 +470,16 @@ void Pcsx2Config::FramerateOptions::SanityCheck()
SlomoScalar = std::clamp(SlomoScalar, 0.05, 10.0);
}
void Pcsx2Config::FramerateOptions::LoadSave(IniInterface& ini)
void Pcsx2Config::FramerateOptions::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path(ini, L"Framerate");
SettingsWrapSection("Framerate");
IniEntry(NominalScalar);
IniEntry(TurboScalar);
IniEntry(SlomoScalar);
SettingsWrapEntry(NominalScalar);
SettingsWrapEntry(TurboScalar);
SettingsWrapEntry(SlomoScalar);
IniEntry(SkipOnLimit);
IniEntry(SkipOnTurbo);
SettingsWrapEntry(SkipOnLimit);
SettingsWrapEntry(SkipOnTurbo);
}
Pcsx2Config::Pcsx2Config()
@ -500,72 +510,68 @@ Pcsx2Config::Pcsx2Config()
CdvdSource = CDVD_SourceType::Iso;
}
void Pcsx2Config::LoadSave( IniInterface& ini )
void Pcsx2Config::LoadSave(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"EmuCore" );
SettingsWrapSection("EmuCore");
IniBitBool( CdvdVerboseReads );
IniBitBool( CdvdDumpBlocks );
IniBitBool( CdvdShareWrite );
IniBitBool( EnablePatches );
IniBitBool( EnableCheats );
IniBitBool( EnableIPC );
IniBitBool( EnableWideScreenPatches );
SettingsWrapBitBool(CdvdVerboseReads);
SettingsWrapBitBool(CdvdDumpBlocks);
SettingsWrapBitBool(CdvdShareWrite);
SettingsWrapBitBool(EnablePatches);
SettingsWrapBitBool(EnableCheats);
SettingsWrapBitBool(EnableIPC);
SettingsWrapBitBool(EnableWideScreenPatches);
#ifndef DISABLE_RECORDING
IniBitBool( EnableRecordingTools );
SettingsWrapBitBool(EnableRecordingTools);
#endif
IniBitBool( ConsoleToStdio );
IniBitBool( HostFs );
SettingsWrapBitBool(ConsoleToStdio);
SettingsWrapBitBool(HostFs);
IniBitBool( BackupSavestate );
IniBitBool( McdEnableEjection );
IniBitBool( McdFolderAutoManage );
IniBitBool( MultitapPort0_Enabled );
IniBitBool( MultitapPort1_Enabled );
SettingsWrapBitBool(BackupSavestate);
SettingsWrapBitBool(McdEnableEjection);
SettingsWrapBitBool(McdFolderAutoManage);
SettingsWrapBitBool(MultitapPort0_Enabled);
SettingsWrapBitBool(MultitapPort1_Enabled);
// Process various sub-components:
Speedhacks .LoadSave( ini );
Cpu .LoadSave( ini );
GS .LoadSave( ini );
Gamefixes .LoadSave( ini );
Profiler .LoadSave( ini );
Speedhacks.LoadSave(wrap);
Cpu.LoadSave(wrap);
GS.LoadSave(wrap);
Gamefixes.LoadSave(wrap);
Profiler.LoadSave(wrap);
Debugger .LoadSave( ini );
Trace .LoadSave( ini );
Debugger.LoadSave(wrap);
Trace.LoadSave(wrap);
IniEntry(GzipIsoIndexTemplate);
SettingsWrapEntry(GzipIsoIndexTemplate);
// For now, this in the derived config for backwards ini compatibility.
#ifdef PCSX2_CORE
BaseFilenames.LoadSave(ini);
Framerate.LoadSave(ini);
LoadSaveMemcards(ini);
BaseFilenames.LoadSave(wrap);
Framerate.LoadSave(wrap);
LoadSaveMemcards(wrap);
IniEntry(GzipIsoIndexTemplate);
SettingsWrapEntry(GzipIsoIndexTemplate);
#ifdef __WXMSW__
IniEntry(McdCompressNTFS);
SettingsWrapEntry(McdCompressNTFS);
#endif
#endif
if (ini.IsLoading())
if (wrap.IsLoading())
{
CurrentAspectRatio = GS.AspectRatio;
}
ini.Flush();
}
void Pcsx2Config::LoadSaveMemcards( IniInterface& ini )
void Pcsx2Config::LoadSaveMemcards(SettingsWrapper& wrap)
{
ScopedIniGroup path( ini, L"MemoryCards" );
for (uint slot = 0; slot < 2; ++slot)
{
ini.Entry( pxsFmt( L"Slot%u_Enable", slot+1 ),
wrap.Entry("MemoryCards", StringUtil::StdStringFromFormat("Slot%u_Enable", slot + 1).c_str(),
Mcd[slot].Enabled, Mcd[slot].Enabled);
ini.Entry( pxsFmt( L"Slot%u_Filename", slot+1 ),
wrap.Entry("MemoryCards", StringUtil::StdStringFromFormat("Slot%u_Filename", slot + 1).c_str(),
Mcd[slot].Filename, Mcd[slot].Filename);
}
@ -574,9 +580,9 @@ void Pcsx2Config::LoadSaveMemcards( IniInterface& ini )
int mtport = FileMcd_GetMtapPort(slot) + 1;
int mtslot = FileMcd_GetMtapSlot(slot) + 1;
ini.Entry( pxsFmt( L"Multitap%u_Slot%u_Enable", mtport, mtslot ),
wrap.Entry("MemoryCards", StringUtil::StdStringFromFormat("Multitap%u_Slot%u_Enable", mtport, mtslot).c_str(),
Mcd[slot].Enabled, Mcd[slot].Enabled);
ini.Entry( pxsFmt( L"Multitap%u_Slot%u_Filename", mtport, mtslot ),
wrap.Entry("MemoryCards", StringUtil::StdStringFromFormat("Multitap%u_Slot%u_Filename", mtport, mtslot).c_str(),
Mcd[slot].Filename, Mcd[slot].Filename);
}
}
@ -587,24 +593,6 @@ bool Pcsx2Config::MultitapEnabled( uint port ) const
return (port == 0) ? MultitapPort0_Enabled : MultitapPort1_Enabled;
}
void Pcsx2Config::Load( const wxString& srcfile )
{
//m_IsLoaded = true;
wxFileConfig cfg( srcfile );
IniLoader loader( cfg );
LoadSave( loader );
}
void Pcsx2Config::Save( const wxString& dstfile )
{
//if( !m_IsLoaded ) return;
wxFileConfig cfg( dstfile );
IniSaver saver( cfg );
LoadSave( saver );
}
wxString Pcsx2Config::FullpathToBios() const
{
return Path::Combine(Folders.Bios, wxString(BaseFilenames.Bios));

View File

@ -18,6 +18,8 @@
#include "MainFrame.h"
#include "common/IniInterface.h"
#include "common/SettingsWrapper.h"
#include "wxSettingsInterface.h"
#include <wx/stdpaths.h>
#include "DebugTools/Debug.h"
@ -549,29 +551,29 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini )
}
// ------------------------------------------------------------------------
void AppConfig::LoadSave( IniInterface& ini )
void AppConfig::LoadSave(IniInterface& ini, SettingsWrapper& wrap)
{
// do all the wx stuff first so it doesn't screw with the wrapper's path
LoadSaveRootItems( ini );
EmuOptions.LoadSaveMemcards( ini );
// Process various sub-components:
ProgLogBox.LoadSave(ini, L"ProgramLog");
Folders.LoadSave(ini);
// sync the EmuOptions folders with what we loaded. what a mess this is....
if (ini.IsLoading())
EmuOptions.Folders = EmuConfig.Folders;
EmuOptions.BaseFilenames.LoadSave( ini );
GSWindow.LoadSave(ini);
EmuOptions.Framerate .LoadSave( ini );
#ifndef DISABLE_RECORDING
inputRecording.loadSave(ini);
#endif
AudioCapture.LoadSave(ini);
Templates.LoadSave(ini);
// Process various sub-components:
EmuOptions.LoadSaveMemcards(wrap);
EmuOptions.BaseFilenames.LoadSave(wrap);
EmuOptions.Framerate .LoadSave(wrap);
ini.Flush();
}
@ -1115,8 +1117,10 @@ static void LoadUiSettings()
ConLog_LoadSaveSettings( loader );
SysTraceLog_LoadSaveSettings( loader );
wxSettingsInterface wxsi(&loader.GetConfig());
SettingsLoadWrapper wrapper(wxsi);
g_Conf = std::make_unique<AppConfig>();
g_Conf->LoadSave( loader );
g_Conf->LoadSave( loader, wrapper );
if( !wxFile::Exists( EmuConfig.CurrentIso ) )
{
@ -1132,8 +1136,10 @@ static void LoadVmSettings()
// are regulated by the PCSX2 UI.
std::unique_ptr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
wxSettingsInterface wxsi(vmini.get());
IniLoader vmloader(vmini.get());
g_Conf->EmuOptions.LoadSave( vmloader );
SettingsLoadWrapper vmwrapper(wxsi);
g_Conf->EmuOptions.LoadSave( vmwrapper );
g_Conf->EmuOptions.GS.LimitScalar = g_Conf->EmuOptions.Framerate.NominalScalar;
if (g_Conf->EnablePresets){
@ -1161,7 +1167,9 @@ static void SaveUiSettings()
sApp.GetRecentIsoManager().Add( EmuConfig.CurrentIso );
AppIniSaver saver;
g_Conf->LoadSave( saver );
wxSettingsInterface wxsi(&saver.GetConfig());
SettingsSaveWrapper wrapper(wxsi);
g_Conf->LoadSave( saver, wrapper );
ConLog_LoadSaveSettings( saver );
SysTraceLog_LoadSaveSettings( saver );
@ -1171,8 +1179,10 @@ static void SaveUiSettings()
static void SaveVmSettings()
{
std::unique_ptr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
wxSettingsInterface wxsi(vmini.get());
IniSaver vmsaver(vmini.get());
g_Conf->EmuOptions.LoadSave( vmsaver );
SettingsSaveWrapper vmwrapper(wxsi);
g_Conf->EmuOptions.LoadSave(vmwrapper);
sApp.DispatchVmSettingsEvent( vmsaver );
}

View File

@ -26,6 +26,8 @@
#include <wx/gdicmn.h>
#include <memory>
class SettingsWrapper;
enum DocsModeType
{
// uses /home/user or /cwd for the program data. This is the default mode and is the most
@ -286,7 +288,7 @@ public:
public:
AppConfig();
void LoadSave( IniInterface& ini );
void LoadSave(IniInterface& ini, SettingsWrapper& wrap);
void LoadSaveRootItems(IniInterface& ini);
static int GetMaxPresetIndex();

View File

@ -203,7 +203,7 @@ void Panels::BiosSelectorPanel::OnEnumComplete(wxCommandEvent& evt)
if (m_EnumeratorThread.get() != enumThread || m_BiosList->size() < enumThread->Result.size())
return;
const wxFileName& currentBios = g_Conf->EmuOptions.FullpathToBios();
const wxFileName currentBios = g_Conf->EmuOptions.FullpathToBios();
m_ComboBox->Clear(); // Clear the "Enumerating BIOSes..."
for (const std::pair<wxString, u32>& result : enumThread->Result)

View File

@ -0,0 +1,172 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "wxSettingsInterface.h"
#include "common/Assertions.h"
wxSettingsInterface::wxSettingsInterface(wxConfigBase* config)
: m_config(config)
{
m_config->SetPath(wxEmptyString);
}
wxSettingsInterface::~wxSettingsInterface()
{
m_config->SetPath(wxEmptyString);
}
void wxSettingsInterface::CheckPath(const char* section) const
{
if (m_current_path.compare(section) == 0)
return;
m_current_path = section;
m_config->SetPath(wxString::Format("/%s", section));
}
bool wxSettingsInterface::Save()
{
pxFailRel("Not implemented");
return false;
}
void wxSettingsInterface::Clear()
{
pxFailRel("Not implemented");
}
bool wxSettingsInterface::GetIntValue(const char* section, const char* key, int* value) const
{
CheckPath(section);
return m_config->Read(key, value);
}
bool wxSettingsInterface::GetUIntValue(const char* section, const char* key, uint* value) const
{
CheckPath(section);
long lvalue;
if (!m_config->Read(key, &lvalue))
return false;
return static_cast<uint>(lvalue);
}
bool wxSettingsInterface::GetFloatValue(const char* section, const char* key, float* value) const
{
CheckPath(section);
return m_config->Read(key, value);
}
bool wxSettingsInterface::GetDoubleValue(const char* section, const char* key, double* value) const
{
CheckPath(section);
return m_config->Read(key, value);
}
bool wxSettingsInterface::GetBoolValue(const char* section, const char* key, bool* value) const
{
CheckPath(section);
wxString wxKey(key);
if (!m_config->HasEntry(wxKey))
return false;
wxString ret = m_config->Read(wxKey);
*value = (ret == wxT("enabled") || ret == wxT("1"));
return true;
}
bool wxSettingsInterface::GetStringValue(const char* section, const char* key, std::string* value) const
{
CheckPath(section);
wxString wxKey(key);
if (!m_config->HasEntry(wxKey))
return false;
wxString ret = m_config->Read(wxKey);
*value = ret.ToStdString();
return true;
}
void wxSettingsInterface::SetIntValue(const char* section, const char* key, int value)
{
CheckPath(section);
m_config->Write(key, value);
}
void wxSettingsInterface::SetUIntValue(const char* section, const char* key, uint value)
{
CheckPath(section);
m_config->Write(key, static_cast<unsigned int>(value));
}
void wxSettingsInterface::SetFloatValue(const char* section, const char* key, float value)
{
CheckPath(section);
m_config->Write(key, value);
}
void wxSettingsInterface::SetDoubleValue(const char* section, const char* key, double value)
{
CheckPath(section);
m_config->Write(key, value);
}
void wxSettingsInterface::SetBoolValue(const char* section, const char* key, bool value)
{
CheckPath(section);
m_config->Write(key, value ? wxT("enabled") : wxT("disabled"));
}
void wxSettingsInterface::SetStringValue(const char* section, const char* key, const char* value)
{
CheckPath(section);
m_config->Write(key, value);
}
std::vector<std::string> wxSettingsInterface::GetStringList(const char* section, const char* key)
{
pxFailRel("Not implemented");
return {};
}
void wxSettingsInterface::SetStringList(const char* section, const char* key, const std::vector<std::string>& items)
{
pxFailRel("Not implemented");
}
bool wxSettingsInterface::RemoveFromStringList(const char* section, const char* key, const char* item)
{
pxFailRel("Not implemented");
return false;
}
bool wxSettingsInterface::AddToStringList(const char* section, const char* key, const char* item)
{
return false;
}
void wxSettingsInterface::DeleteValue(const char* section, const char* key)
{
CheckPath(section);
m_config->DeleteEntry(key);
}
void wxSettingsInterface::ClearSection(const char* section)
{
pxFailRel("Not implemented");
}

View File

@ -0,0 +1,60 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <wx/confbase.h>
#include <string>
#include "common/SettingsInterface.h"
class wxSettingsInterface : public SettingsInterface
{
public:
wxSettingsInterface(wxConfigBase* config);
~wxSettingsInterface();
bool Save() override;
void Clear() override;
bool GetIntValue(const char* section, const char* key, int* value) const override;
bool GetUIntValue(const char* section, const char* key, uint* value) const override;
bool GetFloatValue(const char* section, const char* key, float* value) const override;
bool GetDoubleValue(const char* section, const char* key, double* value) const override;
bool GetBoolValue(const char* section, const char* key, bool* value) const override;
bool GetStringValue(const char* section, const char* key, std::string* value) const override;
void SetIntValue(const char* section, const char* key, int value) override;
void SetUIntValue(const char* section, const char* key, uint value) override;
void SetFloatValue(const char* section, const char* key, float value) override;
void SetDoubleValue(const char* section, const char* key, double value) override;
void SetBoolValue(const char* section, const char* key, bool value) override;
void SetStringValue(const char* section, const char* key, const char* value) override;
std::vector<std::string> GetStringList(const char* section, const char* key) override;
void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override;
bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
bool AddToStringList(const char* section, const char* key, const char* item) override;
void DeleteValue(const char* section, const char* key) override;
void ClearSection(const char* section) override;
private:
void CheckPath(const char* section) const;
wxConfigBase* m_config;
mutable wxString m_current_path;
};

View File

@ -320,6 +320,7 @@
<ClCompile Include="gui\pxRadioPanel.cpp" />
<ClCompile Include="gui\ThreadingDialogs.cpp" />
<ClCompile Include="gui\wxAppWithHelpers.cpp" />
<ClCompile Include="gui\wxSettingsInterface.cpp" />
<ClCompile Include="IopGte.cpp" />
<ClCompile Include="IPC.cpp" />
<ClCompile Include="FW.cpp" />
@ -767,6 +768,7 @@
<ClInclude Include="gui\Panels\MemoryCardPanels.h" />
<ClInclude Include="gui\ThreadingDialogs.h" />
<ClInclude Include="gui\wxAppWithHelpers.h" />
<ClInclude Include="gui\wxSettingsInterface.h" />
<ClInclude Include="Host.h" />
<ClInclude Include="IopGte.h" />
<ClInclude Include="IPC.h" />

View File

@ -1661,6 +1661,9 @@
<ClCompile Include="MemoryCardFolder.cpp">
<Filter>System\Ps2\Iop</Filter>
</ClCompile>
<ClCompile Include="gui\wxSettingsInterface.cpp">
<Filter>AppHost</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Patch.h">
@ -2761,6 +2764,9 @@
<ClInclude Include="Host.h">
<Filter>System\Include</Filter>
</ClInclude>
<ClInclude Include="gui\wxSettingsInterface.h">
<Filter>AppHost</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="windows\wxResources.rc">