From b464b6d668b5c51d2e15c6c2d41f30ceaf75672c Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 11 Jun 2024 13:07:47 +1000 Subject: [PATCH] FullscreenUI: Fix loading undo state from menu --- src/core/fullscreen_ui.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index dc0217f08..471a2d4eb 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -5724,8 +5724,8 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading) closed = true; } - if (ActiveButton(FSUI_ICONSTR(ICON_FA_FOLDER_MINUS, "Delete Save"), false, true, - LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) + if (!entry.path.empty() && ActiveButton(FSUI_ICONSTR(ICON_FA_FOLDER_MINUS, "Delete Save"), false, true, + LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) { if (!FileSystem::FileExists(entry.path.c_str())) { @@ -6023,11 +6023,20 @@ void FullscreenUI::DoLoadState(std::string path) if (System::IsValid()) { - Error error; - if (!System::LoadState(path.c_str(), &error)) + if (path.empty()) { - Host::ReportErrorAsync(TRANSLATE_SV("System", "Error"), - fmt::format(TRANSLATE_FS("System", "Failed to load state: {}"), error.GetDescription())); + // Loading undo state. + if (!System::UndoLoadState()) + ShowToast(std::string(), TRANSLATE_STR("System", "Failed to undo load state.")); + } + else + { + Error error; + if (!System::LoadState(path.c_str(), &error)) + { + ShowToast(std::string(), + fmt::format(TRANSLATE_FS("System", "Failed to load state: {}"), error.GetDescription())); + } } } else @@ -6049,8 +6058,7 @@ void FullscreenUI::DoSaveState(s32 slot, bool global) Error error; if (!System::SaveState(filename.c_str(), &error, g_settings.create_save_state_backups)) { - Host::ReportErrorAsync(TRANSLATE_SV("System", "Error"), - fmt::format(TRANSLATE_FS("System", "Failed to save state: {}"), error.GetDescription())); + ShowToast(std::string(), fmt::format(TRANSLATE_FS("System", "Failed to save state: {}"), error.GetDescription())); } }); }