mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
SaveState: Keep an undo for each slot by default.
This commit is contained in:
parent
a966403def
commit
2ee8dd7752
4 changed files with 47 additions and 2 deletions
|
@ -354,6 +354,7 @@ static ConfigSetting generalSettings[] = {
|
||||||
ConfigSetting("DumpAudio", &g_Config.bDumpAudio, false),
|
ConfigSetting("DumpAudio", &g_Config.bDumpAudio, false),
|
||||||
ConfigSetting("SaveLoadResetsAVdumping", &g_Config.bSaveLoadResetsAVdumping, false),
|
ConfigSetting("SaveLoadResetsAVdumping", &g_Config.bSaveLoadResetsAVdumping, false),
|
||||||
ConfigSetting("StateSlot", &g_Config.iCurrentStateSlot, 0, true, true),
|
ConfigSetting("StateSlot", &g_Config.iCurrentStateSlot, 0, true, true),
|
||||||
|
ConfigSetting("EnableStateUndo", &g_Config.bEnableStateUndo, true, true, true),
|
||||||
ConfigSetting("RewindFlipFrequency", &g_Config.iRewindFlipFrequency, 0, true, true),
|
ConfigSetting("RewindFlipFrequency", &g_Config.iRewindFlipFrequency, 0, true, true),
|
||||||
|
|
||||||
ConfigSetting("GridView1", &g_Config.bGridView1, true),
|
ConfigSetting("GridView1", &g_Config.bGridView1, true),
|
||||||
|
|
|
@ -199,6 +199,7 @@ public:
|
||||||
int iMaxRecent;
|
int iMaxRecent;
|
||||||
int iCurrentStateSlot;
|
int iCurrentStateSlot;
|
||||||
int iRewindFlipFrequency;
|
int iRewindFlipFrequency;
|
||||||
|
bool bEnableStateUndo;
|
||||||
bool bEnableAutoLoad;
|
bool bEnableAutoLoad;
|
||||||
bool bEnableCheats;
|
bool bEnableCheats;
|
||||||
bool bReloadCheats;
|
bool bReloadCheats;
|
||||||
|
|
|
@ -411,11 +411,16 @@ namespace SaveState
|
||||||
{
|
{
|
||||||
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
||||||
std::string shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
std::string shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
||||||
|
std::string fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION);
|
||||||
|
std::string shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION);
|
||||||
if (!fn.empty()) {
|
if (!fn.empty()) {
|
||||||
auto renameCallback = [=](bool status, const std::string &message, void *data) {
|
auto renameCallback = [=](bool status, const std::string &message, void *data) {
|
||||||
if (status) {
|
if (status) {
|
||||||
if (File::Exists(fn)) {
|
if (File::Exists(fnUndo) && g_Config.bEnableStateUndo) {
|
||||||
File::Delete(fn);
|
File::Delete(fnUndo);
|
||||||
|
}
|
||||||
|
if (File::Exists(fn) && g_Config.bEnableStateUndo) {
|
||||||
|
File::Rename(fn, fnUndo);
|
||||||
}
|
}
|
||||||
File::Rename(fn + ".tmp", fn);
|
File::Rename(fn + ".tmp", fn);
|
||||||
}
|
}
|
||||||
|
@ -424,6 +429,9 @@ namespace SaveState
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Let's also create a screenshot.
|
// Let's also create a screenshot.
|
||||||
|
if (File::Exists(shot) && g_Config.bEnableStateUndo) {
|
||||||
|
File::Rename(shot, shotUndo);
|
||||||
|
}
|
||||||
SaveScreenshot(shot, Callback(), 0);
|
SaveScreenshot(shot, Callback(), 0);
|
||||||
Save(fn + ".tmp", renameCallback, cbUserData);
|
Save(fn + ".tmp", renameCallback, cbUserData);
|
||||||
} else {
|
} else {
|
||||||
|
@ -433,12 +441,43 @@ namespace SaveState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UndoSaveSlot(const std::string &gameFilename, int slot) {
|
||||||
|
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
||||||
|
std::string shot = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
||||||
|
std::string fnUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_STATE_EXTENSION);
|
||||||
|
std::string shotUndo = GenerateSaveSlotFilename(gameFilename, slot, UNDO_SCREENSHOT_EXTENSION);
|
||||||
|
|
||||||
|
// Do nothing if there's no undo.
|
||||||
|
if (File::Exists(fnUndo)) {
|
||||||
|
// Swap them so they can undo again to redo. Mistakes happen.
|
||||||
|
if (File::Exists(shotUndo)) {
|
||||||
|
File::Rename(shot, shot + ".tmp");
|
||||||
|
File::Rename(shotUndo, shot);
|
||||||
|
File::Rename(shot + ".tmp", shotUndo);
|
||||||
|
}
|
||||||
|
|
||||||
|
File::Rename(fn, fn + ".tmp");
|
||||||
|
File::Rename(fnUndo, fn);
|
||||||
|
File::Rename(fn + ".tmp", fnUndo);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool HasSaveInSlot(const std::string &gameFilename, int slot)
|
bool HasSaveInSlot(const std::string &gameFilename, int slot)
|
||||||
{
|
{
|
||||||
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
||||||
return File::Exists(fn);
|
return File::Exists(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasUndoSaveInSlot(const std::string &gameFilename, int slot)
|
||||||
|
{
|
||||||
|
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, STATE_EXTENSION);
|
||||||
|
return File::Exists(fn + ".undo");
|
||||||
|
}
|
||||||
|
|
||||||
bool HasScreenshotInSlot(const std::string &gameFilename, int slot)
|
bool HasScreenshotInSlot(const std::string &gameFilename, int slot)
|
||||||
{
|
{
|
||||||
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
std::string fn = GenerateSaveSlotFilename(gameFilename, slot, SCREENSHOT_EXTENSION);
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace SaveState
|
||||||
static const int NUM_SLOTS = 5;
|
static const int NUM_SLOTS = 5;
|
||||||
static const char *STATE_EXTENSION = "ppst";
|
static const char *STATE_EXTENSION = "ppst";
|
||||||
static const char *SCREENSHOT_EXTENSION = "jpg";
|
static const char *SCREENSHOT_EXTENSION = "jpg";
|
||||||
|
static const char *UNDO_STATE_EXTENSION = "undo.ppst";
|
||||||
|
static const char *UNDO_SCREENSHOT_EXTENSION = "undo.jpg";
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
@ -36,8 +38,10 @@ namespace SaveState
|
||||||
void NextSlot();
|
void NextSlot();
|
||||||
void SaveSlot(const std::string &gameFilename, int slot, Callback callback, void *cbUserData = 0);
|
void SaveSlot(const std::string &gameFilename, int slot, Callback callback, void *cbUserData = 0);
|
||||||
void LoadSlot(const std::string &gameFilename, int slot, Callback callback, void *cbUserData = 0);
|
void LoadSlot(const std::string &gameFilename, int slot, Callback callback, void *cbUserData = 0);
|
||||||
|
bool UndoSaveSlot(const std::string &gameFilename, int slot);
|
||||||
// Checks whether there's an existing save in the specified slot.
|
// Checks whether there's an existing save in the specified slot.
|
||||||
bool HasSaveInSlot(const std::string &gameFilename, int slot);
|
bool HasSaveInSlot(const std::string &gameFilename, int slot);
|
||||||
|
bool HasUndoSaveInSlot(const std::string &gameFilename, int slot);
|
||||||
bool HasScreenshotInSlot(const std::string &gameFilename, int slot);
|
bool HasScreenshotInSlot(const std::string &gameFilename, int slot);
|
||||||
|
|
||||||
int GetCurrentSlot();
|
int GetCurrentSlot();
|
||||||
|
|
Loading…
Add table
Reference in a new issue