diff options
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/riven.cpp | 55 | ||||
-rw-r--r-- | engines/mohawk/riven.h | 5 | ||||
-rw-r--r-- | engines/mohawk/riven_stacks/aspit.cpp | 28 |
3 files changed, 61 insertions, 27 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index eaf079446d..69a06ac228 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -279,23 +279,9 @@ void MohawkEngine_Riven::doFrame() { if (!_scriptMan->hasQueuedScripts()) { // Check if we haven't jumped to menu if (_prevStack == -1) { - _prevStack = _stack->getId(); - _prevCard = _card->getId(); - - // If we are already in menu, do not call again - if (_prevStack == kStackAspit && _prevCard == 1) { - _prevStack = -1; - _prevCard = -1; - break; - } - - changeToStack(kStackAspit); - changeToCard(1); + goToMainMenu(); } else { - changeToStack(_prevStack); - changeToCard(_prevCard); - _prevStack = -1; - _prevCard = -1; + resumeFromMainMenu(); } } else { _stack->onKeyPressed(event.kbd); @@ -340,6 +326,34 @@ void MohawkEngine_Riven::doFrame() { _system->delayMillis(10); } +void MohawkEngine_Riven::goToMainMenu() { + _prevStack = _stack->getId(); + _prevCard = _card->getId(); + + // If we are already in menu, do not call again + if (_prevStack == kStackAspit && _prevCard == 1) { + _prevStack = -1; + _prevCard = -1; + return; + } + + changeToStack(kStackAspit); + changeToCard(1); +} + +void MohawkEngine_Riven::resumeFromMainMenu() { + assert(_prevStack != -1); + + changeToStack(_prevStack); + changeToCard(_prevCard); + _prevStack = -1; + _prevCard = -1; +} + +bool MohawkEngine_Riven::isGameStarted() const { + return _stack->getId() != kStackAspit || _prevStack != -1; +} + void MohawkEngine_Riven::pauseEngineIntern(bool pause) { MohawkEngine::pauseEngineIntern(pause); @@ -597,7 +611,14 @@ void MohawkEngine_Riven::runSaveDialog() { } Common::Error MohawkEngine_Riven::loadGameState(int slot) { - return _saveLoad->loadGame(slot); + Common::Error loadError = _saveLoad->loadGame(slot); + + if (loadError.getCode() == Common::kNoError) { + _prevStack = -1; + _prevCard = -1; + } + + return loadError; } void MohawkEngine_Riven::loadGameStateAndDisplayError(int slot) { diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 74cbcd1305..dd26f515c2 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -169,6 +169,11 @@ public: * End the game gracefully */ void setGameEnded(); + + // Main menu handling + void goToMainMenu(); + void resumeFromMainMenu(); + bool isGameStarted() const; }; } // End of namespace Mohawk diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp index 9c8ffc2ddd..b72ba01fe0 100644 --- a/engines/mohawk/riven_stacks/aspit.cpp +++ b/engines/mohawk/riven_stacks/aspit.cpp @@ -127,16 +127,17 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) { struct MenuItem { uint16 blstId; + bool requiresStartedGame; }; MenuItem items[] = { - { 22 }, - { 16 }, - { 23 }, - { 24 }, - { 25 }, - { 26 }, - { 27 } + { 22, false }, // Setup + { 16, false }, // New game + { 23, false }, // Load game + { 24, true }, // Save game + { 25, true }, // Resume + { 26, false }, // Options + { 27, false } // Quit }; for (uint i = 0; i < ARRAYSIZE(items); i++) { @@ -147,12 +148,20 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) { continue; } + bool enabled = !items[i].requiresStartedGame || _vm->isGameStarted(); + hotspot->enable(enabled); + Common::Rect hotspotRect = hotspot->getRect(); Graphics::Surface surface; surface.create(hotspotRect.width(), hotspotRect.height(), _vm->_gfx->getBackScreen()->format); - uint32 textColor = surface.format.RGBToColor(164, 164, 164); + uint32 textColor; + if (enabled) { + textColor = surface.format.RGBToColor(164, 164, 164); + } else { + textColor = surface.format.RGBToColor(96, 96, 96); + } Common::U32String str = Common::convertUtf8ToUtf32(menuItems[lang].items[i]); @@ -374,12 +383,11 @@ void ASpit::xarestoregame(const ArgumentArray &args) { } void ASpit::xaSaveGame(const ArgumentArray &args) { - // Launch the load game dialog _vm->runSaveDialog(); } void ASpit::xaResumeGame(const ArgumentArray &args) { - + _vm->resumeFromMainMenu(); } void ASpit::xaOptions(const ArgumentArray &args) { |