Win32 - new Context Menu item - Save Movie As.. available when a movie is loaded in read+write mode.

This commit is contained in:
adelikat 2009-05-25 20:30:32 +00:00
parent a0c535cd60
commit 9ee1449a74
6 changed files with 54 additions and 7 deletions

View File

@ -1,3 +1,4 @@
23-may-2009 - adelikat - win32 - context menu - Save Movie As... menu item (for when a movie is loaded in read+write mode)
23-may-2009 - adelikat - win32 - added opton to remove a recent item to the roms, lua, and movie recent menus
23-may-2009 - adelikat - win32 - Added a remove recent item function and hooked it up to memwatch recent menu, now if a bad recent item is clicked, the user has a choice to remove it from the list
23-may-2009 - adelikat - win32 - Load Last Movie context menu item added

View File

@ -369,6 +369,7 @@ BEGIN
MENUITEM "Stop Movie Recording", FCEU_CONTEXT_STOPMOVIE
MENUITEM "View comments and subtitles", FCEUX_CONTEXT_VIEWCOMMENTSSUBTITLES
MENUITEM "Make backup", FCEUX_CONTEXT_MAKEBACKUP
MENUITEM "Save Movie As...", FCEUX_CONTEXT_SAVEMOVIEAS
MENUITEM SEPARATOR
MENUITEM "Undo savestate", FCEUX_CONTEXT_UNDOSAVESTATE
MENUITEM "Undo loadstate", FCEUX_CONTEXT_UNDOLOADSTATE

View File

@ -684,6 +684,8 @@
#define MENU_MOVIE_RECENT 40354
#define ID_GAME_LOADLASTMOVIE 40355
#define FCEUX_CONTEXT_LOADLASTMOVIE 40356
#define ID_GAME_SAVEMOVIEAS 40357
#define FCEUX_CONTEXT_SAVEMOVIEAS 40358
#define IDC_DEBUGGER_ICONTRAY 55535
#define MW_ValueLabel2 65423
#define MW_ValueLabel1 65426
@ -693,7 +695,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 125
#define _APS_NEXT_COMMAND_VALUE 40357
#define _APS_NEXT_COMMAND_VALUE 40359
#define _APS_NEXT_CONTROL_VALUE 1204
#define _APS_NEXT_SYMED_VALUE 101
#endif

View File

@ -129,6 +129,7 @@ bool rightClickEnabled = true; //If set to false, the right click context menu
//Function Prototypes
void ChangeMenuItemText(int menuitem, string text); //Alters a menu item name
void ChangeContextMenuItemText(int menuitem, string text, HMENU menu); //Alters a context menu item name
void SaveMovieAs(); //Gets a filename for Save Movie As...
//Recent Menu Strings ------------------------------------
char *recent_files[] = { 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 };
@ -1758,6 +1759,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
}
break;
//Recent Movie 1
case FCEUX_CONTEXT_LOADLASTMOVIE:
if(recent_movie[0])
{
@ -1801,6 +1803,12 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
case FCEUX_CONTEXT_MAKEBACKUP:
FCEUI_MakeBackupMovie(true);
break;
//Create a backup based on user entering a filename
case FCEUX_CONTEXT_SAVEMOVIEAS:
SaveMovieAs();
break;
//Game + Movie - Help
case FCEU_CONTEXT_MOVIEHELP:
OpenHelpWindow(moviehelp);
@ -2580,4 +2588,34 @@ void UpdateMenuHotkeys()
combo = GetKeyComboName(FCEUD_CommandMapping[EMUCMD_TOOL_OPENCDLOGGER]);
combined = "&Code/Data Logger...\t" + combo;
ChangeMenuItemText(MENU_CDLOGGER, combined);
}
//This function is for the context menu item Save Movie As...
//It gets a filename from the user then calls CreateMovie()
void SaveMovieAs()
{
const char filter[]="NES Movie file (*.fm2)\0*.fm2\0";
char nameo[2048];
std::string tempName;
int x;
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save Movie as...";
ofn.lpstrFilter=filter;
strcpy(nameo,curMovieFilename);
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hMemView;
if (GetSaveFileName(&ofn))
{
tempName = nameo;
x = tempName.find_last_of("."); //Check to see if the user provided a file extension
if (x < 0)
tempName.append(".fm2"); //If not, make it .fm2
FCEUI_CreateMovieFile(tempName);
}
}

View File

@ -1293,6 +1293,14 @@ void FCEU_DisplaySubtitles(char *format, ...)
subtitleMessage.isMovieMessage = subtitlesOnAVI;
}
void FCEUI_CreateMovieFile(std::string fn)
{
MovieData md = currMovieData; //Get current movie data
std::fstream* outf = FCEUD_UTF8_fstream(fn, "wb"); //open/create file
md.dump(outf,false); //dump movie data
delete outf; //clean up, delete file object
}
void FCEUI_MakeBackupMovie(bool dispMessage)
{
//This function generates backup movie files
@ -1337,12 +1345,8 @@ void FCEUI_MakeBackupMovie(bool dispMessage)
}
}
}
MovieData md = currMovieData; //Get current movie data
std::fstream* outf = FCEUD_UTF8_fstream(backupFn, "wb"); //open/create file
md.dump(outf,false); //dump movie data
delete outf; //clean up, delete file object
FCEUI_CreateMovieFile(backupFn);
//TODO, decide if fstream successfully opened the file and print error message if it doesn't
if (dispMessage) //If we should inform the user

View File

@ -242,6 +242,7 @@ extern bool autoMovieBackup;
//--------------------------------------------------
bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists
void FCEUI_MakeBackupMovie(bool dispMessage);
void FCEUI_CreateMovieFile(std::string fn);
void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author);
bool FCEUI_LoadMovie(const char *fname, bool read_only, bool tasedit, int _stopframe);
void FCEUI_MoviePlayFromBeginning(void);