diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 26d3e1679b..87c9a0924f 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -34,42 +34,36 @@ Pcsx2Config::SpeedhackOptions::SpeedhackOptions() : void Pcsx2Config::SpeedhackOptions::LoadSave( IniInterface& ini ) { SpeedhackOptions defaults; - ini.SetPath( L"Speedhacks" ); + IniScopedGroup path( ini, L"Speedhacks" ); IniBitfield( EECycleRate ); IniBitfield( VUCycleSteal ); IniBitBool( IopCycleRate_X2 ); IniBitBool( IntcStat ); IniBitBool( BIFC0 ); - - ini.SetPath( L".." ); } void Pcsx2Config::ProfilerOptions::LoadSave( IniInterface& ini ) { ProfilerOptions defaults; - ini.SetPath( L"Profiler" ); + IniScopedGroup path( ini, L"Profiler" ); IniBitBool( Enabled ); IniBitBool( RecBlocks_EE ); IniBitBool( RecBlocks_IOP ); IniBitBool( RecBlocks_VU0 ); IniBitBool( RecBlocks_VU1 ); - - ini.SetPath( L".." ); } void Pcsx2Config::RecompilerOptions::LoadSave( IniInterface& ini ) { RecompilerOptions defaults; - ini.SetPath( L"Recompiler" ); + IniScopedGroup path( ini, L"Recompiler" ); IniBitBool( EnableEE ); IniBitBool( EnableIOP ); IniBitBool( EnableVU0 ); IniBitBool( EnableVU1 ); - - ini.SetPath( L".." ); } Pcsx2Config::CpuOptions::CpuOptions() : @@ -84,7 +78,7 @@ Pcsx2Config::CpuOptions::CpuOptions() : void Pcsx2Config::CpuOptions::LoadSave( IniInterface& ini ) { CpuOptions defaults; - ini.SetPath( L"CPU" ); + IniScopedGroup path( ini, L"CPU" ); IniEntry( sseMXCSR ); IniEntry( sseVUMXCSR ); @@ -99,8 +93,6 @@ void Pcsx2Config::CpuOptions::LoadSave( IniInterface& ini ) IniBitBool( fpuFullMode ); Recompiler.LoadSave( ini ); - - ini.SetPath( L".." ); } Pcsx2Config::VideoOptions::VideoOptions() : @@ -118,7 +110,7 @@ Pcsx2Config::VideoOptions::VideoOptions() : void Pcsx2Config::VideoOptions::LoadSave( IniInterface& ini ) { VideoOptions defaults; - ini.SetPath( L"Video" ); + IniScopedGroup path( ini, L"Video" ); IniEntry( EnableFrameLimiting ); IniEntry( EnableFrameSkipping ); @@ -131,22 +123,18 @@ void Pcsx2Config::VideoOptions::LoadSave( IniInterface& ini ) IniEntry( FpsSkip ); IniEntry( ConsecutiveFrames ); IniEntry( ConsecutiveSkip ); - - ini.SetPath( L".." ); } void Pcsx2Config::GamefixOptions::LoadSave( IniInterface& ini ) { GamefixOptions defaults; - ini.SetPath( L"Gamefixes" ); + IniScopedGroup path( ini, L"Gamefixes" ); IniBitBool( VuAddSubHack ); IniBitBool( VuClipFlagHack ); IniBitBool( FpuCompareHack ); IniBitBool( FpuMulHack ); IniBitBool( XgKickHack ); - - ini.SetPath( L".." ); } Pcsx2Config::Pcsx2Config() : @@ -157,7 +145,7 @@ Pcsx2Config::Pcsx2Config() : void Pcsx2Config::LoadSave( IniInterface& ini ) { Pcsx2Config defaults; - ini.SetPath( L"EmuCore" ); + IniScopedGroup path( ini, L"EmuCore" ); IniBitBool( CdvdVerboseReads ); IniBitBool( CdvdDumpBlocks ); @@ -173,8 +161,7 @@ void Pcsx2Config::LoadSave( IniInterface& ini ) Video.LoadSave( ini ); Gamefixes.LoadSave( ini ); Profiler.LoadSave( ini ); - - ini.SetPath( L".." ); + ini.Flush(); } diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index ff82fb999f..aa5aba5800 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -282,6 +282,7 @@ protected: void ReadUserModeSettings(); bool TryOpenConfigCwd(); void OnMessageBox( wxCommandEvent& evt ); + void CleanupMess(); }; DECLARE_APP(Pcsx2App) diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index c4efc339cd..d980ece9b0 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -378,7 +378,14 @@ AppConfig::AppConfig() : // ------------------------------------------------------------------------ void AppConfig::LoadSaveUserMode( IniInterface& ini ) { - AppConfig defaults; + // timestamping would be useful if we want to auto-purge unused entries after + // a period of time. Dunno if it's needed. + + /*wxString timestamp_now( wxsFormat( L"%s %s", + wxDateTime::Now().FormatISODate().c_str(), wxDateTime::Now().FormatISOTime().c_str() ) + ); + + ini.GetConfig().Write( L"Timestamp", timestamp_now );*/ ini.Entry( L"UseAdminMode", UseAdminMode, false ); ini.Entry( L"SettingsPath", Folders.Settings, PathDefs::GetSettings() ); @@ -496,15 +503,13 @@ AppConfig::ConsoleLogOptions::ConsoleLogOptions() : void AppConfig::ConsoleLogOptions::LoadSave( IniInterface& ini, const wxChar* logger ) { ConsoleLogOptions defaults; - ini.SetPath( logger ); + IniScopedGroup path( ini, logger ); IniEntry( Visible ); IniEntry( AutoDock ); IniEntry( DisplayPosition ); IniEntry( DisplaySize ); IniEntry( FontSize ); - - ini.SetPath( L".." ); } void AppConfig::FolderOptions::ApplyDefaults() @@ -536,7 +541,7 @@ AppConfig::FolderOptions::FolderOptions() : void AppConfig::FolderOptions::LoadSave( IniInterface& ini ) { FolderOptions defaults; - ini.SetPath( L"Folders" ); + IniScopedGroup path( ini, L"Folders" ); if( ini.IsSaving() ) ApplyDefaults(); @@ -561,8 +566,6 @@ void AppConfig::FolderOptions::LoadSave( IniInterface& ini ) if( ini.IsLoading() ) ApplyDefaults(); - - ini.SetPath( L".." ); } // ------------------------------------------------------------------------ @@ -576,7 +579,7 @@ const wxFileName& AppConfig::FilenameOptions::operator[]( PluginsEnum_t pluginid void AppConfig::FilenameOptions::LoadSave( IniInterface& ini ) { - ini.SetPath( L"Filenames" ); + IniScopedGroup path( ini, L"Filenames" ); static const wxFileName pc( L"Please Configure" ); static const wxString g_PluginNames[] = @@ -595,8 +598,6 @@ void AppConfig::FilenameOptions::LoadSave( IniInterface& ini ) { ini.Entry( g_PluginNames[i], Plugins[i], pc ); } - - ini.SetPath( L".." ); } wxFileConfig* OpenFileConfig( const wxString& filename ) diff --git a/pcsx2/gui/IniInterface.cpp b/pcsx2/gui/IniInterface.cpp index f38e428c0b..25f21c3a44 100644 --- a/pcsx2/gui/IniInterface.cpp +++ b/pcsx2/gui/IniInterface.cpp @@ -47,6 +47,24 @@ void IniInterface::Flush() m_Config.Flush(); } +////////////////////////////////////////////////////////////////////////////////////////// +// +IniScopedGroup::IniScopedGroup( IniInterface& mommy, const wxString& group ) : + m_mom( mommy ) +{ + if( IsDevBuild ) + { + if( wxStringTokenize( group, L"/" ).Count() > 1 ) + throw Exception::InvalidArgument( "Cannot nest more than one group deep per instance of IniScopedGroup." ); + } + m_mom.SetPath( group ); +} + +IniScopedGroup::~IniScopedGroup() +{ + m_mom.SetPath( L".." ); +} + ////////////////////////////////////////////////////////////////////////////////////////// // diff --git a/pcsx2/gui/IniInterface.h b/pcsx2/gui/IniInterface.h index 7e28e9d46f..71e5695803 100644 --- a/pcsx2/gui/IniInterface.h +++ b/pcsx2/gui/IniInterface.h @@ -77,6 +77,18 @@ protected: virtual void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue )=0; }; +////////////////////////////////////////////////////////////////////////////////////////// +// +class IniScopedGroup +{ +protected: + IniInterface& m_mom; + +public: + IniScopedGroup( IniInterface& mommy, const wxString& group ); + virtual ~IniScopedGroup(); +}; + ////////////////////////////////////////////////////////////////////////////////////////// // IniLoader class // diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp index dfb89cf974..9275369bbd 100644 --- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp +++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp @@ -133,7 +133,7 @@ Panels::PluginSelectorPanel::StatusPanel::StatusPanel( wxWindow* parent ) : s_main.Add( &m_gauge, wxSizerFlags().Expand().Border( wxLEFT | wxRIGHT, 32 ) ); s_main.Add( &m_label, SizerFlags::StdExpand() ); - SetSizer( &s_main ); + SetSizerAndFit( &s_main ); } void Panels::PluginSelectorPanel::StatusPanel::SetGaugeLength( int len ) diff --git a/pcsx2/gui/main.cpp b/pcsx2/gui/main.cpp index 860c5ccee2..bb44001f3b 100644 --- a/pcsx2/gui/main.cpp +++ b/pcsx2/gui/main.cpp @@ -81,23 +81,19 @@ void Pcsx2App::ReadUserModeSettings() wxString cwd( wxGetCwd() ); u32 hashres = HashTools::Hash( (char*)cwd.c_str(), cwd.Length() ); -#ifdef __WXMSW__ - if( true ) // fixme!! -#else wxDirName usrlocaldir( wxStandardPaths::Get().GetUserLocalDataDir() ); if( !usrlocaldir.Exists() ) usrlocaldir.Mkdir(); - wxFileName usermodefile( wxsFormat( L"%08x.usermode.ini", hashres ) ); + wxFileName usermodefile( FilenameDefs::GetUsermodeConfig() ); usermodefile.SetPath( usrlocaldir.ToString() ); wxScopedPtr conf_usermode( OpenFileConfig( usermodefile.GetFullPath() ) ); - if( !wxFile::Exists( usermodefile.GetFullPath() ) ) -#endif + wxString groupname( wxsFormat( L"CWD.%08x", hashres ) ); + if( !conf_usermode->HasGroup( groupname ) ) { // first time startup, so give the user the choice of user mode: - //if( Dialogs::PickUserModeDialog( NULL ).ShowModal() == wxID_CANCEL ) FirstTimeWizard wiz( NULL ); if( !wiz.RunWizard( wiz.GetFirstPage() ) ) throw Exception::StartupAborted( L"Startup aborted: User canceled FirstTime Wizard." ); @@ -156,6 +152,13 @@ bool Pcsx2App::OnCmdLineParsed(wxCmdLineParser& parser) return true; } +void Pcsx2App::CleanupMess() +{ + safe_delete( g_RecentIsoList ); + safe_delete( m_Bitmap_Logo ); + safe_delete( g_Conf ); +} + // ------------------------------------------------------------------------ bool Pcsx2App::OnInit() { @@ -197,6 +200,8 @@ bool Pcsx2App::OnInit() } catch( Exception::StartupAborted& ) { + // Note: wx does not call OnExit() when returning false. + CleanupMess(); return false; } @@ -220,10 +225,10 @@ bool Pcsx2App::PrepForExit() int Pcsx2App::OnExit() { - g_Conf->Save(); - safe_delete( g_RecentIsoList ); - safe_delete( m_Bitmap_Logo ); - safe_delete( g_Conf ); + if( g_Conf != NULL ) + g_Conf->Save(); + + CleanupMess(); return wxApp::OnExit(); } diff --git a/pcsx2_suite_2008.sln b/pcsx2_suite_2008.sln index 2c8ec5f6e8..c161ce58ef 100644 --- a/pcsx2_suite_2008.sln +++ b/pcsx2_suite_2008.sln @@ -358,24 +358,19 @@ Global {6F3C4136-5801-4EBC-AC6E-37DF6FAB150A}.Release|x64.ActiveCfg = Release|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Debug|Win32.ActiveCfg = Debug|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Debug|Win32.Build.0 = Debug|Win32 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Debug|x64.ActiveCfg = Debug|x64 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Debug|x64.Build.0 = Debug|x64 + {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Debug|x64.ActiveCfg = Debug|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Devel|Win32.ActiveCfg = Release|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Devel|Win32.Build.0 = Release|Win32 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Devel|x64.ActiveCfg = Debug SSE4|x64 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Devel|x64.Build.0 = Debug SSE4|x64 + {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Devel|x64.ActiveCfg = Debug SSE4|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE2|Win32.ActiveCfg = Release|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE2|Win32.Build.0 = Release|Win32 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE2|x64.ActiveCfg = Release SSE2|x64 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE2|x64.Build.0 = Release SSE2|x64 + {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE2|x64.ActiveCfg = Release SSE2|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE4|Win32.ActiveCfg = Release|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE4|Win32.Build.0 = Release|Win32 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE4|x64.ActiveCfg = Release SSE4|x64 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE4|x64.Build.0 = Release SSE4|x64 + {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSE4|x64.ActiveCfg = Release SSE4|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSSE3|Win32.ActiveCfg = Release|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSSE3|Win32.Build.0 = Release|Win32 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSSE3|x64.ActiveCfg = Release SSSE3|x64 - {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSSE3|x64.Build.0 = Release SSSE3|x64 + {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release SSSE3|x64.ActiveCfg = Release SSSE3|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release|Win32.ActiveCfg = Release|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release|Win32.Build.0 = Release|Win32 {FCDF5AE2-EA47-4CC6-9F20-23A0517FEBCB}.Release|x64.ActiveCfg = Release|Win32 diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index e2c99a321a..9191041263 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -355,7 +355,7 @@ void GSRenderer::VSync(int field) } else { - if(m_dump)D3DFMT_D32 + if(m_dump) { m_dump.VSync(field, !(::GetAsyncKeyState(VK_CONTROL) & 0x8000), m_regs); }