From f99ca6f4f6f223ce3f2f0bfb56dd911bfcc015a2 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Sun, 21 Nov 2010 12:35:59 +0000 Subject: [PATCH] New option to backup the old, existing savestate when creating a new one. Hopefully not too buggy :p git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4042 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Config.h | 2 +- pcsx2/Pcsx2Config.cpp | 1 + pcsx2/gui/Dialogs/McdConfigDialog.cpp | 20 ++++++++++++++------ pcsx2/gui/Panels/MemoryCardPanels.h | 1 + pcsx2/gui/SysState.cpp | 9 +++++++++ 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/pcsx2/Config.h b/pcsx2/Config.h index 2ae5623b3a..87de792d71 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -400,7 +400,7 @@ struct Pcsx2Config // when enabled uses BOOT2 injection, skipping sony bios splashes UseBOOT2Injection :1, - + BackupSavestate :1, // enables simulated ejection of memory cards when loading savestates McdEnableEjection :1, diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 80c2e5aaad..91e4054d37 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -374,6 +374,7 @@ void Pcsx2Config::LoadSave( IniInterface& ini ) IniBitBool( ConsoleToStdio ); IniBitBool( HostFs ); + IniBitBool( BackupSavestate ); IniBitBool( McdEnableEjection ); IniBitBool( MultitapPort0_Enabled ); IniBitBool( MultitapPort1_Enabled ); diff --git a/pcsx2/gui/Dialogs/McdConfigDialog.cpp b/pcsx2/gui/Dialogs/McdConfigDialog.cpp index 3d584b519c..4603dc1e44 100644 --- a/pcsx2/gui/Dialogs/McdConfigDialog.cpp +++ b/pcsx2/gui/Dialogs/McdConfigDialog.cpp @@ -44,6 +44,8 @@ Panels::McdConfigPanel_Toggles::McdConfigPanel_Toggles(wxWindow *parent) ) ); + m_check_SavestateBackup = new pxCheckBox( this, pxsFmt(_("Backup existing Savestate when creating a new one")) ); + for( uint i=0; i<2; ++i ) { m_check_Multitap[i] = new pxCheckBox( this, pxsFmt(_("Enable Multitap on Port %u"), i+1) ); @@ -60,23 +62,29 @@ Panels::McdConfigPanel_Toggles::McdConfigPanel_Toggles(wxWindow *parent) *this += 4; + *this += m_check_SavestateBackup; + + *this += 4; + *this += m_check_Ejection; } void Panels::McdConfigPanel_Toggles::Apply() { - g_Conf->EmuOptions.MultitapPort0_Enabled = m_check_Multitap[0]->GetValue(); - g_Conf->EmuOptions.MultitapPort1_Enabled = m_check_Multitap[1]->GetValue(); + g_Conf->EmuOptions.MultitapPort0_Enabled = m_check_Multitap[0]->GetValue(); + g_Conf->EmuOptions.MultitapPort1_Enabled = m_check_Multitap[1]->GetValue(); - g_Conf->EmuOptions.McdEnableEjection = m_check_Ejection->GetValue(); + g_Conf->EmuOptions.BackupSavestate = m_check_SavestateBackup->GetValue(); + g_Conf->EmuOptions.McdEnableEjection = m_check_Ejection->GetValue(); } void Panels::McdConfigPanel_Toggles::AppStatusEvent_OnSettingsApplied() { - m_check_Multitap[0] ->SetValue( g_Conf->EmuOptions.MultitapPort0_Enabled ); - m_check_Multitap[1] ->SetValue( g_Conf->EmuOptions.MultitapPort1_Enabled ); + m_check_Multitap[0] ->SetValue( g_Conf->EmuOptions.MultitapPort0_Enabled ); + m_check_Multitap[1] ->SetValue( g_Conf->EmuOptions.MultitapPort1_Enabled ); - m_check_Ejection ->SetValue( g_Conf->EmuOptions.McdEnableEjection ); + m_check_SavestateBackup ->SetValue( g_Conf->EmuOptions.BackupSavestate ); + m_check_Ejection ->SetValue( g_Conf->EmuOptions.McdEnableEjection ); } diff --git a/pcsx2/gui/Panels/MemoryCardPanels.h b/pcsx2/gui/Panels/MemoryCardPanels.h index 99db26c556..9bed7079a0 100644 --- a/pcsx2/gui/Panels/MemoryCardPanels.h +++ b/pcsx2/gui/Panels/MemoryCardPanels.h @@ -231,6 +231,7 @@ namespace Panels protected: pxCheckBox* m_check_Multitap[2]; pxCheckBox* m_check_Ejection; + pxCheckBox* m_check_SavestateBackup; public: McdConfigPanel_Toggles( wxWindow* parent ); diff --git a/pcsx2/gui/SysState.cpp b/pcsx2/gui/SysState.cpp index 5059dbdc9f..f657c411e2 100644 --- a/pcsx2/gui/SysState.cpp +++ b/pcsx2/gui/SysState.cpp @@ -336,6 +336,15 @@ void StateCopy_SaveToSlot( uint num ) { const wxString file( SaveStateBase::GetFilename( num ) ); + // Backup old Savestate if one exists. + if( wxFileExists( file ) && EmuConfig.BackupSavestate ) + { + const wxString copy( SaveStateBase::GetFilename( num ) + pxsFmt( L".backup") ); + + Console.Indent().WriteLn( Color_StrongGreen, L"Backing up existing state in slot %d.", num); + wxCopyFile( file, copy ); + } + Console.WriteLn( Color_StrongGreen, "Saving savestate to slot %d...", num ); Console.Indent().WriteLn( Color_StrongGreen, L"filename: %s", file.c_str() );