From 0ba035eea6e36c3d0bd9058d0b623eb7aad23f82 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 28 Jan 2017 08:55:31 +0100 Subject: [PATCH] MOHAWK: Move Riven inventory code to a new class --- engines/mohawk/module.mk | 1 + engines/mohawk/riven.cpp | 109 +------------- engines/mohawk/riven.h | 15 +- engines/mohawk/riven_graphics.cpp | 72 +-------- engines/mohawk/riven_graphics.h | 10 +- engines/mohawk/riven_inventory.cpp | 202 ++++++++++++++++++++++++++ engines/mohawk/riven_inventory.h | 73 ++++++++++ engines/mohawk/riven_stack.cpp | 2 +- engines/mohawk/riven_stacks/aspit.cpp | 26 +--- engines/mohawk/riven_stacks/aspit.h | 2 - engines/mohawk/riven_stacks/rspit.cpp | 5 +- engines/mohawk/riven_stacks/tspit.cpp | 3 +- 12 files changed, 302 insertions(+), 218 deletions(-) create mode 100644 engines/mohawk/riven_inventory.cpp create mode 100644 engines/mohawk/riven_inventory.h diff --git a/engines/mohawk/module.mk b/engines/mohawk/module.mk index 292310e88fc..7022c237805 100644 --- a/engines/mohawk/module.mk +++ b/engines/mohawk/module.mk @@ -55,6 +55,7 @@ MODULE_OBJS += \ riven.o \ riven_card.o \ riven_graphics.o \ + riven_inventory.o \ riven_saveload.o \ riven_scripts.o \ riven_sound.o \ diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index 7951d0f487b..c387772f2c5 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -33,6 +33,7 @@ #include "mohawk/riven.h" #include "mohawk/riven_card.h" #include "mohawk/riven_graphics.h" +#include "mohawk/riven_inventory.h" #include "mohawk/riven_saveload.h" #include "mohawk/riven_sound.h" #include "mohawk/riven_stack.h" @@ -50,18 +51,9 @@ namespace Mohawk { -Common::Rect *g_atrusJournalRect1; -Common::Rect *g_atrusJournalRect2; -Common::Rect *g_cathJournalRect2; -Common::Rect *g_atrusJournalRect3; -Common::Rect *g_cathJournalRect3; -Common::Rect *g_trapBookRect3; -Common::Rect *g_demoExitRect; - MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescription *gamedesc) : MohawkEngine(syst, gamedesc) { _showHotspots = false; - _gameOver = false; _activatedPLST = false; _activatedSLST = false; _extrasFile = nullptr; @@ -74,6 +66,7 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio _saveLoad = nullptr; _optionsDialog = nullptr; _card = nullptr; + _inventory = nullptr; removeTimer(); // NOTE: We can never really support CD swapping. All of the music files @@ -88,14 +81,6 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio SearchMan.addSubDirectoryMatching(gameDataDir, "exe"); SearchMan.addSubDirectoryMatching(gameDataDir, "assets1"); SearchMan.addSubDirectoryMatching(gameDataDir, "program"); - - g_atrusJournalRect1 = new Common::Rect(295, 402, 313, 426); - g_atrusJournalRect2 = new Common::Rect(259, 402, 278, 426); - g_cathJournalRect2 = new Common::Rect(328, 408, 348, 419); - g_atrusJournalRect3 = new Common::Rect(222, 402, 240, 426); - g_cathJournalRect3 = new Common::Rect(291, 408, 311, 419); - g_trapBookRect3 = new Common::Rect(363, 396, 386, 432); - g_demoExitRect = new Common::Rect(291, 408, 317, 419); } MohawkEngine_Riven::~MohawkEngine_Riven() { @@ -108,14 +93,8 @@ MohawkEngine_Riven::~MohawkEngine_Riven() { delete _saveLoad; delete _scriptMan; delete _optionsDialog; + delete _inventory; delete _rnd; - delete g_atrusJournalRect1; - delete g_atrusJournalRect2; - delete g_cathJournalRect2; - delete g_atrusJournalRect3; - delete g_cathJournalRect3; - delete g_trapBookRect3; - delete g_demoExitRect; } GUI::Debugger *MohawkEngine_Riven::getDebugger() { @@ -136,6 +115,7 @@ Common::Error MohawkEngine_Riven::run() { _saveLoad = new RivenSaveLoad(this, _saveFileMan); _optionsDialog = new RivenOptionsDialog(this); _scriptMan = new RivenScriptManager(this); + _inventory = new RivenInventory(this); _rnd = new Common::RandomSource("riven"); @@ -198,7 +178,7 @@ Common::Error MohawkEngine_Riven::run() { } - while (!_gameOver && !shouldQuit()) + while (!shouldQuit()) handleEvents(); return Common::kNoError; @@ -222,9 +202,9 @@ void MohawkEngine_Riven::handleEvents() { if (!(getFeatures() & GF_DEMO)) { // Check to show the inventory, but it is always "showing" in the demo if (_eventMan->getMousePos().y >= 392) - _gfx->showInventory(); + _inventory->show(); else - _gfx->hideInventory(); + _inventory->hide(); } needsUpdate = true; @@ -237,7 +217,7 @@ void MohawkEngine_Riven::handleEvents() { break; case Common::EVENT_LBUTTONUP: _card->onMouseUp(_eventMan->getMousePos()); - checkInventoryClick(); + _inventory->checkClick(_eventMan->getMousePos()); break; case Common::EVENT_KEYDOWN: switch (event.kbd.keycode) { @@ -441,79 +421,6 @@ void MohawkEngine_Riven::updateCurrentHotspot() { _card->onMouseMove(_eventMan->getMousePos()); } -void MohawkEngine_Riven::checkInventoryClick() { - Common::Point mousePos = _eventMan->getMousePos(); - - // Don't even bother. We're not in the inventory portion of the screen. - if (mousePos.y < 392) - return; - - // In the demo, check if we've clicked the exit button - if (getFeatures() & GF_DEMO) { - if (g_demoExitRect->contains(mousePos)) { - if (_stack->getId() == kStackAspit && _card->getId() == 1) { - // From the main menu, go to the "quit" screen - changeToCard(12); - } else if (_stack->getId() == kStackAspit && _card->getId() == 12) { - // From the "quit" screen, just quit - _gameOver = true; - } else { - // Otherwise, return to the main menu - if (_stack->getId() != kStackAspit) - changeToStack(kStackAspit); - changeToCard(1); - } - } - return; - } - - // No inventory shown on aspit - if (_stack->getId() == kStackAspit) - return; - - // Set the return stack/card id's. - _vars["returnstackid"] = _stack->getId(); - _vars["returncardid"] = _stack->getCardGlobalId(_card->getId()); - - // See RivenGraphics::showInventory() for an explanation - // of the variables' meanings. - bool hasCathBook = _vars["acathbook"] != 0; - bool hasTrapBook = _vars["atrapbook"] != 0; - - // Go to the book if a hotspot contains the mouse - if (!hasCathBook) { - if (g_atrusJournalRect1->contains(mousePos)) { - _gfx->hideInventory(); - changeToStack(kStackAspit); - changeToCard(5); - } - } else if (!hasTrapBook) { - if (g_atrusJournalRect2->contains(mousePos)) { - _gfx->hideInventory(); - changeToStack(kStackAspit); - changeToCard(5); - } else if (g_cathJournalRect2->contains(mousePos)) { - _gfx->hideInventory(); - changeToStack(kStackAspit); - changeToCard(6); - } - } else { - if (g_atrusJournalRect3->contains(mousePos)) { - _gfx->hideInventory(); - changeToStack(kStackAspit); - changeToCard(5); - } else if (g_cathJournalRect3->contains(mousePos)) { - _gfx->hideInventory(); - changeToStack(kStackAspit); - changeToCard(6); - } else if (g_trapBookRect3->contains(mousePos)) { - _gfx->hideInventory(); - changeToStack(kStackAspit); - changeToCard(7); - } - } -} - Common::SeekableReadStream *MohawkEngine_Riven::getExtrasResource(uint32 tag, uint16 id) { return _extrasFile->getResource(tag, id); } diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 73245e983e6..9e9f2b27986 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -44,6 +44,7 @@ class RivenStack; class RivenCard; class RivenHotspot; class RivenSoundManager; +class RivenInventory; // Riven Stack Types enum { @@ -68,16 +69,6 @@ enum RivenTransitionSpeed { kRivenTransitionSpeedBest = 5003 }; -// Rects for the inventory object positions (initialized in -// MohawkEngine_Riven's constructor). -extern Common::Rect *g_atrusJournalRect1; -extern Common::Rect *g_atrusJournalRect2; -extern Common::Rect *g_cathJournalRect2; -extern Common::Rect *g_atrusJournalRect3; -extern Common::Rect *g_cathJournalRect3; -extern Common::Rect *g_trapBookRect3; -extern Common::Rect *g_demoExitRect; - struct ZipMode { Common::String name; uint16 id; @@ -98,6 +89,7 @@ public: RivenGraphics *_gfx; Common::RandomSource *_rnd; RivenScriptManager *_scriptMan; + RivenInventory *_inventory; GUI::Debugger *getDebugger(); @@ -127,7 +119,6 @@ private: void handleEvents(); // Hotspot related functions and variables - void checkInventoryClick(); bool _showHotspots; // Variables @@ -138,7 +129,6 @@ private: uint32 _timerTime; // Miscellaneous - bool _gameOver; void checkSunnerAlertClick(); public: @@ -160,7 +150,6 @@ public: uint32 &getStackVar(uint32 index); // Miscellaneous - void setGameOver() { _gameOver = true; } Common::SeekableReadStream *getExtrasResource(uint32 tag, uint16 id); bool _activatedPLST; bool _activatedSLST; diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp index 573eddf7d8d..7fa35dd5d40 100644 --- a/engines/mohawk/riven_graphics.cpp +++ b/engines/mohawk/riven_graphics.cpp @@ -51,7 +51,6 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm _screenUpdateRunning = false; _scheduledTransition = -1; // no transition _dirtyScreen = false; - _inventoryDrawn = false; _creditsImage = 302; _creditsPos = 0; @@ -256,79 +255,12 @@ void RivenGraphics::fadeToBlack() { runScheduledTransition(); } -void RivenGraphics::showInventory() { - // Don't redraw the inventory - if (_inventoryDrawn) - return; - - // Clear the inventory area - clearInventoryArea(); - - // Draw the demo's exit button - if (_vm->getFeatures() & GF_DEMO) { - // extras.mhk tBMP 101 contains "EXIT" instead of Atrus' journal in the demo! - // The demo's extras.mhk contains all the other inventory/marble/credits image - // but has hacked tBMP 101 with "EXIT". *sigh* - drawInventoryImage(101, g_demoExitRect); - } else { - // We don't want to show the inventory on setup screens or in other journals. - if (_vm->getStack()->getId() == kStackAspit) - return; - - // There are three books and three vars. We have three different - // combinations. At the start you have just Atrus' journal. Later, - // you get Catherine's journal and the trap book. Near the end, - // you lose the trap book and have just the two journals. - - bool hasCathBook = _vm->_vars["acathbook"] != 0; - bool hasTrapBook = _vm->_vars["atrapbook"] != 0; - - if (!hasCathBook) { - drawInventoryImage(101, g_atrusJournalRect1); - } else if (!hasTrapBook) { - drawInventoryImage(101, g_atrusJournalRect2); - drawInventoryImage(102, g_cathJournalRect2); - } else { - drawInventoryImage(101, g_atrusJournalRect3); - drawInventoryImage(102, g_cathJournalRect3); - drawInventoryImage(100, g_trapBookRect3); - } - } - - _vm->_system->updateScreen(); - _inventoryDrawn = true; -} - -void RivenGraphics::hideInventory() { - // Don't hide the inventory twice - if (!_inventoryDrawn) - return; - - // Clear the area - clearInventoryArea(); - - _inventoryDrawn = false; -} - -void RivenGraphics::clearInventoryArea() { - // Clear the inventory area - static const Common::Rect inventoryRect = Common::Rect(0, 392, 608, 436); - - // Lock the screen - Graphics::Surface *screen = _vm->_system->lockScreen(); - - // Fill the inventory area with black - screen->fillRect(inventoryRect, _pixelFormat.RGBToColor(0, 0, 0)); - - _vm->_system->unlockScreen(); -} - -void RivenGraphics::drawInventoryImage(uint16 id, const Common::Rect *rect) { +void RivenGraphics::drawExtrasImageToScreen(uint16 id, const Common::Rect &rect) { MohawkSurface *mhkSurface = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id)); mhkSurface->convertToTrueColor(); Graphics::Surface *surface = mhkSurface->getSurface(); - _vm->_system->copyRectToScreen(surface->getPixels(), surface->pitch, rect->left, rect->top, surface->w, surface->h); + _vm->_system->copyRectToScreen(surface->getPixels(), surface->pitch, rect.left, rect.top, surface->w, surface->h); delete mhkSurface; } diff --git a/engines/mohawk/riven_graphics.h b/engines/mohawk/riven_graphics.h index 81208793101..76bcae5c208 100644 --- a/engines/mohawk/riven_graphics.h +++ b/engines/mohawk/riven_graphics.h @@ -44,6 +44,7 @@ public: void drawRect(Common::Rect rect, bool active); void drawImageRect(uint16 id, Common::Rect srcRect, Common::Rect dstRect); void drawExtrasImage(uint16 id, Common::Rect dstRect); + void drawExtrasImageToScreen(uint16 id, const Common::Rect &rect); Graphics::Surface *getEffectScreen(); Graphics::Surface *getBackScreen(); @@ -64,10 +65,6 @@ public: void fadeToBlack(); void setTransitionSpeed(uint32 speed) { _transitionSpeed = speed; } - // Inventory - void showInventory(); - void hideInventory(); - // Credits void beginCredits(); void updateCredits(); @@ -105,11 +102,6 @@ private: Common::Rect _transitionRect; uint32 _transitionSpeed; - // Inventory - void clearInventoryArea(); - void drawInventoryImage(uint16 id, const Common::Rect *rect); - bool _inventoryDrawn; - // Screen Related Graphics::Surface *_mainScreen; Graphics::Surface *_effectScreen; diff --git a/engines/mohawk/riven_inventory.cpp b/engines/mohawk/riven_inventory.cpp new file mode 100644 index 00000000000..11a42f0ea57 --- /dev/null +++ b/engines/mohawk/riven_inventory.cpp @@ -0,0 +1,202 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "mohawk/riven_inventory.h" + +#include "mohawk/resource.h" +#include "mohawk/riven.h" +#include "mohawk/riven_card.h" +#include "mohawk/riven_graphics.h" +#include "mohawk/riven_stack.h" + +namespace Mohawk { + +RivenInventory::RivenInventory(MohawkEngine_Riven *vm) : + _vm(vm) { + + _inventoryDrawn = false; + + _atrusJournalRect1 = Common::Rect(295, 402, 313, 426); + _atrusJournalRect2 = Common::Rect(259, 402, 278, 426); + _cathJournalRect2 = Common::Rect(328, 408, 348, 419); + _atrusJournalRect3 = Common::Rect(222, 402, 240, 426); + _cathJournalRect3 = Common::Rect(291, 408, 311, 419); + _trapBookRect3 = Common::Rect(363, 396, 386, 432); + _demoExitRect = Common::Rect(291, 408, 317, 419); +} + +RivenInventory::~RivenInventory() { + +} + +void RivenInventory::show() { + // Don't redraw the inventory + if (_inventoryDrawn) + return; + + // Clear the inventory area + clearArea(); + + // Draw the demo's exit button + if (_vm->getFeatures() & GF_DEMO) { + // extras.mhk tBMP 101 contains "EXIT" instead of Atrus' journal in the demo! + // The demo's extras.mhk contains all the other inventory/marble/credits image + // but has hacked tBMP 101 with "EXIT". *sigh* + _vm->_gfx->drawExtrasImageToScreen(101, _demoExitRect); + } else { + // We don't want to show the inventory on setup screens or in other journals. + if (_vm->getStack()->getId() == kStackAspit) + return; + + // There are three books and three vars. We have three different + // combinations. At the start you have just Atrus' journal. Later, + // you get Catherine's journal and the trap book. Near the end, + // you lose the trap book and have just the two journals. + + bool hasCathBook = _vm->_vars["acathbook"] != 0; + bool hasTrapBook = _vm->_vars["atrapbook"] != 0; + + if (!hasCathBook) { + _vm->_gfx->drawExtrasImageToScreen(101, _atrusJournalRect1); + } else if (!hasTrapBook) { + _vm->_gfx->drawExtrasImageToScreen(101, _atrusJournalRect2); + _vm->_gfx->drawExtrasImageToScreen(102, _cathJournalRect2); + } else { + _vm->_gfx->drawExtrasImageToScreen(101, _atrusJournalRect3); + _vm->_gfx->drawExtrasImageToScreen(102, _cathJournalRect3); + _vm->_gfx->drawExtrasImageToScreen(100, _trapBookRect3); + } + } + + _vm->_system->updateScreen(); + _inventoryDrawn = true; +} + +void RivenInventory::hide() { + // Don't hide the inventory twice + if (!_inventoryDrawn) + return; + + // Clear the area + clearArea(); + + _inventoryDrawn = false; +} + +void RivenInventory::clearArea() { + // Clear the inventory area + static const Common::Rect inventoryRect = Common::Rect(0, 392, 608, 436); + + // Lock the screen + Graphics::Surface *screen = _vm->_system->lockScreen(); + + // Fill the inventory area with black + screen->fillRect(inventoryRect, screen->format.RGBToColor(0, 0, 0)); + + _vm->_system->unlockScreen(); +} + +void RivenInventory::checkClick(const Common::Point &mousePos) { + // Don't even bother. We're not in the inventory portion of the screen. + if (mousePos.y < 392) + return; + + // In the demo, check if we've clicked the exit button + if (_vm->getFeatures() & GF_DEMO) { + if (_demoExitRect.contains(mousePos)) { + if (_vm->getStack()->getId() == kStackAspit && _vm->getCard()->getId() == 1) { + // From the main menu, go to the "quit" screen + _vm->changeToCard(12); + } else if (_vm->getStack()->getId() == kStackAspit && _vm->getCard()->getId() == 12) { + // From the "quit" screen, just quit + _vm->quitGame(); + } else { + // Otherwise, return to the main menu + if (_vm->getStack()->getId() != kStackAspit) + _vm->changeToStack(kStackAspit); + _vm->changeToCard(1); + } + } + return; + } + + // No inventory shown on aspit + if (_vm->getStack()->getId() == kStackAspit) + return; + + // Set the return stack/card id's. + _vm->_vars["returnstackid"] = _vm->getStack()->getId(); + _vm->_vars["returncardid"] = _vm->getStack()->getCardGlobalId(_vm->getCard()->getId()); + + // See RivenGraphics::show() for an explanation + // of the variables' meanings. + bool hasCathBook = _vm->_vars["acathbook"] != 0; + bool hasTrapBook = _vm->_vars["atrapbook"] != 0; + + // Go to the book if a hotspot contains the mouse + if (!hasCathBook) { + if (_atrusJournalRect1.contains(mousePos)) { + hide(); + _vm->changeToStack(kStackAspit); + _vm->changeToCard(5); + } + } else if (!hasTrapBook) { + if (_atrusJournalRect2.contains(mousePos)) { + hide(); + _vm->changeToStack(kStackAspit); + _vm->changeToCard(5); + } else if (_cathJournalRect2.contains(mousePos)) { + hide(); + _vm->changeToStack(kStackAspit); + _vm->changeToCard(6); + } + } else { + if (_atrusJournalRect3.contains(mousePos)) { + hide(); + _vm->changeToStack(kStackAspit); + _vm->changeToCard(5); + } else if (_cathJournalRect3.contains(mousePos)) { + hide(); + _vm->changeToStack(kStackAspit); + _vm->changeToCard(6); + } else if (_trapBookRect3.contains(mousePos)) { + hide(); + _vm->changeToStack(kStackAspit); + _vm->changeToCard(7); + } + } +} + +void RivenInventory::backFromItemScript() const { + RivenScriptPtr stopSoundScript = _vm->_scriptMan->createScriptFromData(1, 12, 1, 1); + _vm->_scriptMan->runScript(stopSoundScript, false); + + uint16 backStackId = _vm->_vars["returnstackid"]; + uint32 backCardId = _vm->_vars["returncardid"]; + + // Return to where we were before entering the book + RivenCommand *back = new RivenStackChangeCommand(_vm, backStackId, backCardId, true); + RivenScriptPtr backScript = _vm->_scriptMan->createScriptWithCommand(back); + _vm->_scriptMan->runScript(backScript, false); +} + +} // End of namespace Mohawk diff --git a/engines/mohawk/riven_inventory.h b/engines/mohawk/riven_inventory.h new file mode 100644 index 00000000000..e1b7ae513c0 --- /dev/null +++ b/engines/mohawk/riven_inventory.h @@ -0,0 +1,73 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef RIVEN_INVENTORY_H +#define RIVEN_INVENTORY_H + +#include "common/rect.h" + +namespace Mohawk { + +class MohawkEngine_Riven; + +/** + * The player's inventory + * + * Is responsible for drawing the bottom part of the screen. + */ +class RivenInventory { +public: + RivenInventory(MohawkEngine_Riven *vm); + virtual ~RivenInventory(); + + /** Make the inventory visible */ + void show(); + + /** Make the inventory invisible */ + void hide(); + + /** Handle a click event in the inventory area */ + void checkClick(const Common::Point &mousePos); + + /** Go back to the game from an inventory item detail view */ + void backFromItemScript() const; + +private: + void clearArea(); + + MohawkEngine_Riven *_vm; + + bool _inventoryDrawn; + + // Rects for the inventory object positions + Common::Rect _atrusJournalRect1; + Common::Rect _atrusJournalRect2; + Common::Rect _cathJournalRect2; + Common::Rect _atrusJournalRect3; + Common::Rect _cathJournalRect3; + Common::Rect _trapBookRect3; + Common::Rect _demoExitRect; +}; + +} // End of namespace Mohawk + +#endif diff --git a/engines/mohawk/riven_stack.cpp b/engines/mohawk/riven_stack.cpp index c375097d7f4..c39464558c9 100644 --- a/engines/mohawk/riven_stack.cpp +++ b/engines/mohawk/riven_stack.cpp @@ -216,7 +216,7 @@ void RivenStack::runCredits(uint16 video, uint32 delay) { _vm->_system->delayMillis(10); } - _vm->setGameOver(); + _vm->quitGame(); } void RivenStack::installCardTimer() { diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp index 4c88b196765..aabd7dba916 100644 --- a/engines/mohawk/riven_stacks/aspit.cpp +++ b/engines/mohawk/riven_stacks/aspit.cpp @@ -25,6 +25,7 @@ #include "mohawk/riven.h" #include "mohawk/riven_card.h" #include "mohawk/riven_graphics.h" +#include "mohawk/riven_inventory.h" #include "mohawk/riven_sound.h" #include "common/translation.h" @@ -95,20 +96,7 @@ void ASpit::xaatrusopenbook(uint16 argc, uint16 *argv) { } void ASpit::xaatrusbookback(uint16 argc, uint16 *argv) { - inventoryBackFromItemScript(); -} - -void ASpit::inventoryBackFromItemScript() const { - RivenScriptPtr stopSoundScript = _vm->_scriptMan->createScriptFromData(1, 12, 1, 1); - _vm->_scriptMan->runScript(stopSoundScript, false); - - uint16 backStackId = _vm->_vars["returnstackid"]; - uint32 backCardId = _vm->_vars["returncardid"]; - - // Return to where we were before entering the book - RivenCommand *back = new RivenStackChangeCommand(_vm, backStackId, backCardId, true); - RivenScriptPtr backScript = _vm->_scriptMan->createScriptWithCommand(back); - _vm->_scriptMan->runScript(backScript, false); + _vm->_inventory->backFromItemScript(); } void ASpit::xaatrusbookprevpage(uint16 argc, uint16 *argv) { @@ -198,7 +186,7 @@ void ASpit::xacathopenbook(uint16 argc, uint16 *argv) { } void ASpit::xacathbookback(uint16 argc, uint16 *argv) { - inventoryBackFromItemScript(); + _vm->_inventory->backFromItemScript(); } void ASpit::xacathbookprevpage(uint16 argc, uint16 *argv) { @@ -238,7 +226,7 @@ void ASpit::xacathbooknextpage(uint16 argc, uint16 *argv) { void ASpit::xtrapbookback(uint16 argc, uint16 *argv) { // Return to where we were before entering the book _vm->_vars["atrap"] = 0; - inventoryBackFromItemScript(); + _vm->_inventory->backFromItemScript(); } void ASpit::xatrapbookclose(uint16 argc, uint16 *argv) { @@ -309,7 +297,7 @@ void ASpit::xadisablemenuintro(uint16 argc, uint16 *argv) { // The original also had this shortcut. // Hide the "exit" button here - _vm->_gfx->hideInventory(); + _vm->_inventory->hide(); } void ASpit::xaenablemenuintro(uint16 argc, uint16 *argv) { @@ -318,12 +306,12 @@ void ASpit::xaenablemenuintro(uint16 argc, uint16 *argv) { // The original also had this shortcut. // Show the "exit" button here - _vm->_gfx->showInventory(); + _vm->_inventory->show(); } void ASpit::xademoquit(uint16 argc, uint16 *argv) { // Exactly as it says on the tin. In the demo, this function quits. - _vm->setGameOver(); + _vm->quitGame(); } void ASpit::xaexittomain(uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/riven_stacks/aspit.h b/engines/mohawk/riven_stacks/aspit.h index 3aa400263da..60400dd5f65 100644 --- a/engines/mohawk/riven_stacks/aspit.h +++ b/engines/mohawk/riven_stacks/aspit.h @@ -67,8 +67,6 @@ public: void xaenablemenuintro(uint16 argc, uint16 *argv); void xademoquit(uint16 argc, uint16 *argv); void xaexittomain(uint16 argc, uint16 *argv); - - void inventoryBackFromItemScript() const; }; } // End of namespace RivenStacks diff --git a/engines/mohawk/riven_stacks/rspit.cpp b/engines/mohawk/riven_stacks/rspit.cpp index a7431a6e7f7..49fac733466 100644 --- a/engines/mohawk/riven_stacks/rspit.cpp +++ b/engines/mohawk/riven_stacks/rspit.cpp @@ -25,6 +25,7 @@ #include "mohawk/riven.h" #include "mohawk/riven_card.h" #include "mohawk/riven_graphics.h" +#include "mohawk/riven_inventory.h" namespace Mohawk { namespace RivenStacks { @@ -53,11 +54,11 @@ void RSpit::xrshowinventory(uint16 argc, uint16 *argv) { // Give the trap book and Catherine's journal to the player _vm->_vars["atrapbook"] = 1; _vm->_vars["acathbook"] = 1; - _vm->_gfx->showInventory(); + _vm->_inventory->show(); } void RSpit::xrhideinventory(uint16 argc, uint16 *argv) { - _vm->_gfx->hideInventory(); + _vm->_inventory->hide(); } void RSpit::rebelPrisonWindowTimer() { diff --git a/engines/mohawk/riven_stacks/tspit.cpp b/engines/mohawk/riven_stacks/tspit.cpp index 763f5351cdb..e4d51791bbb 100644 --- a/engines/mohawk/riven_stacks/tspit.cpp +++ b/engines/mohawk/riven_stacks/tspit.cpp @@ -26,6 +26,7 @@ #include "mohawk/riven.h" #include "mohawk/riven_card.h" #include "mohawk/riven_graphics.h" +#include "mohawk/riven_inventory.h" #include "common/events.h" @@ -181,7 +182,7 @@ void TSpit::xtchotakesbook(uint16 argc, uint16 *argv) { } void TSpit::xthideinventory(uint16 argc, uint16 *argv) { - _vm->_gfx->hideInventory(); + _vm->_inventory->hide(); } // Marble Puzzle related constants