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.
This commit is contained in:
Adrian Frühwirth 2018-05-06 02:16:40 +02:00
parent 488c22631b
commit 589f0f8750
3 changed files with 44 additions and 0 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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();