Decouple save states from UI.

It's the UI's job to decide how and what things are displayed, not Core's.
This also reduces reasons for linkage issues.
This commit is contained in:
Unknown W. Brackets committed 2016-05-27 21:25:05 -07:00
1 parent 2862253f12
commit 27d135d48a
7 files changed
+58 -35

No files matched your search

+13 -6
View File
@@ -218,7 +218,14 @@ void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) {
RecreateViews();
}
static void AfterStateLoad(bool success, void *ignored) {
static void AfterSaveStateAction(bool success, const std::string &message, void *) {
if (!message.empty()) {
osm.Show(message, 2.0);
}
}
static void AfterStateBoot(bool success, const std::string &message, void *ignored) {
AfterSaveStateAction(success, message, ignored);
Core_EnableStepping(false);
host->UpdateDisassembly();
}
@@ -252,7 +259,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
} else if (!strcmp(message, "boot")) {
const char *ext = strrchr(value, '.');
if (ext != nullptr && !strcmp(ext, ".ppst")) {
SaveState::Load(value, &AfterStateLoad);
SaveState::Load(value, &AfterStateBoot);
} else {
PSP_Shutdown();
bootPending_ = true;
@@ -385,16 +392,16 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) {
case VIRTKEY_REWIND:
if (SaveState::CanRewind()) {
SaveState::Rewind();
SaveState::Rewind(&AfterSaveStateAction);
} else {
osm.Show(sc->T("norewind", "No rewind save states available"), 2.0);
}
break;
case VIRTKEY_SAVE_STATE:
SaveState::SaveSlot(gamePath_, g_Config.iCurrentStateSlot, SaveState::Callback());
SaveState::SaveSlot(gamePath_, g_Config.iCurrentStateSlot, &AfterSaveStateAction);
break;
case VIRTKEY_LOAD_STATE:
SaveState::LoadSlot(gamePath_, g_Config.iCurrentStateSlot, SaveState::Callback());
SaveState::LoadSlot(gamePath_, g_Config.iCurrentStateSlot, &AfterSaveStateAction);
break;
case VIRTKEY_NEXT_SLOT:
SaveState::NextSlot();
@@ -1024,7 +1031,7 @@ void EmuScreen::autoLoad() {
//check if save state has save, if so, load
int lastSlot = SaveState::GetNewestSlot(gamePath_);
if (g_Config.bEnableAutoLoad && lastSlot != -1) {
SaveState::LoadSlot(gamePath_, lastSlot, SaveState::Callback(), 0);
SaveState::LoadSlot(gamePath_, lastSlot, &AfterSaveStateAction);
g_Config.iCurrentStateSlot = lastSlot;
}
}