mirror of https://github.com/PCSX2/pcsx2.git
Multiple cheat files and WIP: widescreen cheats
1. Multiple cheats files (at the "cheats' folder) can be loaded, as long as they begin with the CRC and end in '.pnach' (e.g ABCD1234.Persona4(EU).god-mode.pnach) 2. Multiple cheats are also loaded from the Widescreen hacks folder ('cheats_ws'). File names rules are the same as for normal cheats. TODO: Add config and GUI for widescreen hacks. Right now the cheat files from cheat_ws folder are loaded if cheats are enabled. We need a separate config for that. Thanks to dlanor from the forum for his filenames wildcards patch: http://forums.pcsx2.net/Thread-PCSX2-Patch-Finder-Removed-completely-or-just-hidden?pid=263592#pid263592 git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5562 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
484065d0a8
commit
8cc03b1e2a
|
@ -21,6 +21,7 @@
|
||||||
#include "Patch.h"
|
#include "Patch.h"
|
||||||
#include "GameDatabase.h"
|
#include "GameDatabase.h"
|
||||||
#include <wx/textfile.h>
|
#include <wx/textfile.h>
|
||||||
|
#include <wx/dir.h>
|
||||||
|
|
||||||
IniPatch Patch[ MAX_PATCH ];
|
IniPatch Patch[ MAX_PATCH ];
|
||||||
IniPatch Cheat[ MAX_CHEAT ];
|
IniPatch Cheat[ MAX_CHEAT ];
|
||||||
|
@ -165,35 +166,55 @@ void inifile_process(wxTextFile &f1 )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResetCeatsCount()
|
||||||
|
{
|
||||||
|
cheatnumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int LoadCheatsFiles(const wxString& 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());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
wxDir dir(folderName);
|
||||||
|
|
||||||
|
int before = cheatnumber;
|
||||||
|
wxString buffer;
|
||||||
|
wxTextFile f;
|
||||||
|
bool found = dir.GetFirst(&buffer, fileSpec, wxDIR_FILES);
|
||||||
|
while (found) {
|
||||||
|
Console.WriteLn(Color_Gray, L"Found %s file: '%s'", friendlyName.c_str(), buffer.c_str());
|
||||||
|
int before = cheatnumber;
|
||||||
|
f.Open(Path::Combine(dir.GetName(), buffer));
|
||||||
|
inifile_process(f);
|
||||||
|
f.Close();
|
||||||
|
int loaded = cheatnumber - before;
|
||||||
|
Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Loaded %d %s from '%s'", loaded, friendlyName.c_str(), buffer.c_str());
|
||||||
|
found = dir.GetNext(&buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cheatnumber - before;
|
||||||
|
}
|
||||||
|
|
||||||
// This routine loads cheats from *.pnach files
|
// This routine loads cheats from *.pnach files
|
||||||
// Returns number of cheats loaded
|
// Returns number of cheats loaded
|
||||||
// Note: Should be called after InitPatches()
|
// Note: Should be called after InitPatches()
|
||||||
int InitCheats(const wxString& name)
|
int LoadCheats(const wxString& name, const wxString& folderName, const wxString& friendlyName)
|
||||||
{
|
{
|
||||||
wxTextFile f1;
|
int loaded = 0;
|
||||||
wxString buffer;
|
|
||||||
cheatnumber = 0;
|
|
||||||
|
|
||||||
// FIXME : We need to add a 'cheats' folder to the AppConfig, and use that instead. --air
|
wxString filespec = name + L"*.pnach";
|
||||||
|
loaded += LoadCheatsFiles(folderName, filespec, friendlyName);
|
||||||
|
|
||||||
buffer = Path::Combine(L"cheats", name + L".pnach");
|
wxString nameUpper = name; nameUpper.Upper();
|
||||||
|
if (wxFileName::IsCaseSensitive() && name != nameUpper) {
|
||||||
|
filespec = nameUpper + L"*.pnach";
|
||||||
|
loaded += LoadCheatsFiles(folderName, filespec, friendlyName);
|
||||||
|
}
|
||||||
|
|
||||||
if(!f1.Open(buffer) && wxFileName::IsCaseSensitive())
|
Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Overall %d %s loaded", loaded, friendlyName.c_str());
|
||||||
{
|
return loaded;
|
||||||
f1.Open( Path::Combine(L"cheats", name.Upper() + L".pnach") );
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!f1.IsOpened())
|
|
||||||
{
|
|
||||||
Console.WriteLn( Color_Gray, "No cheats found. Resuming execution without cheats..." );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLn( Color_Green, "Cheats found!");
|
|
||||||
inifile_process( f1 );
|
|
||||||
|
|
||||||
Console.WriteLn("Cheats Loaded: %d", cheatnumber);
|
|
||||||
return cheatnumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 StrToU32(const wxString& str, int base = 10)
|
static u32 StrToU32(const wxString& str, int base = 10)
|
||||||
|
|
|
@ -57,7 +57,8 @@ namespace PatchFunc
|
||||||
PATCHTABLEFUNC cheat;
|
PATCHTABLEFUNC cheat;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int InitCheats(const wxString& name);
|
extern void ResetCeatsCount();
|
||||||
|
extern int LoadCheats(const wxString& name, const wxString& folderName, const wxString& friendlyName);
|
||||||
extern void inifile_command(bool isCheat, const wxString& cmd);
|
extern void inifile_command(bool isCheat, const wxString& cmd);
|
||||||
extern void inifile_trim(wxString& buffer);
|
extern void inifile_trim(wxString& buffer);
|
||||||
|
|
||||||
|
|
|
@ -305,6 +305,7 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src )
|
||||||
wxString gamePatch;
|
wxString gamePatch;
|
||||||
wxString gameFixes;
|
wxString gameFixes;
|
||||||
wxString gameCheats;
|
wxString gameCheats;
|
||||||
|
wxString gameWsHacks;
|
||||||
|
|
||||||
wxString gameName;
|
wxString gameName;
|
||||||
wxString gameCompat;
|
wxString gameCompat;
|
||||||
|
@ -349,13 +350,21 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src )
|
||||||
gameName = L"Booting PS2 BIOS... ";
|
gameName = L"Booting PS2 BIOS... ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResetCeatsCount();
|
||||||
if (EmuConfig.EnableCheats) {
|
if (EmuConfig.EnableCheats) {
|
||||||
if (int cheats = InitCheats(gameCRC)) {
|
if (int cheats = LoadCheats(gameCRC, L"cheats", L"Cheats")) {
|
||||||
gameCheats.Printf(L" [%d Cheats]", cheats);
|
gameCheats.Printf(L" [%d Cheats]", cheats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.SetTitle(gameName+gameSerial+gameCompat+gameFixes+gamePatch+gameCheats);
|
// FIXME: we should have a widescreen hacks config
|
||||||
|
if (EmuConfig.EnableCheats) {
|
||||||
|
if (int cheats = LoadCheats(gameCRC, L"cheats_ws", L"Widescreen hacks")) {
|
||||||
|
gameWsHacks.Printf(L" [%d WS hacks]", cheats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.SetTitle(gameName+gameSerial+gameCompat+gameFixes+gamePatch+gameCheats+gameWsHacks);
|
||||||
|
|
||||||
// Re-entry guard protects against cases where code wants to manually set core settings
|
// Re-entry guard protects against cases where code wants to manually set core settings
|
||||||
// which are not part of g_Conf. The subsequent call to apply g_Conf settings (which is
|
// which are not part of g_Conf. The subsequent call to apply g_Conf settings (which is
|
||||||
|
|
Loading…
Reference in New Issue