[Scummvm-git-logs] scummvm master -> 589f0f875070f0e8bd7b2cbf395818fbc934f822
bonki
bonki at users.noreply.github.com
Sun May 6 02:27:03 CEST 2018
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
589f0f8750 PRINCE: Use ScummVM save/load dialogs
Commit: 589f0f875070f0e8bd7b2cbf395818fbc934f822
https://github.com/scummvm/scummvm/commit/589f0f875070f0e8bd7b2cbf395818fbc934f822
Author: Adrian Frühwirth (bonki at users.noreply.github.com)
Date: 2018-05-06T02:26:28+02:00
Commit Message:
PRINCE: Use ScummVM save/load dialogs
The original option dialogs do not seem to be implemented yet so we
always show the ScummVM ones when using the save/load hotkeys for now.
This partly fixes Trac#9866.
Changed paths:
engines/prince/prince.cpp
engines/prince/prince.h
engines/prince/saveload.cpp
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index b31a319..ae24576 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 efebd4c..e0b9490 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 e91bc34..b1d9fc4 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();
More information about the Scummvm-git-logs
mailing list