added file open dialog to movie playback and other bugfixes

This commit is contained in:
punkrockguy318 2008-08-10 15:24:30 +00:00
parent 88b1fffe9d
commit 60147db30f
5 changed files with 45 additions and 38 deletions

View File

@ -1,4 +1,7 @@
---version 2.0.2 released--- ---version 2.0.2 released---
10-aug-2008 - punkrockguy318 - SDL: fixed bug where fceux would close when file dialogs were closed
10-aug-2008 - punkrockguy318 - SDL: File open dialog is now used to movie playback
10-aug-2008 - punkrockguy318 - SDL: File open wrapper now takes a titlebar argument
10-aug-2008 - punkrockguy318 - SDL: Cleanup of usage 10-aug-2008 - punkrockguy318 - SDL: Cleanup of usage
10-aug-2008 - punkrockguy318 - SDL: --no8lim option renamed to --nospritelim 10-aug-2008 - punkrockguy318 - SDL: --no8lim option renamed to --nospritelim
10-aug-2008 - punkrockguy318 - SDL: --color option renamed to --ntsccolor 10-aug-2008 - punkrockguy318 - SDL: --color option renamed to --ntsccolor

View File

@ -270,7 +270,6 @@ InitConfig()
config->addOption(prefix + "LoadState", SDLK_F7); config->addOption(prefix + "LoadState", SDLK_F7);
config->addOption(prefix + "Reset", SDLK_F9); config->addOption(prefix + "Reset", SDLK_F9);
config->addOption(prefix + "Screenshot", SDLK_F12); config->addOption(prefix + "Screenshot", SDLK_F12);
config->addOption(prefix + "Quit", SDLK_ESCAPE);
config->addOption(prefix + "Pause", SDLK_PAUSE); config->addOption(prefix + "Pause", SDLK_PAUSE);
config->addOption(prefix + "DecreaseSpeed", SDLK_MINUS); config->addOption(prefix + "DecreaseSpeed", SDLK_MINUS);
config->addOption(prefix + "IncreaseSpeed", SDLK_EQUALS); config->addOption(prefix + "IncreaseSpeed", SDLK_EQUALS);

View File

