aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Bouclet2017-07-01 17:05:39 +0200
committerEugene Sandulenko2017-07-03 08:50:10 +0200
commit8c6cd9806714b463ae43bfed11acbb88d1e9bc9a (patch)
tree05caa717abbe01f5a5d88b48e51d2aede19e42d6
parent64c1a1d2b28f5fa0520d5824d595a3194a79ec3f (diff)
downloadscummvm-rg350-8c6cd9806714b463ae43bfed11acbb88d1e9bc9a.tar.gz
scummvm-rg350-8c6cd9806714b463ae43bfed11acbb88d1e9bc9a.tar.bz2
scummvm-rg350-8c6cd9806714b463ae43bfed11acbb88d1e9bc9a.zip
MOHAWK: Fix the inventory being visible when scripts are running
-rw-r--r--engines/mohawk/riven.cpp10
-rw-r--r--engines/mohawk/riven_inventory.cpp88
-rw-r--r--engines/mohawk/riven_inventory.h15
-rw-r--r--engines/mohawk/riven_stacks/aspit.cpp4
-rw-r--r--engines/mohawk/riven_stacks/ospit.cpp4
5 files changed, 64 insertions, 57 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index f7a29ab8c2..8b2fa6c754 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -202,14 +202,6 @@ void MohawkEngine_Riven::doFrame() {
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
_stack->onMouseMove(event.mouse);
-
- if (!(getFeatures() & GF_DEMO)) {
- // Check to show the inventory, but it is always "showing" in the demo
- if (_eventMan->getMousePos().y >= 392)
- _inventory->show();
- else
- _inventory->hide();
- }
break;
case Common::EVENT_LBUTTONDOWN:
_stack->onMouseDown(_eventMan->getMousePos());
@@ -274,6 +266,8 @@ void MohawkEngine_Riven::doFrame() {
_scriptMan->runQueuedScripts();
}
+ _inventory->onFrame();
+
// Update the screen once per frame
_system->updateScreen();
diff --git a/engines/mohawk/riven_inventory.cpp b/engines/mohawk/riven_inventory.cpp
index 3dcc5908b0..6e6f575c0c 100644
--- a/engines/mohawk/riven_inventory.cpp
+++ b/engines/mohawk/riven_inventory.cpp
@@ -31,9 +31,9 @@
namespace Mohawk {
RivenInventory::RivenInventory(MohawkEngine_Riven *vm) :
- _vm(vm) {
-
- _inventoryDrawn = false;
+ _vm(vm),
+ _inventoryDrawn(false),
+ _forceVisible(false) {
_atrusJournalRect1 = Common::Rect(295, 402, 313, 426);
_atrusJournalRect2 = Common::Rect(259, 402, 278, 426);
@@ -48,11 +48,7 @@ RivenInventory::~RivenInventory() {
}
-void RivenInventory::show() {
- // Don't redraw the inventory
- if (_inventoryDrawn)
- return;
-
+void RivenInventory::draw() {
// Clear the inventory area
clearArea();
@@ -63,17 +59,13 @@ void RivenInventory::show() {
// 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;
+ bool hasCathBook = _vm->_vars["rrebel"] == 5 || _vm->_vars["rrebel"] == 6;
+ bool hasTrapBook = _vm->_vars["atrapbook"] == 1;
if (!hasCathBook) {
_vm->_gfx->drawExtrasImageToScreen(101, _atrusJournalRect1);
@@ -86,20 +78,6 @@ void RivenInventory::show() {
_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() {
@@ -116,9 +94,9 @@ void RivenInventory::clearArea() {
}
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;
+ if (!isVisible()) {
+ return; // Don't even bother.
+ }
// In the demo, check if we've clicked the exit button
if (_vm->getFeatures() & GF_DEMO) {
@@ -149,37 +127,31 @@ void RivenInventory::checkClick(const Common::Point &mousePos) {
// See RivenGraphics::show() for an explanation
// of the variables' meanings.
- bool hasCathBook = _vm->_vars["acathbook"] != 0;
- bool hasTrapBook = _vm->_vars["atrapbook"] != 0;
+ bool hasCathBook = _vm->_vars["rrebel"] == 5 || _vm->_vars["rrebel"] == 6;
+ bool hasTrapBook = _vm->_vars["atrapbook"] == 1;
// 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);
}
@@ -199,4 +171,42 @@ void RivenInventory::backFromItemScript() const {
_vm->_scriptMan->runScript(backScript, true);
}
+bool RivenInventory::isVisible() const {
+ if (_forceVisible) {
+ return true;
+ }
+
+ if (_vm->getFeatures() & GF_DEMO) {
+ // The inventory is always visible in the demo
+ return true;
+ }
+
+ // We don't want to show the inventory on setup screens or in other journals.
+ if (_vm->getStack()->getId() == kStackAspit)
+ return false;
+
+ // We don't want to show the inventory while scripts are running
+ if (_vm->_scriptMan->runningQueuedScripts())
+ return false;
+
+ Common::Point mouse = _vm->getStack()->getMousePosition();
+ return mouse.y >= 392;
+}
+
+void RivenInventory::onFrame() {
+ bool visible = isVisible();
+
+ if (visible && !_inventoryDrawn) {
+ draw();
+ _inventoryDrawn = true;
+ } else if (!visible && _inventoryDrawn) {
+ clearArea();
+ _inventoryDrawn = false;
+ }
+}
+
+void RivenInventory::forceVisible(bool visible) {
+ _forceVisible = visible;
+}
+
} // End of namespace Mohawk
diff --git a/engines/mohawk/riven_inventory.h b/engines/mohawk/riven_inventory.h
index e1b7ae513c..ff4f68cb76 100644
--- a/engines/mohawk/riven_inventory.h
+++ b/engines/mohawk/riven_inventory.h
@@ -39,24 +39,27 @@ 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;
+ /** Make the inventory visible and draw it as necessary */
+ void onFrame();
+
+ /** Force the inventory to be visible even in situations where it usually is not */
+ void forceVisible(bool visible);
+
private:
+ bool isVisible() const;
+ void draw();
void clearArea();
MohawkEngine_Riven *_vm;
bool _inventoryDrawn;
+ bool _forceVisible;
// Rects for the inventory object positions
Common::Rect _atrusJournalRect1;
diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp
index bf2adc0e8e..0835d28d9f 100644
--- a/engines/mohawk/riven_stacks/aspit.cpp
+++ b/engines/mohawk/riven_stacks/aspit.cpp
@@ -333,7 +333,7 @@ void ASpit::xadisablemenuintro(uint16 argc, uint16 *argv) {
// The original also had this shortcut.
// Hide the "exit" button here
- _vm->_inventory->hide();
+ //_vm->_inventory->forceVisible(false);
}
void ASpit::xaenablemenuintro(uint16 argc, uint16 *argv) {
@@ -342,7 +342,7 @@ void ASpit::xaenablemenuintro(uint16 argc, uint16 *argv) {
// The original also had this shortcut.
// Show the "exit" button here
- _vm->_inventory->show();
+ //_vm->_inventory->forceVisible(true);
}
void ASpit::xademoquit(uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/riven_stacks/ospit.cpp b/engines/mohawk/riven_stacks/ospit.cpp
index 524f6d7e3d..f177ae88eb 100644
--- a/engines/mohawk/riven_stacks/ospit.cpp
+++ b/engines/mohawk/riven_stacks/ospit.cpp
@@ -122,9 +122,9 @@ void OSpit::xbookclick(uint16 argc, uint16 *argv) {
_vm->_sound->playSound(0); // Play the link sound again
_vm->_gfx->scheduleTransition(kRivenTransitionBlend);
_vm->changeToCard(_vm->getStack()->getCardStackId(0x2885)); // Link out!
- _vm->_inventory->show();
+ _vm->_inventory->forceVisible(true);
_vm->delay(2000);
- _vm->_inventory->hide();
+ _vm->_inventory->forceVisible(false);
_vm->_scriptMan->stopAllScripts(); // Stop all running scripts (so we don't remain in the cage)
return;
}