Skip to content

Commit

Permalink
SaveStateSelectorUI: Decouple current slot from list
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Dec 17, 2023
1 parent cffb383 commit 73968ac
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 106 deletions.
Binary file added data/resources/no-save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/core/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void Host::ReleaseGPUDevice()
if (!g_gpu_device)
return;

SaveStateSelectorUI::DestroyTextures();
ImGuiManager::DestroyOverlayTextures();
FullscreenUI::Shutdown();
ImGuiManager::Shutdown();

Expand Down
21 changes: 15 additions & 6 deletions src/core/hotkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include "achievements.h"
#include "cpu_code_cache.h"
#include "cpu_core.h"
#include "cpu_pgxp.h"
#include "fullscreen_ui.h"
#include "gpu.h"
#include "host.h"
#include "imgui_overlays.h"
#include "cpu_pgxp.h"
#include "settings.h"
#include "spu.h"
#include "system.h"
Expand Down Expand Up @@ -68,7 +68,7 @@ static void HotkeyLoadStateSlot(bool global, s32 slot)
if (!global && System::GetGameSerial().empty())
{
Host::AddKeyedOSDMessage("LoadState", TRANSLATE_NOOP("OSDMessage", "Cannot load state for game without serial."),
5.0f);
Host::OSD_ERROR_DURATION);
return;
}

Expand All @@ -77,7 +77,8 @@ static void HotkeyLoadStateSlot(bool global, s32 slot)
if (!FileSystem::FileExists(path.c_str()))
{
Host::AddKeyedOSDMessage("LoadState",
fmt::format(TRANSLATE_NOOP("OSDMessage", "No save state found in slot {}."), slot), 5.0f);
fmt::format(TRANSLATE_NOOP("OSDMessage", "No save state found in slot {}."), slot),
Host::OSD_INFO_DURATION);
return;
}

Expand All @@ -92,7 +93,7 @@ static void HotkeySaveStateSlot(bool global, s32 slot)
if (!global && System::GetGameSerial().empty())
{
Host::AddKeyedOSDMessage("LoadState", TRANSLATE_NOOP("OSDMessage", "Cannot save state for game without serial."),
5.0f);
Host::OSD_ERROR_DURATION);
return;
}

Expand Down Expand Up @@ -518,12 +519,20 @@ DEFINE_HOTKEY("SaveSelectedSaveState", TRANSLATE_NOOP("Hotkeys", "Save States"),
DEFINE_HOTKEY("SelectPreviousSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Select Previous Save Slot"), [](s32 pressed) {
if (!pressed)
Host::RunOnCPUThread(SaveStateSelectorUI::SelectPreviousSlot);
Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectPreviousSlot(true); });
})
DEFINE_HOTKEY("SelectNextSaveStateSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Select Next Save Slot"), [](s32 pressed) {
if (!pressed)
Host::RunOnCPUThread(SaveStateSelectorUI::SelectNextSlot);
Host::RunOnCPUThread([]() { SaveStateSelectorUI::SelectNextSlot(true); });
})
DEFINE_HOTKEY("SaveStateAndSelectNextSlot", TRANSLATE_NOOP("Hotkeys", "Save States"),
TRANSLATE_NOOP("Hotkeys", "Save State and Select Next Slot"), [](s32 pressed) {
if (!pressed && System::IsValid())
{
SaveStateSelectorUI::SaveCurrentSlot();
SaveStateSelectorUI::SelectNextSlot(false);
}
})

DEFINE_HOTKEY("UndoLoadState", TRANSLATE_NOOP("Hotkeys", "Save States"), TRANSLATE_NOOP("Hotkeys", "Undo Load State"),
Expand Down
Loading

0 comments on commit 73968ac

Please sign in to comment.