@ -147,11 +147,13 @@ static int g_fkbEnabled = 0;
* This function opens a file chooser dialog and returns the filename the * This function opens a file chooser dialog and returns the filename the
* user selected. * user selected.
* */ * */
std::string GetFilename() std::string GetFilename(const char* title)
{ {
if (FCEUI_EmulationPaused() == 0)
FCEUI_ToggleEmulationPause();
std::string fname = ""; std::string fname = "";
#ifdef WIN32 #ifdef WIN32
// TODO: WIN32 file chooser code goes here
OPENFILENAME ofn; // common dialog box structure OPENFILENAME ofn; // common dialog box structure
char szFile[260]; // buffer for file name char szFile[260]; // buffer for file name
HWND hwnd; // owner window HWND hwnd; // owner window
@ -178,18 +180,26 @@ std::string GetFilename()
#else #else
FILE *fpipe; FILE *fpipe;
std::string command = "zenity --file-selection --title=\"";
if ( !(fpipe = (FILE*)popen("zenity --file-selection","r")) ) command.append(title);
command.append("\"");
if ( !(fpipe = (FILE*)popen(command.c_str(),"r")) )
{ // If fpipe is NULL { // If fpipe is NULL
FCEUD_PrintError("Pipe error on opening zenity"); FCEUD_PrintError("Pipe error on opening zenity");
} }
int c; int c;
while((c = fgetc (fpipe ))!= '\n') while( (c = fgetc(fpipe)) )
{
if (c == EOF)
break;
if (c == '\n')
break;
fname += c; fname += c;
}
pclose(fpipe); pclose(fpipe);
#endif #endif
FCEUI_ToggleEmulationPause();
return fname; return fname;
} }
@ -200,9 +210,7 @@ static void
KeyboardCommands() KeyboardCommands()
{ {
int is_shift, is_alt, key; int is_shift, is_alt, key;
char* movie_fname = "";
const char* movie_fname = FCEU_MakeFName(FCEUMKF_MOVIE, 0, 0).c_str();
// get the keyboard input // get the keyboard input
g_keyState = SDL_GetKeyState(NULL); g_keyState = SDL_GetKeyState(NULL);
@ -269,7 +277,8 @@ KeyboardCommands()
g_config->getOption("SDL.Hotkeys.SaveState", &key); g_config->getOption("SDL.Hotkeys.SaveState", &key);
if(_keyonly(key)) { if(_keyonly(key)) {
if(is_shift) { if(is_shift) {
movie_fname = const_cast<char*>(FCEU_MakeFName(FCEUMKF_MOVIE, 0, 0).c_str());
FCEUI_printf("Recording movie to %s\n", movie_fname); FCEUI_printf("Recording movie to %s\n", movie_fname);
FCEUI_SaveMovie(movie_fname, MOVIE_FLAG_NONE, L""); FCEUI_SaveMovie(movie_fname, MOVIE_FLAG_NONE, L"");
} else { } else {
@ -281,9 +290,14 @@ KeyboardCommands()
// f7 to load state, Shift-f7 to load movie // f7 to load state, Shift-f7 to load movie
if(_keyonly(key)) { if(_keyonly(key)) {
if(is_shift) { if(is_shift) {
FCEUI_StopMovie(); FCEUI_StopMovie();
FCEUI_printf("Playing back movie located at %s\n", movie_fname); std::string fname;
FCEUI_LoadMovie(movie_fname , false, false, false); fname = GetFilename("Open movie for playback...");
if(fname != "")
{
FCEUI_printf("Playing back movie located at %s\n", fname.c_str());
FCEUI_LoadMovie(fname.c_str(), false, false, false);
}
} else { } else {
FCEUI_LoadState(NULL); FCEUI_LoadState(NULL);
} }
@ -331,8 +345,9 @@ KeyboardCommands()
g_config->getOption("SDL.Hotkeys.LoadLua", &key); g_config->getOption("SDL.Hotkeys.LoadLua", &key);
if(_keyonly(key)) { if(_keyonly(key)) {
std::string fname; std::string fname;
fname = GetFilename(); fname = GetFilename("Open LUA script...");
FCEU_LoadLuaCode(fname.c_str()); if(fname != "")
FCEU_LoadLuaCode(fname.c_str());
} }
// VS Unisystem games // VS Unisystem games

View File

@ -472,12 +472,9 @@ SDL_GL_LoadLibrary(0);
} }
CloseGame(); CloseGame();
// save the configuration information?
//SaveConfig();
// exit the infrastructure // exit the infrastructure
FCEUI_Kill(); FCEUI_Kill();
SDL_Quit(); SDL_Quit();
return 0; return 0;
} }

View File

@ -519,7 +519,7 @@ std::string FCEU_MakePath(int type, const char* filebase)
std::string FCEU_MakeFName(int type, int id1, char *cd1) std::string FCEU_MakeFName(int type, int id1, char *cd1)
{ {
char ret[FILENAME_MAX]; char ret[FILENAME_MAX] = "";
struct stat tmpstat; struct stat tmpstat;
std::string mfnString; std::string mfnString;
const char* mfn; const char* mfn;
@ -527,10 +527,14 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
switch(type) switch(type)
{ {
case FCEUMKF_MOVIE: case FCEUMKF_MOVIE:
if(odirs[FCEUIOD_MOVIES]) struct stat fileInfo;
sprintf(ret,"%s"PSS"%s.fm2",odirs[FCEUIOD_MOVIES],FileBase); do {
else if(odirs[FCEUIOD_MOVIES])
sprintf(ret,"%s"PSS"movie"PSS"%s.fm2",BaseDirectory.c_str(),FileBase); sprintf(ret,"%s"PSS"%s-%d.fm2",odirs[FCEUIOD_MOVIES],FileBase, id1);
else
sprintf(ret,"%s"PSS"movie"PSS"%s-%d.fm2",BaseDirectory.c_str(),FileBase, id1);
id1++;
} while (stat(ret, &fileInfo) == 0);
break; break;
case FCEUMKF_STATE: case FCEUMKF_STATE:
{ {
@ -558,20 +562,10 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
} }
break; break;
case FCEUMKF_SNAP: case FCEUMKF_SNAP:
if(FSettings.SnapName) if(odirs[FCEUIOD_SNAPS])
{ sprintf(ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1);
if(odirs[FCEUIOD_SNAPS])
sprintf(ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1);
else
sprintf(ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory.c_str(),FileBase,id1,cd1);
}
else else
{ sprintf(ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory.c_str(),FileBase,id1,cd1);
if(odirs[FCEUIOD_SNAPS])
sprintf(ret,"%s"PSS"%d.%s",odirs[FCEUIOD_SNAPS],id1,cd1);
else
sprintf(ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory.c_str(),id1,cd1);
}
break; break;
case FCEUMKF_FDS: case FCEUMKF_FDS:
if(odirs[FCEUIOD_NV]) if(odirs[FCEUIOD_NV])
@ -593,7 +587,6 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1)
} }
break; break;
case FCEUMKF_AUTOSTATE: case FCEUMKF_AUTOSTATE:
extern char curMovieFilename[512];
mfnString = GetMfn(); mfnString = GetMfn();
mfn = mfnString.c_str(); mfn = mfnString.c_str();
if(odirs[FCEUIOD_STATES]) if(odirs[FCEUIOD_STATES])