diff options
-rw-r--r-- | engines/prince/prince.cpp | 8 | ||||
-rw-r--r-- | engines/prince/prince.h | 2 | ||||
-rw-r--r-- | engines/prince/saveload.cpp | 34 |
3 files changed, 44 insertions, 0 deletions
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index b31a319e23..ae2457640c 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -544,6 +544,14 @@ void PrinceEngine::setMobTranslationTexts() { void PrinceEngine::keyHandler(Common::Event event) { uint16 nChar = event.kbd.keycode; switch (nChar) { + case Common::KEYCODE_F1: + if (canLoadGameStateCurrently()) + scummVMSaveLoadDialog(false); + break; + case Common::KEYCODE_F2: + if (canSaveGameStateCurrently()) + scummVMSaveLoadDialog(true); + break; case Common::KEYCODE_d: if (event.kbd.hasFlags(Common::KBD_CTRL)) { getDebugger()->attach(); diff --git a/engines/prince/prince.h b/engines/prince/prince.h index efebd4c286..e0b9490c37 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -279,6 +279,8 @@ public: PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc); virtual ~PrinceEngine(); + bool scummVMSaveLoadDialog(bool isSave); + virtual bool hasFeature(EngineFeature f) const; virtual void pauseEngineIntern(bool pause); virtual bool canSaveGameStateCurrently(); diff --git a/engines/prince/saveload.cpp b/engines/prince/saveload.cpp index e91bc3476b..b1d9fc49fd 100644 --- a/engines/prince/saveload.cpp +++ b/engines/prince/saveload.cpp @@ -30,12 +30,15 @@ #include "common/system.h" #include "common/config-manager.h" #include "common/memstream.h" +#include "common/translation.h" #include "graphics/thumbnail.h" #include "graphics/surface.h" #include "graphics/palette.h" #include "graphics/scaler.h" +#include "gui/saveload.h" + namespace Prince { #define kSavegameVersion 1 @@ -43,6 +46,37 @@ namespace Prince { class InterpreterFlags; class Interpreter; +bool PrinceEngine::scummVMSaveLoadDialog(bool isSave) { + GUI::SaveLoadChooser *dialog; + Common::String desc; + int slot; + + if (isSave) { + dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); + + slot = dialog->runModalWithCurrentTarget(); + desc = dialog->getResultString(); + + if (desc.empty()) { + desc = dialog->createDefaultSaveDescription(slot); + } + } else { + dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); + slot = dialog->runModalWithCurrentTarget(); + } + + delete dialog; + + if (slot < 0) + return false; + + if (isSave) { + return saveGameState(slot, desc).getCode() == Common::kNoError; + } else { + return loadGameState(slot).getCode() == Common::kNoError; + } +} + WARN_UNUSED_RESULT bool PrinceEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header, bool skipThumbnail) { header.version = 0; header.saveName.clear(); |