LoadBackup function added, Win32 - Undo Loadstate context menu item added.
This commit is contained in:
parent
7b035bb3bc
commit
d9471d1f75
|
@ -1,4 +1,5 @@
|
|||
---version 2.0.4 yet to be released---
|
||||
19-dec-2008 - adelikat - Loadbackup function added, Win32 - Undo Loadstate context menu item
|
||||
19-dec-2008 - adelikat - Backup savestate is made before loading a state
|
||||
18-dec-2008 - adelikat - win32 - turbo bypasses sound better if muteturbo is checked
|
||||
18-dec-2008 - shinydoofy - sdl - fixed compiling errors for SDL due to r1037
|
||||
|
|
|
@ -340,6 +340,7 @@ BEGIN
|
|||
MENUITEM "&Replay Movie", FCEUX_CONTEXT_REPLAYMOVIE
|
||||
MENUITEM "Record Movie", FCEUX_CONTEXT_RECORDMOVIE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Undo loadstate", FCEUX_CONTEXT_UNDOLOADSTATE
|
||||
MENUITEM "Rewind to last auto-save", FCEUX_CONTEXT_REWINDTOLASTAUTO
|
||||
MENUITEM "Screenshot", FCEUX_CONTEXT_SCREENSHOT
|
||||
MENUITEM SEPARATOR
|
||||
|
@ -357,6 +358,7 @@ BEGIN
|
|||
MENUITEM "Stop Movie Recording", FCEU_CONTEXT_STOPMOVIE
|
||||
MENUITEM "View comments and subtitles", FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Undo loadstate", FCEUX_CONTEXT_UNDOLOADSTATE
|
||||
MENUITEM "Rewind to last auto-save", FCEUX_CONTEXT_REWINDTOLASTAUTO
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Help...", FCEU_CONTEXT_MOVIEHELP
|
||||
|
|
|
@ -383,7 +383,6 @@
|
|||
#define MEMW_EDIT02RMADDRESS 1190
|
||||
#define INSERTCS_STATIC 1190
|
||||
#define MEMW_EDIT03RMADDRESS 1191
|
||||
#define IDC_DEBUG_RESTORESIZE 1191
|
||||
#define IDC_DEBUGGER_RESTORESIZE 1191
|
||||
#define MEMW_EDIT04RMADDRESS 1192
|
||||
#define EDIT00_RESULTS 1193
|
||||
|
@ -625,6 +624,10 @@
|
|||
#define ID_GAME_VIEWCOMMENTSSUBTITLES40312 40312
|
||||
#define ID_OPTIONS_COLLAPSETO1COLUMN 40313
|
||||
#define MEMW_OPTIONS_EXPANDCOLLAPSE 40314
|
||||
#define ID_GAME_UNDOLOADSTATE 40315
|
||||
#define FCEUX_CONTEXT_UNDOLOADSTATE 40316
|
||||
#define ID_GAME_UNDOLOADSTATE40317 40317
|
||||
#define ID_GAME_UNDOLOADSTATE40318 40318
|
||||
#define IDC_DEBUGGER_ICONTRAY 55535
|
||||
#define MW_ValueLabel2 65423
|
||||
#define MW_ValueLabel1 65426
|
||||
|
@ -634,7 +637,7 @@
|
|||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 125
|
||||
#define _APS_NEXT_COMMAND_VALUE 40315
|
||||
#define _APS_NEXT_COMMAND_VALUE 40319
|
||||
#define _APS_NEXT_CONTROL_VALUE 1192
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
using namespace std;
|
||||
|
||||
//Externs
|
||||
extern int CurrentState; //Declared in src/state.cpp
|
||||
extern int CurrentState; //Declared in src/state.cpp
|
||||
extern bool FCEUSS_Load(const char *fname); //Declared in src/state.cpp
|
||||
extern string GetBackupFileName(); //Declared in src/state.cpp
|
||||
|
||||
bool CheckBackupSaveStateExist(); //Checks if backupsavestate exists
|
||||
/**
|
||||
|
@ -69,26 +71,21 @@ void FCEUD_LoadStateFrom()
|
|||
bool CheckBackupSaveStateExist()
|
||||
{
|
||||
//This function simply checks to see if the backup savestate of the appropriate filename exists
|
||||
string filename;
|
||||
int x;
|
||||
|
||||
filename = strdup(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str()); //Generate normal savestate filename
|
||||
x = filename.find_last_of("."); //Find last dot
|
||||
filename = filename.substr(0,x); //Chop off file extension
|
||||
filename.append(".bak"); //add .bak
|
||||
|
||||
string filename = GetBackupFileName(); //Get backup savestate filename
|
||||
|
||||
//Check if this filename exists
|
||||
fstream test;
|
||||
test.open(filename.c_str(),fstream::in);
|
||||
|
||||
FCEUI_printf("Checking %s\n",filename.c_str());
|
||||
if (test.fail())
|
||||
{
|
||||
test.close();
|
||||
test.close(); FCEUI_printf("Fail\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
test.close();
|
||||
test.close(); FCEUI_printf("Succeed\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ void ShowNetplayConsole(void); //mbg merge 7/17/06 YECH had to add
|
|||
void MapInput(void);
|
||||
extern BOOL CALLBACK ReplayMetadataDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //Metadata dialog
|
||||
extern bool CheckBackupSaveStateExist(); //Checks if backupsavestate exists
|
||||
extern void LoadBackup();
|
||||
//AutoFire-----------------------------------------------
|
||||
|
||||
static int CheckedAutoFirePattern = MENU_AUTOFIRE_PATTERN_1;
|
||||
|
@ -409,6 +410,34 @@ void UpdateCheckedMenuItems()
|
|||
}
|
||||
}
|
||||
|
||||
void UpdateContextMenuItems(HMENU context, int whichContext)
|
||||
{
|
||||
bool exist;
|
||||
|
||||
switch(whichContext)
|
||||
{
|
||||
//0 = Game + Movie in read only
|
||||
case 0:
|
||||
break;
|
||||
//1 = Game + No Movie
|
||||
case 1:
|
||||
exist = CheckBackupSaveStateExist();
|
||||
EnableMenuItem(context,FCEUX_CONTEXT_UNDOLOADSTATE,MF_BYCOMMAND | exist ? MF_ENABLED : MF_GRAYED);
|
||||
break;
|
||||
//2 = No Game
|
||||
case 2:
|
||||
break;
|
||||
//3 = Game + Movie in read + write
|
||||
case 3:
|
||||
exist = CheckBackupSaveStateExist();
|
||||
EnableMenuItem(context,FCEUX_CONTEXT_UNDOLOADSTATE,MF_BYCOMMAND | exist ? MF_ENABLED : MF_GRAYED);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Updates recent files / recent directories menu
|
||||
/// @param menu Menu handle of the main window's menu
|
||||
/// @param strs Strings to add to the menu
|
||||
|
@ -721,6 +750,8 @@ void GetMouseData(uint32 (&md)[3])
|
|||
//Message loop of the main window
|
||||
LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
int whichContext = 0;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
|
@ -734,22 +765,36 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
|||
hfceuxcontext = LoadMenu(fceu_hInstance,"FCEUCONTEXTMENUS");
|
||||
|
||||
//If There is a movie loaded in read only
|
||||
if (GameInfo && FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD) && movie_readonly)
|
||||
if (GameInfo && FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD) && movie_readonly)
|
||||
{
|
||||
hfceuxcontextsub = GetSubMenu(hfceuxcontext,0);
|
||||
|
||||
whichContext = 0;
|
||||
}
|
||||
|
||||
//If there is a movie loaded in read+write
|
||||
else if (GameInfo && FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD) && !movie_readonly)
|
||||
{
|
||||
hfceuxcontextsub = GetSubMenu(hfceuxcontext,3);
|
||||
whichContext = 3;
|
||||
}
|
||||
|
||||
|
||||
//If there is a ROM loaded but no movie
|
||||
else if (GameInfo)
|
||||
{
|
||||
hfceuxcontextsub = GetSubMenu(hfceuxcontext,1);
|
||||
whichContext = 1;
|
||||
}
|
||||
|
||||
//Else no ROM
|
||||
else
|
||||
{
|
||||
hfceuxcontextsub = GetSubMenu(hfceuxcontext,2);
|
||||
|
||||
whichContext = 2;
|
||||
}
|
||||
UpdateContextMenuItems(hfceuxcontextsub, whichContext);
|
||||
TrackPopupMenu(hfceuxcontextsub,0,(MainWindow_wndx+mousex),(MainWindow_wndy+mousey),TPM_RIGHTBUTTON,hWnd,0);
|
||||
|
||||
}
|
||||
|
||||
case WM_MOVE:
|
||||
|
@ -1268,18 +1313,25 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
|||
//View comments and subtitles
|
||||
case FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES:
|
||||
CreateDialog(fceu_hInstance, "IDD_REPLAY_METADATA", hWnd, ReplayMetadataDialogProc, (LPARAM)0);
|
||||
break;
|
||||
|
||||
//Undo Loadstate
|
||||
case FCEUX_CONTEXT_UNDOLOADSTATE:
|
||||
if (CheckBackupSaveStateExist())
|
||||
LoadBackup();
|
||||
break;
|
||||
|
||||
//Load last auto-save
|
||||
case FCEUX_CONTEXT_REWINDTOLASTAUTO:
|
||||
FCEUI_Autosave();
|
||||
break;
|
||||
|
||||
//Movie help
|
||||
//Game + Movie - Help
|
||||
case FCEU_CONTEXT_MOVIEHELP:
|
||||
OpenHelpWindow(moviehelp);
|
||||
break;
|
||||
|
||||
//No Game
|
||||
//No Game - Help
|
||||
case FCEU_CONTEXT_FCEUHELP:
|
||||
OpenHelpWindow(gettingstartedhelp);
|
||||
break;
|
||||
|
|
|
@ -839,16 +839,28 @@ void FCEU_DrawSaveStates(uint8 *XBuf)
|
|||
StateShow--;
|
||||
}
|
||||
|
||||
void BackupSaveState()
|
||||
string GetBackupFileName()
|
||||
{
|
||||
//Everytime a load state is loaded, this is run prior so that the user has a backup of the previous emulator state
|
||||
string filename;
|
||||
int x;
|
||||
|
||||
filename = strdup(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str()); //Generate normal savestate filename
|
||||
x = filename.find_last_of("."); //Find last dot
|
||||
filename = filename.substr(0,x); //Chop off file extension
|
||||
filename.append(".bak"); //add .bak
|
||||
FCEUI_printf("%s\n",filename.c_str());
|
||||
filename.append(".bak.fc0"); //add .bak
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
void BackupSaveState()
|
||||
{
|
||||
string filename = GetBackupFileName();
|
||||
FCEUSS_Save(filename.c_str());
|
||||
FCEUI_printf("File %s loaded.\n",filename.c_str());
|
||||
}
|
||||
|
||||
void LoadBackup()
|
||||
{
|
||||
string filename = GetBackupFileName();
|
||||
FCEUSS_Load(filename.c_str());
|
||||
}
|
|
@ -61,4 +61,5 @@ void AddExState(void *v, uint32 s, int type, char *desc);
|
|||
|
||||
void FCEU_DrawSaveStates(uint8 *XBuf);
|
||||
|
||||
void BackupSaveState(); //Makes a backupsavestate
|
||||
void BackupSaveState(); //Makes a backupsavestate
|
||||
void LoadBackup(); //Loads the backupsavestate
|
Loading…
Reference in New Issue