aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Bouclet2018-04-29 19:22:50 +0200
committerBastien Bouclet2018-06-14 21:04:44 +0200
commitc0fa7ceae5e23f09b3e28cca6900ccf2a8313e26 (patch)
tree32a49329107056cc488f089a8b6c9545d1b9a711
parent4ea8ed4ff5e835281615442de1ea0425743f9a20 (diff)
downloadscummvm-rg350-c0fa7ceae5e23f09b3e28cca6900ccf2a8313e26.tar.gz
scummvm-rg350-c0fa7ceae5e23f09b3e28cca6900ccf2a8313e26.tar.bz2
scummvm-rg350-c0fa7ceae5e23f09b3e28cca6900ccf2a8313e26.zip
MOHAWK: MYST: Clean up the options dialog
Also load and save games using ctrl-o / ctrl-s.
-rw-r--r--engines/mohawk/dialogs.cpp45
-rw-r--r--engines/mohawk/dialogs.h16
-rw-r--r--engines/mohawk/myst.cpp128
-rw-r--r--engines/mohawk/myst.h12
4 files changed, 130 insertions, 71 deletions
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index f4433152a8..a83116ed07 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -179,7 +179,13 @@ void MohawkOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd,
#ifdef ENABLE_MYST
-MystOptionsDialog::MystOptionsDialog(MohawkEngine_Myst* vm) : MohawkOptionsDialog(vm), _vm(vm) {
+MystOptionsDialog::MystOptionsDialog(MohawkEngine_Myst* vm) :
+ MohawkOptionsDialog(vm),
+ _vm(vm),
+ _canDropPage(false),
+ _canShowMap(false),
+ _canReturnToMenu(false) {
+
// I18N: Option for fast scene switching
_zipModeCheckbox = new GUI::CheckboxWidget(this, 15, 10, 220, 15, _("~Z~ip Mode Activated"), nullptr, kZipCmd);
_transitionsCheckbox = new GUI::CheckboxWidget(this, 15, 30, 220, 15, _("~T~ransitions Enabled"), nullptr, kTransCmd);
@@ -205,18 +211,15 @@ MystOptionsDialog::~MystOptionsDialog() {
void MystOptionsDialog::open() {
MohawkOptionsDialog::open();
- bool canDropPage = _vm->isInteractive() && _vm->_gameState->_globals.heldPage != kNoPage;
- _dropPageButton->setEnabled(canDropPage);
+ _dropPageButton->setEnabled(_canDropPage);
if (_showMapButton) {
- bool canShowMap = _vm->isInteractive() && _vm->_stack->getMap();
- _showMapButton->setEnabled(canShowMap);
+ _showMapButton->setEnabled(_canShowMap);
}
if (_returnToMenuButton) {
// Return to menu button is not enabled on the menu
- bool canReturnToMenu = _vm->isInteractive() && _vm->_stack->getStackId() != kDemoStack;
- _returnToMenuButton->setEnabled(canReturnToMenu);
+ _returnToMenuButton->setEnabled(_canReturnToMenu);
}
// Zip mode is disabled in the demo
@@ -230,32 +233,26 @@ void MystOptionsDialog::open() {
void MystOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kDropCmd:
- _vm->_needsPageDrop = true;
+ setResult(kActionDropPage);
close();
break;
case kMapCmd:
- _vm->_needsShowMap = true;
+ setResult(kActionShowMap);
close();
break;
case kMenuCmd:
- _vm->_needsShowDemoMenu = true;
+ setResult(kActionGoToMenu);
close();
break;
case kQuitCmd: {
- if (_vm->getGameType() != GType_MAKINGOF) {
- _vm->_needsShowCredits = true;
- } else {
- Common::Event eventQ;
- eventQ.type = Common::EVENT_QUIT;
- g_system->getEventManager()->pushEvent(eventQ);
- }
+ setResult(kActionShowCredits);
close();
}
break;
case GUI::kOKCmd:
_vm->_gameState->_globals.zipMode = _zipModeCheckbox->getState();
_vm->_gameState->_globals.transitions = _transitionsCheckbox->getState();
- setResult(1);
+ setResult(kActionNone);
close();
break;
default:
@@ -263,6 +260,18 @@ void MystOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, ui
}
}
+void MystOptionsDialog::setCanDropPage(bool canDropPage) {
+ _canDropPage = canDropPage;
+}
+
+void MystOptionsDialog::setCanShowMap(bool canShowMap) {
+ _canShowMap = canShowMap;
+}
+
+void MystOptionsDialog::setCanReturnToMenu(bool canReturnToMenu) {
+ _canReturnToMenu = canReturnToMenu;
+}
+
#endif
#ifdef ENABLE_RIVEN
diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h
index 9e892d768d..1de60d314b 100644
--- a/engines/mohawk/dialogs.h
+++ b/engines/mohawk/dialogs.h
@@ -115,12 +115,28 @@ public:
explicit MystOptionsDialog(MohawkEngine_Myst *vm);
~MystOptionsDialog() override;
+ enum ResultAction {
+ kActionNone = 1,
+ kActionDropPage,
+ kActionShowMap,
+ kActionGoToMenu,
+ kActionShowCredits
+ };
+
+ void setCanDropPage(bool canDropPage);
+ void setCanShowMap(bool canShowMap);
+ void setCanReturnToMenu(bool canReturnToMenu);
+
void open() override;
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
private:
MohawkEngine_Myst *_vm;
+ bool _canDropPage;
+ bool _canShowMap;
+ bool _canReturnToMenu;
+
GUI::CheckboxWidget *_zipModeCheckbox;
GUI::CheckboxWidget *_transitionsCheckbox;
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index eda9da501c..f7c0e9bf01 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -26,6 +26,8 @@
#include "common/translation.h"
#include "common/textconsole.h"
+#include "gui/saveload.h"
+
#include "mohawk/cursors.h"
#include "mohawk/myst.h"
#include "mohawk/myst_areas.h"
@@ -85,11 +87,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_mouseMoved = false;
_escapePressed = false;
_waitingOnBlockingOperation = false;
-
- _needsPageDrop = false;
- _needsShowCredits = false;
- _needsShowDemoMenu = false;
- _needsShowMap = false;
}
MohawkEngine_Myst::~MohawkEngine_Myst() {
@@ -415,51 +412,25 @@ void MohawkEngine_Myst::doFrame() {
pauseGame();
break;
case Common::KEYCODE_F5:
- _needsPageDrop = false;
- _needsShowMap = false;
- _needsShowDemoMenu = false;
- _needsShowCredits = false;
-
- runDialog(*_optionsDialog);
- if (_optionsDialog->getLoadSlot() >= 0)
- loadGameState(_optionsDialog->getLoadSlot());
- if (_optionsDialog->getSaveSlot() >= 0)
- saveGameState(_optionsDialog->getSaveSlot(), _optionsDialog->getSaveDescription());
-
- if (_needsPageDrop) {
- dropPage();
- _needsPageDrop = false;
- }
-
- if (_needsShowMap) {
- _stack->showMap();
- _needsShowMap = false;
- }
-
- if (_needsShowDemoMenu) {
- changeToStack(kDemoStack, 2002, 0, 0);
- _needsShowDemoMenu = false;
- }
-
- if (_needsShowCredits) {
- if (isInteractive()) {
- // Attempt to autosave before exiting
- tryAutoSaving();
-
- _cursor->hideCursor();
- changeToStack(kCreditsStack, 10000, 0, 0);
- _needsShowCredits = false;
- } else {
- // Showing the credits in the middle of a script is not possible
- // because it unloads the previous age, removing data needed by the
- // rest of the script. Instead we just quit without showing the credits.
- quitGame();
- }
- }
+ runOptionsDialog();
break;
case Common::KEYCODE_ESCAPE:
_escapePressed = true;
break;
+ case Common::KEYCODE_o:
+ if (event.kbd.flags & Common::KBD_CTRL) {
+ if (canLoadGameStateCurrently()) {
+ runLoadDialog();
+ }
+ }
+ break;
+ case Common::KEYCODE_s:
+ if (event.kbd.flags & Common::KBD_CTRL) {
+ if (canSaveGameStateCurrently()) {
+ runSaveDialog();
+ }
+ }
+ break;
default:
break;
}
@@ -502,6 +473,41 @@ void MohawkEngine_Myst::doFrame() {
_system->delayMillis(10);
}
+void MohawkEngine_Myst::runOptionsDialog() {
+ _optionsDialog->setCanDropPage(isInteractive() && _gameState->_globals.heldPage != kNoPage);
+ _optionsDialog->setCanShowMap(isInteractive() && _stack->getMap());
+ _optionsDialog->setCanReturnToMenu(isInteractive() && _stack->getStackId() != kDemoStack);
+
+ switch (runDialog(*_optionsDialog)) {
+ case MystOptionsDialog::kActionDropPage:
+ dropPage();
+ break;
+ case MystOptionsDialog::kActionShowMap:
+ _stack->showMap();
+ break;
+ case MystOptionsDialog::kActionGoToMenu:
+ changeToStack(kDemoStack, 2002, 0, 0);
+ break;
+ case MystOptionsDialog::kActionShowCredits:
+ if (isInteractive() && getGameType() != GType_MAKINGOF) {
+ _cursor->hideCursor();
+ changeToStack(kCreditsStack, 10000, 0, 0);
+ } else {
+ // Showing the credits in the middle of a script is not possible
+ // because it unloads the previous age, removing data needed by the
+ // rest of the script. Instead we just quit without showing the credits.
+ quitGame();
+ }
+ break;
+ default:
+ if (_optionsDialog->getLoadSlot() >= 0)
+ loadGameState(_optionsDialog->getLoadSlot());
+ if (_optionsDialog->getSaveSlot() >= 0)
+ saveGameState(_optionsDialog->getSaveSlot(), _optionsDialog->getSaveDescription());
+ break;
+ }
+}
+
bool MohawkEngine_Myst::wait(uint32 duration, bool skippable) {
_waitingOnBlockingOperation = true;
uint32 end = getTotalPlayTime() + duration;
@@ -808,6 +814,36 @@ bool MohawkEngine_Myst::canSaveGameStateCurrently() {
}
}
+void MohawkEngine_Myst::runLoadDialog() {
+ GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
+
+ pauseEngine(true);
+ int slot = slc.runModalWithCurrentTarget();
+ pauseEngine(false);
+
+ if (slot >= 0) {
+ loadGameState(slot);
+ }
+}
+
+void MohawkEngine_Myst::runSaveDialog() {
+ GUI::SaveLoadChooser slc(_("Save game:"), _("Save"), true);
+
+ pauseEngine(true);
+ int slot = slc.runModalWithCurrentTarget();
+ pauseEngine(false);
+
+ if (slot >= 0) {
+ Common::String result(slc.getResultString());
+ if (result.empty()) {
+ // If the user was lazy and entered no save name, come up with a default name.
+ result = slc.createDefaultSaveDescription(slot);
+ }
+
+ saveGameState(slot, result);
+ }
+}
+
void MohawkEngine_Myst::dropPage() {
HeldPage page = _gameState->_globals.heldPage;
bool whitePage = page == kWhitePage;
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index d626221ab3..43c918a7e2 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -151,11 +151,6 @@ public:
MystSoundBlock readSoundBlock(Common::ReadStream *stream) const;
void applySoundBlock(const MystSoundBlock &block);
- bool _needsPageDrop;
- bool _needsShowMap;
- bool _needsShowDemoMenu;
- bool _needsShowCredits;
-
bool _showResourceRects;
VideoManager *_video;
@@ -204,6 +199,11 @@ private:
uint32 _lastSaveTime;
bool hasGameSaveSupport() const;
+ void pauseEngineIntern(bool pause) override;
+
+ void runLoadDialog();
+ void runSaveDialog();
+ void runOptionsDialog();
void dropPage();
@@ -217,8 +217,6 @@ private:
uint16 _currentCursor;
uint16 _mainCursor; // Also defines the current page being held (white, blue, red, or none)
-
- void pauseEngineIntern(bool pause) override;
};
} // End of namespace Mohawk