diff --git a/changelog.txt b/changelog.txt index 61d1e133..67fad6bb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,7 @@ ---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: --no8lim option renamed to --nospritelim 10-aug-2008 - punkrockguy318 - SDL: --color option renamed to --ntsccolor diff --git a/src/drivers/sdl/config.cpp b/src/drivers/sdl/config.cpp index 2e547c66..98f39074 100644 --- a/src/drivers/sdl/config.cpp +++ b/src/drivers/sdl/config.cpp @@ -270,7 +270,6 @@ InitConfig() config->addOption(prefix + "LoadState", SDLK_F7); config->addOption(prefix + "Reset", SDLK_F9); config->addOption(prefix + "Screenshot", SDLK_F12); - config->addOption(prefix + "Quit", SDLK_ESCAPE); config->addOption(prefix + "Pause", SDLK_PAUSE); config->addOption(prefix + "DecreaseSpeed", SDLK_MINUS); config->addOption(prefix + "IncreaseSpeed", SDLK_EQUALS); diff --git a/src/drivers/sdl/input.cpp b/src/drivers/sdl/input.cpp index b10e17c1..21c641f4 100644 --- a/src/drivers/sdl/input.cpp +++ b/src/drivers/sdl/input.cpp @@ -147,11 +147,13 @@ static int g_fkbEnabled = 0; * This function opens a file chooser dialog and returns the filename the * user selected. * */ -std::string GetFilename() +std::string GetFilename(const char* title) { + if (FCEUI_EmulationPaused() == 0) + FCEUI_ToggleEmulationPause(); std::string fname = ""; + #ifdef WIN32 - // TODO: WIN32 file chooser code goes here OPENFILENAME ofn; // common dialog box structure char szFile[260]; // buffer for file name HWND hwnd; // owner window @@ -178,18 +180,26 @@ std::string GetFilename() #else FILE *fpipe; - - if ( !(fpipe = (FILE*)popen("zenity --file-selection","r")) ) + std::string command = "zenity --file-selection --title=\""; + command.append(title); + command.append("\""); + if ( !(fpipe = (FILE*)popen(command.c_str(),"r")) ) { // If fpipe is NULL FCEUD_PrintError("Pipe error on opening zenity"); } int c; - while((c = fgetc (fpipe ))!= '\n') + while( (c = fgetc(fpipe)) ) + { + if (c == EOF) + break; + if (c == '\n') + break; fname += c; + } pclose(fpipe); #endif - + FCEUI_ToggleEmulationPause(); return fname; } @@ -200,9 +210,7 @@ static void KeyboardCommands() { int is_shift, is_alt, key; - - const char* movie_fname = FCEU_MakeFName(FCEUMKF_MOVIE, 0, 0).c_str(); - + char* movie_fname = ""; // get the keyboard input g_keyState = SDL_GetKeyState(NULL); @@ -269,7 +277,8 @@ KeyboardCommands() g_config->getOption("SDL.Hotkeys.SaveState", &key); if(_keyonly(key)) { - if(is_shift) { + if(is_shift) { + movie_fname = const_cast(FCEU_MakeFName(FCEUMKF_MOVIE, 0, 0).c_str()); FCEUI_printf("Recording movie to %s\n", movie_fname); FCEUI_SaveMovie(movie_fname, MOVIE_FLAG_NONE, L""); } else { @@ -281,9 +290,14 @@ KeyboardCommands() // f7 to load state, Shift-f7 to load movie if(_keyonly(key)) { if(is_shift) { - FCEUI_StopMovie(); - FCEUI_printf("Playing back movie located at %s\n", movie_fname); - FCEUI_LoadMovie(movie_fname , false, false, false); + FCEUI_StopMovie(); + std::string fname; + 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 { FCEUI_LoadState(NULL); } @@ -331,8 +345,9 @@ KeyboardCommands() g_config->getOption("SDL.Hotkeys.LoadLua", &key); if(_keyonly(key)) { std::string fname; - fname = GetFilename(); - FCEU_LoadLuaCode(fname.c_str()); + fname = GetFilename("Open LUA script..."); + if(fname != "") + FCEU_LoadLuaCode(fname.c_str()); } // VS Unisystem games diff --git a/src/drivers/sdl/sdl.cpp b/src/drivers/sdl/sdl.cpp index 31cd8f09..a9cec03b 100644 --- a/src/drivers/sdl/sdl.cpp +++ b/src/drivers/sdl/sdl.cpp @@ -472,12 +472,9 @@ SDL_GL_LoadLibrary(0); } CloseGame(); - // save the configuration information? - //SaveConfig(); // exit the infrastructure FCEUI_Kill(); - SDL_Quit(); return 0; } diff --git a/src/file.cpp b/src/file.cpp index 15c53a0c..9a034ff9 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -519,7 +519,7 @@ std::string FCEU_MakePath(int type, const char* filebase) std::string FCEU_MakeFName(int type, int id1, char *cd1) { - char ret[FILENAME_MAX]; + char ret[FILENAME_MAX] = ""; struct stat tmpstat; std::string mfnString; const char* mfn; @@ -527,10 +527,14 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1) switch(type) { case FCEUMKF_MOVIE: - if(odirs[FCEUIOD_MOVIES]) - sprintf(ret,"%s"PSS"%s.fm2",odirs[FCEUIOD_MOVIES],FileBase); - else - sprintf(ret,"%s"PSS"movie"PSS"%s.fm2",BaseDirectory.c_str(),FileBase); + struct stat fileInfo; + do { + if(odirs[FCEUIOD_MOVIES]) + 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; case FCEUMKF_STATE: { @@ -558,20 +562,10 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1) } break; case FCEUMKF_SNAP: - if(FSettings.SnapName) - { - 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); - } + if(odirs[FCEUIOD_SNAPS]) + sprintf(ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1); else - { - 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); - } + sprintf(ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory.c_str(),FileBase,id1,cd1); break; case FCEUMKF_FDS: if(odirs[FCEUIOD_NV]) @@ -593,7 +587,6 @@ std::string FCEU_MakeFName(int type, int id1, char *cd1) } break; case FCEUMKF_AUTOSTATE: - extern char curMovieFilename[512]; mfnString = GetMfn(); mfn = mfnString.c_str(); if(odirs[FCEUIOD_STATES])