aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2018-06-19 19:38:07 +0200
committerBastien Bouclet2018-06-29 13:31:54 +0200
commitd848ebe85a2954263219ae64fd5183129dc74df6 (patch)
tree8f859cb1d609ba633d0e6620cd86f024eda69d10 /engines
parent2f9c9a2c324b27e21f4bb249cc1a89c46f1e353c (diff)
downloadscummvm-rg350-d848ebe85a2954263219ae64fd5183129dc74df6.tar.gz
scummvm-rg350-d848ebe85a2954263219ae64fd5183129dc74df6.tar.bz2
scummvm-rg350-d848ebe85a2954263219ae64fd5183129dc74df6.zip
MOHAWK: RIVEN: Fix loading and resuming from the main menu
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/riven.cpp55
-rw-r--r--engines/mohawk/riven.h5
-rw-r--r--engines/mohawk/riven_stacks/aspit.cpp28
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) {