Skip to content

Commit

Permalink
MOHAWK: Don't allow displaying the map when the game is not interactive
Browse files Browse the repository at this point in the history
Fixes Trac#10526 and Trac#10531.
  • Loading branch information
bgK committed May 17, 2018
1 parent 44fd44c commit 6798f9c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
19 changes: 11 additions & 8 deletions engines/mohawk/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,19 @@ MystOptionsDialog::~MystOptionsDialog() {
void MystOptionsDialog::open() {
MohawkOptionsDialog::open();

_dropPageButton->setEnabled(_vm->_gameState->_globals.heldPage != kNoPage);
bool canDropPage = _vm->isInteractive() && _vm->_gameState->_globals.heldPage != kNoPage;
_dropPageButton->setEnabled(canDropPage);

if (_showMapButton)
_showMapButton->setEnabled(_vm->_scriptParser &&
_vm->_scriptParser->getMap());
if (_showMapButton) {
bool canShowMap = _vm->isInteractive() && _vm->_scriptParser->getMap();
_showMapButton->setEnabled(canShowMap);
}

// Return to menu button is not enabled on the menu
if (_returnToMenuButton)
_returnToMenuButton->setEnabled(_vm->_scriptParser &&
_vm->getCurStack() != kDemoStack);
if (_returnToMenuButton) {
// Return to menu button is not enabled on the menu
bool canReturnToMenu = _vm->isInteractive() && _vm->getCurStack() != kDemoStack;
_returnToMenuButton->setEnabled(canReturnToMenu);
}

// Zip mode is disabled in the demo
if (_vm->getFeatures() & GF_DEMO)
Expand Down
30 changes: 17 additions & 13 deletions engines/mohawk/myst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_mouseClicked = false;
_mouseMoved = false;
_escapePressed = false;
_interactive = true;
_waitingOnBlockingOperation = false;
_runExitScript = true;

_needsPageDrop = false;
Expand Down Expand Up @@ -310,7 +310,7 @@ void MohawkEngine_Myst::waitUntilMovieEnds(const VideoEntryPtr &video) {
if (!video)
return;

_interactive = false;
_waitingOnBlockingOperation = true;

// Sanity check
if (video->isLooping())
Expand All @@ -328,17 +328,17 @@ void MohawkEngine_Myst::waitUntilMovieEnds(const VideoEntryPtr &video) {

// Ensure it's removed
_video->removeEntry(video);
_interactive = true;
_waitingOnBlockingOperation = false;
}

void MohawkEngine_Myst::playSoundBlocking(uint16 id) {
_interactive = false;
_waitingOnBlockingOperation = true;
_sound->playEffect(id);

while (_sound->isEffectPlaying() && !shouldQuit()) {
doFrame();
}
_interactive = true;
_waitingOnBlockingOperation = false;
}

Common::Error MohawkEngine_Myst::run() {
Expand Down Expand Up @@ -389,10 +389,10 @@ Common::Error MohawkEngine_Myst::run() {
void MohawkEngine_Myst::doFrame() {
// Update any background videos
_video->updateMovies();
if (!_scriptParser->isScriptRunning() && _interactive) {
_interactive = false;
if (isInteractive()) {
_waitingOnBlockingOperation = true;
_scriptParser->runPersistentScripts();
_interactive = true;
_waitingOnBlockingOperation = false;
}

Common::Event event;
Expand Down Expand Up @@ -446,7 +446,7 @@ void MohawkEngine_Myst::doFrame() {
}

if (_needsShowCredits) {
if (_interactive) {
if (isInteractive()) {
_cursor->hideCursor();
changeToStack(kCreditsStack, 10000, 0, 0);
_needsShowCredits = false;
Expand Down Expand Up @@ -479,7 +479,7 @@ void MohawkEngine_Myst::doFrame() {
}
}

if (!_scriptParser->isScriptRunning() && _interactive) {
if (isInteractive()) {
updateActiveResource();
checkCurrentResource();
}
Expand All @@ -491,7 +491,7 @@ void MohawkEngine_Myst::doFrame() {
}

bool MohawkEngine_Myst::wait(uint32 duration, bool skippable) {
_interactive = false;
_waitingOnBlockingOperation = true;
uint32 end = getTotalPlayTime() + duration;

do {
Expand All @@ -503,7 +503,7 @@ bool MohawkEngine_Myst::wait(uint32 duration, bool skippable) {
}
} while (getTotalPlayTime() < end && !shouldQuit());

_interactive = true;
_waitingOnBlockingOperation = false;
return false;
}

Expand Down Expand Up @@ -1165,8 +1165,12 @@ bool MohawkEngine_Myst::hasGameSaveSupport() const {
return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
}

bool MohawkEngine_Myst::isInteractive() {
return !_scriptParser->isScriptRunning() && !_waitingOnBlockingOperation;
}

bool MohawkEngine_Myst::canLoadGameStateCurrently() {
if (_scriptParser->isScriptRunning() || !_interactive) {
if (!isInteractive()) {
return false;
}

Expand Down
9 changes: 8 additions & 1 deletion engines/mohawk/myst.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ class MohawkEngine_Myst : public MohawkEngine {

GUI::Debugger *getDebugger() override { return _console; }

/**
* Is the game currently interactive
*
* When the game is interactive, the user can interact with the game world
* and perform other operations such as loading saved games, ...
*/
bool isInteractive();
bool canLoadGameStateCurrently() override;
bool canSaveGameStateCurrently() override;
Common::Error loadGameState(int slot) override;
Expand Down Expand Up @@ -284,7 +291,7 @@ class MohawkEngine_Myst : public MohawkEngine {
bool _mouseClicked;
bool _mouseMoved;
bool _escapePressed;
bool _interactive; // Is the game currently interactive
bool _waitingOnBlockingOperation;

Common::Array<MystCursorHint> _cursorHints;
void loadCursorHints();
Expand Down

0 comments on commit 6798f9c

Please sign in to comment.