FullscreenUI: Fix loading undo state from menu

This commit is contained in:
Stenzek 2024-06-11 13:07:47 +10:00
parent f41c238c53
commit b464b6d668
No known key found for this signature in database

View File

@ -5724,8 +5724,8 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading)
closed = true; closed = true;
} }
if (ActiveButton(FSUI_ICONSTR(ICON_FA_FOLDER_MINUS, "Delete Save"), false, true, if (!entry.path.empty() && ActiveButton(FSUI_ICONSTR(ICON_FA_FOLDER_MINUS, "Delete Save"), false, true,
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY)) LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
{ {
if (!FileSystem::FileExists(entry.path.c_str())) if (!FileSystem::FileExists(entry.path.c_str()))
{ {
@ -6023,11 +6023,20 @@ void FullscreenUI::DoLoadState(std::string path)
if (System::IsValid()) if (System::IsValid())
{ {
Error error; if (path.empty())
if (!System::LoadState(path.c_str(), &error))
{ {
Host::ReportErrorAsync(TRANSLATE_SV("System", "Error"), // Loading undo state.
fmt::format(TRANSLATE_FS("System", "Failed to load state: {}"), error.GetDescription())); 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 else
@ -6049,8 +6058,7 @@ void FullscreenUI::DoSaveState(s32 slot, bool global)
Error error; Error error;
if (!System::SaveState(filename.c_str(), &error, g_settings.create_save_state_backups)) if (!System::SaveState(filename.c_str(), &error, g_settings.create_save_state_backups))
{ {
Host::ReportErrorAsync(TRANSLATE_SV("System", "Error"), ShowToast(std::string(), fmt::format(TRANSLATE_FS("System", "Failed to save state: {}"), error.GetDescription()));
fmt::format(TRANSLATE_FS("System", "Failed to save state: {}"), error.GetDescription()));
} }
}); });
} }