Clean up Deign's screenshot as code. Internally it is now set up for easy implementation in the SDL build.

This commit is contained in:
adelikat 2010-06-07 15:41:52 +00:00
parent cacd846515
commit 6faa55b21f
5 changed files with 44 additions and 27 deletions

View File

@ -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. 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 02-june-2010 - adelikat - Win32 - Movie Options Dialog - Fix so Full Savestate Load checkbox is updated on load

View File

@ -41,8 +41,6 @@ extern int eoptions;
#define EO_FOAFTERSTART 64 #define EO_FOAFTERSTART 64
#define EO_NOTHROTTLE 128 #define EO_NOTHROTTLE 128
#define EO_CLIPSIDES 256 #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_HIDEMENU 2048
#define EO_HIGHPRIO 4096 #define EO_HIGHPRIO 4096
#define EO_FORCEASPECT 8192 #define EO_FORCEASPECT 8192

View File

@ -56,4 +56,7 @@ void ResetVideo();
void SetFSVideoMode(); void SetFSVideoMode();
void PushCurrentVideoSettings(); void PushCurrentVideoSettings();
std::string FCEUI_GetSnapshotAsName();
void FCEUI_SetSnapshotAsName(std::string name);
#endif #endif

View File

@ -12,7 +12,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *f
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 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; static int vchanged = 0;
int menuYoffset = 0; int menuYoffset = 0;
bool wasPausedByCheats = false; //For unpausing the emulator if paused by the cheats dialog 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. bool rightClickEnabled = true; //If set to false, the right click context menu will be disabled.
//Function Prototypes //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 SaveMovieAs(); //Gets a filename for Save Movie As...
void OpenRamSearch(); void OpenRamSearch();
void OpenRamWatch(); void OpenRamWatch();
void SaveSnapshotAs();
//Recent Menu Strings ------------------------------------ //Recent Menu Strings ------------------------------------
char *recent_files[] = { 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }; 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(); FCEUI_SaveSnapshot();
break; break;
case ID_FILE_SAVESCREENSHOTAS: case ID_FILE_SAVESCREENSHOTAS:
FCEUI_SaveSnapshotAs(); SaveSnapshotAs();
break; break;
//Lua submenu //Lua submenu
@ -2842,4 +2842,31 @@ void OpenRamSearch()
void OpenRamWatch() void OpenRamWatch()
{ {
RamWatchHWnd = CreateDialog(fceu_hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), MainhWnd, (DLGPROC) RamWatchProc); 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();
} }

View File

@ -77,6 +77,11 @@ bool oldInputDisplay = false;
HANDLE mapXBuf; HANDLE mapXBuf;
#endif #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) void FCEU_KillVirtualVideo(void)
{ {
//mbg merge TODO 7/17/06 temporarily removed //mbg merge TODO 7/17/06 temporarily removed
@ -202,31 +207,12 @@ void FCEU_PutImage(void)
#ifdef SHOWFPS #ifdef SHOWFPS
ShowFPS(); ShowFPS();
#endif #endif
if(dosnapsave==2) if(dosnapsave==2) //Save screenshot as, currently only flagged & run by the Win32 build. //TODO SDL: implement this?
{ {
#ifdef WIN32 #ifdef WIN32
const char filter[] = "Snapshot (*.png)\0*.png\0All Files (*.*)\0*.*\0\0";
char nameo[512]; char nameo[512];
OPENFILENAME ofn; strcpy(nameo,FCEUI_GetSnapshotAsName().c_str());
if (nameo)
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))
{ {
SaveSnapshot(nameo); SaveSnapshot(nameo);
FCEU_DispMessage("Snapshot Saved.",0); FCEU_DispMessage("Snapshot Saved.",0);
@ -680,6 +666,8 @@ PNGerr:
fclose(pp); fclose(pp);
return(0); return(0);
} }
//overloaded SaveSnapshot for "Savesnapshot As" function
int SaveSnapshot(char fileName[512]) int SaveSnapshot(char fileName[512])
{ {
int totallines=FSettings.LastSLine-FSettings.FirstSLine+1; int totallines=FSettings.LastSLine-FSettings.FirstSLine+1;