Undo savestate / Redo savestate and Undo loadstate / Redo loadstate features implemented. Win32 - undo/redo context menu items implemented.
This commit is contained in:
parent
ff7496930b
commit
5cb9c50814
|
@ -1,4 +1,6 @@
|
|||
---version 2.0.4 yet to be released---
|
||||
23-dec-2008 - adelikat - Win32 - Undo/redo loadstate and Undo/redo savestate context menu items added
|
||||
23-dec-2008 - adelikat - undo/redo loadstate and undo/redo savestate implemented
|
||||
22-dec-2008 - adelikat - backupSavestate system added.
|
||||
22-dec-2008 - shinydoofy - sdl - added Shift+M for toggling automatic movie backups for SDL
|
||||
22-dec-2008 - adelikat - Movie auto-backup feature implemented
|
||||
|
|
|
@ -327,6 +327,7 @@ BEGIN
|
|||
MENUITEM "Stop Movie Replay", FCEU_CONTEXT_STOPMOVIE
|
||||
MENUITEM "View comments and subtitles", FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Undo savestate", FCEUX_CONTEXT_UNDOSAVESTATE
|
||||
MENUITEM "Rewind to last auto-save", FCEUX_CONTEXT_REWINDTOLASTAUTO
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Help....", FCEU_CONTEXT_MOVIEHELP
|
||||
|
@ -356,6 +357,7 @@ BEGIN
|
|||
MENUITEM "View comments and subtitles", FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES
|
||||
MENUITEM "Make backup", FCEUX_CONTEXT_MAKEBACKUP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Undo savestate", FCEUX_CONTEXT_UNDOSAVESTATE
|
||||
MENUITEM "Undo loadstate", FCEUX_CONTEXT_UNDOLOADSTATE
|
||||
MENUITEM "Rewind to last auto-save", FCEUX_CONTEXT_REWINDTOLASTAUTO
|
||||
MENUITEM SEPARATOR
|
||||
|
|
|
@ -637,6 +637,8 @@
|
|||
#define MENU_MOVIEOPTIONS 40322
|
||||
#define ID_GAME_UNDOSAVESTATE 40323
|
||||
#define FCEUX_CONTEXT_UNDOSAVESTATE 40324
|
||||
#define ID_GAME_UNDOSAVESTATE40325 40325
|
||||
#define ID_GAME_UNDOSAVESTATE40326 40326
|
||||
#define IDC_DEBUGGER_ICONTRAY 55535
|
||||
#define MW_ValueLabel2 65423
|
||||
#define MW_ValueLabel1 65426
|
||||
|
@ -646,7 +648,7 @@
|
|||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 125
|
||||
#define _APS_NEXT_COMMAND_VALUE 40325
|
||||
#define _APS_NEXT_COMMAND_VALUE 40327
|
||||
#define _APS_NEXT_CONTROL_VALUE 1199
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
|
|
@ -64,5 +64,4 @@ void FCEUD_LoadStateFrom()
|
|||
// Load save state if a file was selected.
|
||||
FCEUI_LoadState(nameo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
void FCEUD_SaveStateAs();
|
||||
void FCEUD_LoadStateFrom();
|
||||
|
||||
|
||||
void LoadBackup(); //Load backup savestate
|
||||
|
|
|
@ -415,14 +415,21 @@ void UpdateCheckedMenuItems()
|
|||
|
||||
void UpdateContextMenuItems(HMENU context, int whichContext)
|
||||
{
|
||||
bool exist;
|
||||
string undoLoadstate = "Undo loadstate";
|
||||
string redoLoadstate = "Redo loadstate";
|
||||
string redoSavestate = "Redo savestate";
|
||||
string undoSavestate = "Undo savestate";
|
||||
|
||||
//Undo Loadstate
|
||||
exist = CheckBackupSaveStateExist();
|
||||
EnableMenuItem(context,FCEUX_CONTEXT_UNDOLOADSTATE,MF_BYCOMMAND | exist ? MF_ENABLED : MF_GRAYED);
|
||||
|
||||
if (CheckBackupSaveStateExist() && (undoLS || redoLS))
|
||||
EnableMenuItem(context,FCEUX_CONTEXT_UNDOLOADSTATE,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(context,FCEUX_CONTEXT_UNDOLOADSTATE,MF_BYCOMMAND | MF_GRAYED);
|
||||
if (redoLS)
|
||||
ChangeContextMenuItemText(FCEUX_CONTEXT_UNDOLOADSTATE, redoLoadstate, context);
|
||||
else
|
||||
ChangeContextMenuItemText(FCEUX_CONTEXT_UNDOLOADSTATE, undoLoadstate, context);
|
||||
|
||||
//Undo Savestate
|
||||
if (undoSS || redoSS) //If undo or redo, enable Undo savestate, else keep it gray
|
||||
EnableMenuItem(context,FCEUX_CONTEXT_UNDOSAVESTATE,MF_BYCOMMAND | MF_ENABLED);
|
||||
|
@ -432,25 +439,6 @@ void UpdateContextMenuItems(HMENU context, int whichContext)
|
|||
ChangeContextMenuItemText(FCEUX_CONTEXT_UNDOSAVESTATE, redoSavestate, context);
|
||||
else
|
||||
ChangeContextMenuItemText(FCEUX_CONTEXT_UNDOSAVESTATE, undoSavestate, context);
|
||||
|
||||
//Case specific menu item handling
|
||||
switch(whichContext)
|
||||
{
|
||||
//0 = Game + Movie in read only
|
||||
case 0:
|
||||
break;
|
||||
//1 = Game + No Movie
|
||||
case 1:
|
||||
break;
|
||||
//2 = No Game
|
||||
case 2:
|
||||
break;
|
||||
//3 = Game + Movie in read + write
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates recent files / recent directories menu
|
||||
|
@ -1325,7 +1313,9 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
|||
|
||||
//Undo Loadstate
|
||||
case FCEUX_CONTEXT_UNDOLOADSTATE:
|
||||
if (CheckBackupSaveStateExist())
|
||||
if (CheckBackupSaveStateExist() && redoLS)
|
||||
RedoLoadState();
|
||||
else if (CheckBackupSaveStateExist() && undoLS)
|
||||
LoadBackup();
|
||||
break;
|
||||
|
||||
|
|
|
@ -128,6 +128,9 @@ static void CloseGame(void)
|
|||
lastSavestateMade[0] = 0;
|
||||
undoSS = false;
|
||||
redoSS = false;
|
||||
lastLoadstateMade[0] = 0;
|
||||
undoLS = false;
|
||||
redoLS = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,10 +59,14 @@ static int StateShow;
|
|||
//tells the save system innards that we're loading the old format
|
||||
bool FCEU_state_loading_old_format;
|
||||
|
||||
char lastSavestateMade[2048]; //Stores the last savestate made (needed for UndoSavestate)
|
||||
bool undoSS = false; //This will be true if there is a backup state for lastSavestateMade
|
||||
char lastSavestateMade[2048]; //Stores the filename of the last savestate made (needed for UndoSavestate)
|
||||
bool undoSS = false; //This will be true if there is lastSavestateMade, it was made since ROM was loaded, a backup state for lastSavestateMade exists
|
||||
bool redoSS = false; //This will be true if UndoSaveState is run, will turn false when a new savestate is made
|
||||
|
||||
char lastLoadstateMade[2048]; //Stores the filename of the last state loaded (needed for Undo/Redo loadstate)
|
||||
bool undoLS = false; //This will be true if a backupstate was made and it was made since ROM was loaded
|
||||
bool redoLS = false; //This will be true if a backupstate was loaded, meaning redoLoadState can be run
|
||||
|
||||
#define SFMDATA_SIZE (64)
|
||||
static SFORMAT SFMDATA[SFMDATA_SIZE];
|
||||
static int SFEXINDEX;
|
||||
|
@ -663,7 +667,9 @@ bool FCEUSS_Load(const char *fname)
|
|||
}
|
||||
else
|
||||
{
|
||||
st=FCEUD_UTF8_fstream(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,fname),"rb");
|
||||
string fn = FCEU_MakeFName(FCEUMKF_STATE,CurrentState,fname);
|
||||
st=FCEUD_UTF8_fstream(fn,"rb");
|
||||
strcpy(lastLoadstateMade,fn.c_str());
|
||||
}
|
||||
|
||||
if(st == NULL)
|
||||
|
@ -974,10 +980,31 @@ void BackupLoadState()
|
|||
{
|
||||
string filename = GetBackupFileName();
|
||||
FCEUSS_Save(filename.c_str());
|
||||
undoLS = true;
|
||||
}
|
||||
|
||||
void LoadBackup()
|
||||
{
|
||||
string filename = GetBackupFileName();
|
||||
FCEUSS_Load(filename.c_str());
|
||||
if (!undoLS) return;
|
||||
string filename = GetBackupFileName(); //Get backup filename
|
||||
if (CheckBackupSaveStateExist())
|
||||
{
|
||||
FCEUSS_Load(filename.c_str()); //Load it
|
||||
redoLS = true; //Flag redoLoadState
|
||||
undoLS = false; //Flag that LoadBackup cannot be run again
|
||||
}
|
||||
else
|
||||
FCEUI_DispMessage("Error: Could not load %s",filename.c_str());
|
||||
}
|
||||
|
||||
void RedoLoadState()
|
||||
{
|
||||
if (!redoLS) return;
|
||||
if (lastLoadstateMade && redoLS)
|
||||
{
|
||||
FCEUSS_Load(lastLoadstateMade);
|
||||
FCEUI_printf("Redoing %s\n",lastLoadstateMade);
|
||||
}
|
||||
redoLS = false; //Flag that RedoLoadState can not be run again
|
||||
undoLS = true; //Flag that LoadBackup can be run again
|
||||
}
|
|
@ -64,8 +64,13 @@ void FCEU_DrawSaveStates(uint8 *XBuf);
|
|||
void CreateBackupSaveState(const char *fname); //backsup a savestate before overwriting it with a new one
|
||||
void BackupLoadState(); //Makes a backup savestate before any loadstate
|
||||
void LoadBackup(); //Loads the backupsavestate
|
||||
void RedoLoadState(); //reloads a loadstate if backupsavestate was run
|
||||
void SwapSaveState(); //Swaps a savestate with its backup state
|
||||
|
||||
extern char lastSavestateMade[2048]; //Filename of last savestate used
|
||||
extern bool undoSS; //undo savestate flag
|
||||
extern bool redoSS; //redo savestate flag
|
||||
extern char lastSavestateMade[2048]; //Filename of last savestate used
|
||||
extern char lastLoadstateMade[2048]; //Filename of last state loaded
|
||||
extern bool undoLS; //undo loadstate flag
|
||||
extern bool redoLS; //redo savestate flag
|
||||
bool CheckBackupSaveStateExist(); //Checks if backupsavestate exists
|
Loading…
Reference in New Issue