FullscreenUI: Add undo load state to load menu

This commit is contained in:
Connor McLaughlin
2021-07-13 22:39:55 +10:00
parent 921c5cdfbf
commit ab9109f3b1
3 changed files with 74 additions and 20 deletions

View File

@ -2785,6 +2785,7 @@ void InitializeSaveStateListEntry(SaveStateListEntry* li, CommonHostInterface::E
li->summary =
StringUtil::StdStringFromFormat("%s - Saved %s", ssi->game_code.c_str(),
Timestamp::FromUnixTimestamp(ssi->timestamp).ToString("%c").GetCharArray());
li->slot = ssi->slot;
li->global = ssi->global;
li->path = std::move(ssi->path);
@ -2812,6 +2813,19 @@ void PopulateSaveStateListEntries()
{
s_save_state_selector_slots.clear();
if (s_save_state_selector_loading)
{
std::optional<CommonHostInterface::ExtendedSaveStateInfo> ssi = s_host_interface->GetUndoSaveStateInfo();
if (ssi)
{
SaveStateListEntry li;
InitializeSaveStateListEntry(&li, &ssi.value());
li.title = "Undo Load State";
li.summary = "Restores the state of the system prior to the last state loaded.";
s_save_state_selector_slots.push_back(std::move(li));
}
}
if (!System::GetRunningCode().empty())
{
for (s32 i = 1; i <= CommonHostInterface::PER_GAME_SAVE_STATE_SLOTS; i++)
@ -3025,7 +3039,11 @@ void DrawSaveStateSelector(bool is_loading, bool fullscreen)
{
const std::string& path = entry.path;
s_host_interface->RunLater([path]() {
s_host_interface->LoadState(path.c_str());
if (path.empty())
s_host_interface->UndoLoadState();
else
s_host_interface->LoadState(path.c_str());
CloseSaveStateSelector();
});
}