From b9bd672c8955f12465c684467211eef573aa8186 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 23 May 2013 20:03:10 +0000 Subject: [PATCH] pcsx2 gui: * handle cheats and cheatsWS folder like others data folders. Note: I didn't add new gui entry but every configuration bits are here. Tell me if you want addional entry * replace folder name hardcoded in AppCoreThread with the new PathDefs::GetCheats* functions git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5640 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Patch.cpp | 10 +++++----- pcsx2/Patch.h | 2 +- pcsx2/PathDefs.h | 7 +++++++ pcsx2/gui/AppConfig.cpp | 32 ++++++++++++++++++++++++++++++++ pcsx2/gui/AppConfig.h | 8 ++++++-- pcsx2/gui/AppCoreThread.cpp | 4 ++-- 6 files changed, 53 insertions(+), 10 deletions(-) diff --git a/pcsx2/Patch.cpp b/pcsx2/Patch.cpp index faf1b57ec8..78a4d00f5d 100644 --- a/pcsx2/Patch.cpp +++ b/pcsx2/Patch.cpp @@ -171,13 +171,13 @@ void ResetCheatsCount() cheatnumber = 0; } -static int LoadCheatsFiles(const wxString& folderName, wxString& fileSpec, const wxString& friendlyName) +static int LoadCheatsFiles(const wxDirName& folderName, wxString& fileSpec, const wxString& friendlyName) { - if (!wxDir::Exists(folderName)) { - Console.WriteLn(Color_Red, L"The %s folder ('%s') is inaccessible. Skipping...", friendlyName.c_str(), folderName.c_str()); + if (!folderName.Exists()) { + Console.WriteLn(Color_Red, L"The %s folder ('%s') is inaccessible. Skipping...", friendlyName.c_str(), folderName.ToString().c_str()); return 0; } - wxDir dir(folderName); + wxDir dir(folderName.ToString()); int before = cheatnumber; wxString buffer; @@ -200,7 +200,7 @@ static int LoadCheatsFiles(const wxString& folderName, wxString& fileSpec, const // This routine loads cheats from *.pnach files // Returns number of cheats loaded // Note: Should be called after InitPatches() -int LoadCheats(wxString name, const wxString& folderName, const wxString& friendlyName) +int LoadCheats(wxString name, const wxDirName& folderName, const wxString& friendlyName) { if (!name.Length()) { Console.WriteLn(Color_Gray, "Cheats: No CRC, using 00000000 instead."); diff --git a/pcsx2/Patch.h b/pcsx2/Patch.h index a62f8692b4..1d07594e99 100644 --- a/pcsx2/Patch.h +++ b/pcsx2/Patch.h @@ -58,7 +58,7 @@ namespace PatchFunc } extern void ResetCheatsCount(); -extern int LoadCheats(wxString name, const wxString& folderName, const wxString& friendlyName); +extern int LoadCheats(wxString name, const wxDirName& folderName, const wxString& friendlyName); extern void inifile_command(bool isCheat, const wxString& cmd); extern void inifile_trim(wxString& buffer); diff --git a/pcsx2/PathDefs.h b/pcsx2/PathDefs.h index 35fe2c8eb0..61d37bcd16 100644 --- a/pcsx2/PathDefs.h +++ b/pcsx2/PathDefs.h @@ -33,6 +33,9 @@ enum FoldersEnum_t FolderId_Documents, + FolderId_Cheats, + FolderId_CheatsWS, + FolderId_COUNT }; @@ -58,6 +61,8 @@ namespace PathDefs extern wxDirName GetSettings(); extern wxDirName GetLogs(); extern wxDirName GetLangs(); + extern wxDirName GetCheats(); + extern wxDirName GetCheatsWS(); extern wxDirName Get( FoldersEnum_t folderidx ); @@ -74,6 +79,8 @@ namespace PathDefs extern const wxDirName& Logs(); extern const wxDirName& Dumps(); extern const wxDirName& Langs(); + extern const wxDirName& Cheats(); + extern const wxDirName& CheatsWS(); } } diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 47dc849a6d..60e0dcb84a 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -162,6 +162,16 @@ namespace PathDefs return GetDocuments() + wxDirName( L"bios" ); } + wxDirName GetCheats() + { + return GetDocuments() + wxDirName( L"cheats" ); + } + + wxDirName GetCheatsWS() + { + return GetDocuments() + wxDirName( L"cheats_ws" ); + } + wxDirName GetSavestates() { return GetDocuments() + Base::Savestates(); @@ -218,6 +228,8 @@ namespace PathDefs case FolderId_MemoryCards: return GetMemoryCards(); case FolderId_Logs: return GetLogs(); case FolderId_Langs: return GetLangs(); + case FolderId_Cheats: return GetCheats(); + case FolderId_CheatsWS: return GetCheatsWS(); case FolderId_Documents: return CustomDocumentsFolder; @@ -240,6 +252,8 @@ wxDirName& AppConfig::FolderOptions::operator[]( FoldersEnum_t folderidx ) case FolderId_MemoryCards: return MemoryCards; case FolderId_Logs: return Logs; case FolderId_Langs: return Langs; + case FolderId_Cheats: return Cheats; + case FolderId_CheatsWS: return CheatsWS; case FolderId_Documents: return CustomDocumentsFolder; @@ -266,6 +280,8 @@ bool AppConfig::FolderOptions::IsDefault( FoldersEnum_t folderidx ) const case FolderId_MemoryCards: return UseDefaultMemoryCards; case FolderId_Logs: return UseDefaultLogs; case FolderId_Langs: return UseDefaultLangs; + case FolderId_Cheats: return UseDefaultCheats; + case FolderId_CheatsWS: return UseDefaultCheatsWS; case FolderId_Documents: return false; @@ -327,6 +343,16 @@ void AppConfig::FolderOptions::Set( FoldersEnum_t folderidx, const wxString& src CustomDocumentsFolder = src; break; + case FolderId_Cheats: + Cheats = src; + UseDefaultCheats = useDefault; + break; + + case FolderId_CheatsWS: + CheatsWS = src; + UseDefaultCheatsWS = useDefault; + break; + jNO_DEFAULT } } @@ -634,6 +660,8 @@ void AppConfig::FolderOptions::ApplyDefaults() if( UseDefaultLogs ) Logs = PathDefs::GetLogs(); if( UseDefaultLangs ) Langs = PathDefs::GetLangs(); if( UseDefaultPluginsFolder)PluginsFolder = PathDefs::GetPlugins(); + if( UseDefaultCheats ) Cheats = PathDefs::GetCheats(); + if( UseDefaultCheatsWS ) CheatsWS = PathDefs::GetCheatsWS(); } // ------------------------------------------------------------------------ @@ -667,6 +695,8 @@ void AppConfig::FolderOptions::LoadSave( IniInterface& ini ) IniBitBool( UseDefaultLogs ); IniBitBool( UseDefaultLangs ); IniBitBool( UseDefaultPluginsFolder ); + IniBitBool( UseDefaultCheats ); + IniBitBool( UseDefaultCheatsWS ); //when saving in portable mode, we save relative paths if possible // --> on load, these relative paths will be expanded relative to the exe folder. @@ -678,6 +708,8 @@ void AppConfig::FolderOptions::LoadSave( IniInterface& ini ) IniEntryDirFile( MemoryCards, rel ); IniEntryDirFile( Logs, rel ); IniEntryDirFile( Langs, rel ); + IniEntryDirFile( Cheats, rel ); + IniEntryDirFile( CheatsWS, rel ); ini.Entry( L"PluginsFolder", PluginsFolder, InstallFolder + PathDefs::Base::Plugins(), rel ); IniEntryDirFile( RunIso, rel ); diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index d14484ddcc..9f480ca03a 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -132,7 +132,9 @@ public: UseDefaultSavestates:1, UseDefaultMemoryCards:1, UseDefaultLogs:1, - UseDefaultLangs:1; + UseDefaultLangs:1, + UseDefaultCheats:1, + UseDefaultCheatsWS:1; BITFIELD_END wxDirName @@ -141,7 +143,9 @@ public: Savestates, MemoryCards, Langs, - Logs; + Logs, + Cheats, + CheatsWS; wxDirName RunIso; // last used location for Iso loading. wxDirName RunELF; // last used location for ELF loading. diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index dab97ce2e1..8ffdb43772 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -352,14 +352,14 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src ) ResetCheatsCount(); if (EmuConfig.EnableCheats) { - if (int cheats = LoadCheats(gameCRC, L"cheats", L"Cheats")) { + if (int cheats = LoadCheats(gameCRC, PathDefs::GetCheats(), L"Cheats")) { gameCheats.Printf(L" [%d Cheats]", cheats); } } // FIXME: we should have a widescreen hacks config if (EmuConfig.EnableCheats) { - if (int cheats = LoadCheats(gameCRC, L"cheats_ws", L"Widescreen hacks")) { + if (int cheats = LoadCheats(gameCRC, PathDefs::GetCheatsWS(), L"Widescreen hacks")) { gameWsHacks.Printf(L" [%d WS hacks]", cheats); } }