diff --git a/src/main.cpp b/src/main.cpp index a23eb5ad7..2854a867a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1076,6 +1076,7 @@ static void parse_cmdline (int argc, TCHAR **argv) savestate_state = STATE_DORESTORE; xfree(txt); } + SetLastActiveConfig(txt); #endif } loaded = true; @@ -1175,6 +1176,7 @@ static void parse_cmdline (int argc, TCHAR **argv) savestate_state = STATE_DORESTORE; currprefs.start_gui = false; } + SetLastActiveConfig(txt); } else if (_tcscmp(txt2.c_str(), ".cue") == 0 || _tcscmp(txt2.c_str(), ".iso") == 0 diff --git a/src/osdep/amiberry.cpp b/src/osdep/amiberry.cpp index 4fd1cf5ba..55b4a2ea9 100644 --- a/src/osdep/amiberry.cpp +++ b/src/osdep/amiberry.cpp @@ -4467,8 +4467,6 @@ int main(int argc, char* argv[]) abort(); } - snprintf(savestate_fname, sizeof savestate_fname, "%s/default.ads", fix_trailing(savestate_dir).c_str()); - reginitializeinit(&inipath); if (getregmode() == NULL) { diff --git a/src/osdep/amiberry_gui.cpp b/src/osdep/amiberry_gui.cpp index dd2f6cd75..93af3d42a 100644 --- a/src/osdep/amiberry_gui.cpp +++ b/src/osdep/amiberry_gui.cpp @@ -922,10 +922,12 @@ int gui_update() filename = extract_filename(currprefs.floppyslots[0].df); else if (currprefs.cdslots[0].inuse && strlen(currprefs.cdslots[0].name) > 0) filename = extract_filename(currprefs.cdslots[0].name); + else if (!whdload_prefs.whdload_filename.empty()) + filename = extract_filename(whdload_prefs.whdload_filename); + else if (strlen(last_loaded_config) > 0) + filename = extract_filename(std::string(last_loaded_config)); else - { - last_loaded_config[0] != '\0' ? filename = std::string(last_loaded_config) : filename = "default.uae"; - } + return 0; get_savestate_path(savestate_fname, MAX_DPATH - 1); strncat(savestate_fname, filename.c_str(), MAX_DPATH - 1); diff --git a/src/osdep/gui/PanelSavestate.cpp b/src/osdep/gui/PanelSavestate.cpp index 8286696ff..b07f48217 100644 --- a/src/osdep/gui/PanelSavestate.cpp +++ b/src/osdep/gui/PanelSavestate.cpp @@ -26,7 +26,7 @@ static gcn::Image* imgSavestate = nullptr; static gcn::Button* cmdLoadState; static gcn::Button* cmdSaveState; -std::string get_file_timestamp(const std::string& filename) +static std::string get_file_timestamp(const std::string& filename) { struct stat st {}; tm tm{}; @@ -52,7 +52,6 @@ class SavestateActionListener : public gcn::ActionListener { current_state_num = std::distance(radioButtons.begin(), it); } - else if (actionEvent.getSource() == cmdLoadState) { //------------------------------------------ @@ -70,12 +69,16 @@ class SavestateActionListener : public gcn::ActionListener savestate_state = STATE_DORESTORE; gui_running = false; } + else + { + ShowMessage("Loading savestate", "Statefile doesn't exist.", "", "", "Ok", ""); + } } - if (savestate_state != STATE_DORESTORE) - ShowMessage("Loading savestate", "Statefile doesn't exist.", "", "", "Ok", ""); } else + { ShowMessage("Loading savestate", "Emulation hasn't started yet.", "", "", "Ok", ""); + } cmdLoadState->requestFocus(); } @@ -107,7 +110,9 @@ class SavestateActionListener : public gcn::ActionListener save_thumb(screenshot_filename); } else + { ShowMessage("Saving state", "Emulation hasn't started yet.", "", "", "Ok", ""); + } cmdSaveState->requestFocus(); } @@ -210,7 +215,7 @@ void RefreshPanelSavestate() imgSavestate = nullptr; } - if (current_state_num >= 0 && current_state_num < radioButtons.size()) { + if (current_state_num >= 0 && current_state_num < static_cast(radioButtons.size())) { radioButtons[current_state_num]->setSelected(true); } @@ -222,50 +227,50 @@ void RefreshPanelSavestate() if (f) { fclose(f); lblTimestamp->setCaption(get_file_timestamp(savestate_fname)); + + if (!screenshot_filename.empty()) + { + auto* const screenshot_file = fopen(screenshot_filename.c_str(), "rbe"); + if (screenshot_file) + { + fclose(screenshot_file); + const auto rect = grpScreenshot->getChildrenArea(); + auto* loaded_image = IMG_Load(screenshot_filename.c_str()); + if (loaded_image != nullptr) + { + const SDL_Rect source = { 0, 0, loaded_image->w, loaded_image->h }; + const SDL_Rect target = { 0, 0, rect.width, rect.height }; + auto* scaled = SDL_CreateRGBSurface(0, rect.width, rect.height, + loaded_image->format->BitsPerPixel, + loaded_image->format->Rmask, loaded_image->format->Gmask, + loaded_image->format->Bmask, loaded_image->format->Amask); + SDL_SoftStretch(loaded_image, &source, scaled, &target); + SDL_FreeSurface(loaded_image); + imgSavestate = new gcn::SDLImage(scaled, true); + icoSavestate = new gcn::Icon(imgSavestate); + grpScreenshot->add(icoSavestate); + } + } + } } else { - lblTimestamp->setCaption("No savestate found"); + lblTimestamp->setCaption("No savestate found: " + extract_filename(std::string(savestate_fname))); } } - - if (screenshot_filename.length() > 0) + else { - auto* const f = fopen(screenshot_filename.c_str(), "rbe"); - if (f) - { - fclose(f); - const auto rect = grpScreenshot->getChildrenArea(); - auto* loadedImage = IMG_Load(screenshot_filename.c_str()); - if (loadedImage != nullptr) - { - SDL_Rect source = {0, 0, 0, 0}; - SDL_Rect target = {0, 0, 0, 0}; - auto* scaled = SDL_CreateRGBSurface(0, rect.width, rect.height, - loadedImage->format->BitsPerPixel, - loadedImage->format->Rmask, loadedImage->format->Gmask, - loadedImage->format->Bmask, loadedImage->format->Amask); - source.w = loadedImage->w; - source.h = loadedImage->h; - target.w = rect.width; - target.h = rect.height; - SDL_SoftStretch(loadedImage, &source, scaled, &target); - SDL_FreeSurface(loadedImage); - loadedImage = nullptr; - imgSavestate = new gcn::SDLImage(scaled, true); - icoSavestate = new gcn::Icon(imgSavestate); - grpScreenshot->add(icoSavestate); - } - } + lblTimestamp->setCaption("No savestate loaded"); } + lblTimestamp->adjustSize(); for (const auto& radioButton : radioButtons) { radioButton->setEnabled(true); } grpScreenshot->setVisible(true); - cmdLoadState->setEnabled(true); - cmdSaveState->setEnabled(true); + cmdLoadState->setEnabled(strlen(savestate_fname) > 0); + cmdSaveState->setEnabled(strlen(savestate_fname) > 0); } bool HelpPanelSavestate(std::vector& helptext)