From 6faa55b21ff381636114b5a5fa5e43219c9e3f27 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 7 Jun 2010 15:41:52 +0000 Subject: [PATCH] Clean up Deign's screenshot as code. Internally it is now set up for easy implementation in the SDL build. --- changelog.txt | 1 + src/drivers/win/common.h | 2 -- src/drivers/win/video.h | 3 +++ src/drivers/win/window.cpp | 33 ++++++++++++++++++++++++++++++--- src/video.cpp | 32 ++++++++++---------------------- 5 files changed, 44 insertions(+), 27 deletions(-) diff --git a/changelog.txt b/changelog.txt index df516be3..ed03a219 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,4 @@ +07-june-2010 - Deign/adelikat - Win32 - Added a SavestateAs Menu item 06-june-2010 - FatRatKnight - Added a return value to gui.text: The X position where the function would paint the next character. 02-june-2010 - adelikat - Win32 - Movie Options Dialog - Fix so Full Savestate Load checkbox is updated on load diff --git a/src/drivers/win/common.h b/src/drivers/win/common.h index f9adf878..ec8c5be6 100644 --- a/src/drivers/win/common.h +++ b/src/drivers/win/common.h @@ -41,8 +41,6 @@ extern int eoptions; #define EO_FOAFTERSTART 64 #define EO_NOTHROTTLE 128 #define EO_CLIPSIDES 256 -//ch4: this constant isn't used at all, snap is always name-based -//#define EO_SNAPNAME 512 #define EO_HIDEMENU 2048 #define EO_HIGHPRIO 4096 #define EO_FORCEASPECT 8192 diff --git a/src/drivers/win/video.h b/src/drivers/win/video.h index 1ecf4f06..d599fcee 100644 --- a/src/drivers/win/video.h +++ b/src/drivers/win/video.h @@ -56,4 +56,7 @@ void ResetVideo(); void SetFSVideoMode(); void PushCurrentVideoSettings(); +std::string FCEUI_GetSnapshotAsName(); +void FCEUI_SetSnapshotAsName(std::string name); + #endif diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 0254c8cd..53e897c0 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -12,7 +12,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. -* +*f * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -133,7 +133,6 @@ static uint32 mousex,mousey,mouseb; static int vchanged = 0; int menuYoffset = 0; bool wasPausedByCheats = false; //For unpausing the emulator if paused by the cheats dialog - bool rightClickEnabled = true; //If set to false, the right click context menu will be disabled. //Function Prototypes @@ -142,6 +141,7 @@ void ChangeContextMenuItemText(int menuitem, string text, HMENU menu); //Alters void SaveMovieAs(); //Gets a filename for Save Movie As... void OpenRamSearch(); void OpenRamWatch(); +void SaveSnapshotAs(); //Recent Menu Strings ------------------------------------ char *recent_files[] = { 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }; @@ -1643,7 +1643,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) FCEUI_SaveSnapshot(); break; case ID_FILE_SAVESCREENSHOTAS: - FCEUI_SaveSnapshotAs(); + SaveSnapshotAs(); break; //Lua submenu @@ -2842,4 +2842,31 @@ void OpenRamSearch() void OpenRamWatch() { RamWatchHWnd = CreateDialog(fceu_hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), MainhWnd, (DLGPROC) RamWatchProc); +} + +void SaveSnapshotAs() +{ + const char filter[] = "Snapshot (*.png)\0*.png\0All Files (*.*)\0*.*\0\0"; + char nameo[512]; + OPENFILENAME ofn; + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hInstance = fceu_hInstance; + ofn.lpstrTitle = "Save Snapshot As..."; + ofn.lpstrFilter = filter; + strcpy(nameo,FCEU_MakeFName(FCEUMKF_SNAP,0,"png").c_str()); + + nameo[strlen(nameo)-6] = '\0'; + + ofn.lpstrFile = nameo; + ofn.lpstrDefExt = "fcs"; + std::string initdir = FCEU_GetPath(FCEUMKF_SNAP); + ofn.lpstrInitialDir = initdir.c_str(); + ofn.nMaxFile = 256; + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + ofn.lpstrDefExt = "png"; + + if(GetSaveFileName(&ofn)) + FCEUI_SetSnapshotAsName(nameo); + FCEUI_SaveSnapshotAs(); } \ No newline at end of file diff --git a/src/video.cpp b/src/video.cpp index 46238f64..3a55887d 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -77,6 +77,11 @@ bool oldInputDisplay = false; HANDLE mapXBuf; #endif +std::string AsSnapshotName =""; //adelikat:this will set the snapshot name when for s savesnapshot as function + +void FCEUI_SetSnapshotAsName(std::string name) { AsSnapshotName = name; } +std::string FCEUI_GetSnapshotAsName() { return AsSnapshotName; } + void FCEU_KillVirtualVideo(void) { //mbg merge TODO 7/17/06 temporarily removed @@ -202,31 +207,12 @@ void FCEU_PutImage(void) #ifdef SHOWFPS ShowFPS(); #endif - if(dosnapsave==2) + if(dosnapsave==2) //Save screenshot as, currently only flagged & run by the Win32 build. //TODO SDL: implement this? { #ifdef WIN32 - const char filter[] = "Snapshot (*.png)\0*.png\0All Files (*.*)\0*.*\0\0"; char nameo[512]; - OPENFILENAME ofn; - - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hInstance = fceu_hInstance; - ofn.lpstrTitle = "Save Snapshot As..."; - ofn.lpstrFilter = filter; - strcpy(nameo,FCEU_MakeFName(FCEUMKF_SNAP,0,"png").c_str()); - - nameo[strlen(nameo)-6] = '\0'; - - ofn.lpstrFile = nameo; - ofn.lpstrDefExt = "fcs"; - std::string initdir = FCEU_GetPath(FCEUMKF_SNAP); - ofn.lpstrInitialDir = initdir.c_str(); - ofn.nMaxFile = 256; - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - ofn.lpstrDefExt = "png"; - dosnapsave=0; - if(GetSaveFileName(&ofn)) + strcpy(nameo,FCEUI_GetSnapshotAsName().c_str()); + if (nameo) { SaveSnapshot(nameo); FCEU_DispMessage("Snapshot Saved.",0); @@ -680,6 +666,8 @@ PNGerr: fclose(pp); return(0); } + +//overloaded SaveSnapshot for "Savesnapshot As" function int SaveSnapshot(char fileName[512]) { int totallines=FSettings.LastSLine-FSettings.FirstSLine+1;