From 8932619ee273967821c3c5fc93ae162f75f7d6c8 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Wed, 23 Jul 2008 02:45:09 +0000 Subject: More decoupling of inventory code. svn-id: r33224 --- engines/parallaction/graphics.cpp | 6 +++++- engines/parallaction/input.cpp | 26 +++++++++++++------------- engines/parallaction/input.h | 5 +++-- engines/parallaction/inventory.cpp | 4 +--- engines/parallaction/parallaction.cpp | 2 +- engines/parallaction/parallaction.h | 2 +- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 9b9ea8605a..6f29a6cf3f 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -307,10 +307,14 @@ void Gfx::setProjectorProgram(int16 *data) { } void Gfx::drawInventory() { - +/* if ((_engineFlags & kEngineInventory) == 0) { return; } +*/ + if (_vm->_input->_inputMode != Input::kInputModeInventory) { + return; + } Common::Rect r; _vm->_inventoryRenderer->getRect(r); diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp index 243eaec94f..518c165155 100644 --- a/engines/parallaction/input.cpp +++ b/engines/parallaction/input.cpp @@ -171,9 +171,7 @@ void Input::updateGameInput() { } else { _inputData._mousePos = _mousePos; _inputData._event = kEvNone; - if (!translateGameInput()) { - translateInventoryInput(); - } + translateGameInput(); } } @@ -192,6 +190,11 @@ InputData* Input::updateInput() { case kInputModeGame: updateGameInput(); break; + + case kInputModeInventory: + readInput(); + updateInventoryInput(); + break; } return &_inputData; @@ -234,7 +237,7 @@ void Input::walkTo(const Common::Point &dest) { bool Input::translateGameInput() { - if ((_engineFlags & kEnginePauseJobs) || (_engineFlags & kEngineInventory)) { + if (_engineFlags & kEnginePauseJobs) { return false; } @@ -310,6 +313,8 @@ void Input::enterInventoryMode() { _vm->openInventory(); _transCurrentHoverItem = -1; + + _inputMode = kInputModeInventory; } void Input::exitInventoryMode() { @@ -339,22 +344,17 @@ void Input::exitInventoryMode() { _vm->setInventoryCursor(item); } _vm->resumeJobs(); -} - -bool Input::translateInventoryInput() { - if ((_engineFlags & kEngineInventory) == 0) { - return false; - } - - // in inventory - int16 _si = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y); + _inputMode = kInputModeGame; +} +bool Input::updateInventoryInput() { if (_mouseButtons == kMouseRightUp) { exitInventoryMode(); return true; } + int16 _si = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y); if (_si != _transCurrentHoverItem) { _transCurrentHoverItem = _si; _vm->highlightInventoryItem(_si); // enable diff --git a/engines/parallaction/input.h b/engines/parallaction/input.h index 19825c8baa..4d22d7b59b 100644 --- a/engines/parallaction/input.h +++ b/engines/parallaction/input.h @@ -60,7 +60,7 @@ class Input { InputData *translateInput(); bool translateGameInput(); - bool translateInventoryInput(); + bool updateInventoryInput(); void takeAction(ZonePtr z); void walkTo(const Common::Point &dest); @@ -80,7 +80,8 @@ public: enum { kInputModeGame = 0, kInputModeComment = 1, - kInputModeDialogue = 2 + kInputModeDialogue = 2, + kInputModeInventory = 3 }; diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index 58848196d7..71c336bbab 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -131,7 +131,7 @@ void InventoryRenderer::showInventory() { if (!_inv) error("InventoryRenderer not bound to inventory"); - _engineFlags |= kEngineInventory; +// _engineFlags |= kEngineInventory; uint16 lines = getNumLines(); @@ -147,8 +147,6 @@ void InventoryRenderer::showInventory() { void InventoryRenderer::hideInventory() { if (!_inv) error("InventoryRenderer not bound to inventory"); - - _engineFlags &= ~kEngineInventory; } void InventoryRenderer::getRect(Common::Rect& r) const { diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index cdc19c32c4..20f6129d78 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -151,7 +151,7 @@ void Parallaction::clearSet(OpcodeSet &opcodes) { void Parallaction::updateView() { - if ((_engineFlags & kEnginePauseJobs) && (_engineFlags & kEngineInventory) == 0) { + if ((_engineFlags & kEnginePauseJobs) && (_input->_inputMode != Input::kInputModeInventory)) { return; } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 20d0d90d68..387fa43c09 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -101,7 +101,7 @@ enum { enum EngineFlags { kEngineQuit = (1 << 0), kEnginePauseJobs = (1 << 1), - kEngineInventory = (1 << 2), +// kEngineInventory = (1 << 2), kEngineWalking = (1 << 3), kEngineChangeLocation = (1 << 4), kEngineBlockInput = (1 << 5), -- cgit v1.2.3