diff options
-rw-r--r-- | engines/parallaction/graphics.cpp | 9 | ||||
-rw-r--r-- | engines/parallaction/inventory.cpp | 88 | ||||
-rw-r--r-- | engines/parallaction/inventory.h | 14 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 5 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 29 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 2 |
6 files changed, 53 insertions, 94 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index a60f272ca8..615366a643 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -287,6 +287,15 @@ void Gfx::setHalfbriteMode(bool enable) { void Gfx::updateScreen() { g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _buffers[kBitFront]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight); + + if (_engineFlags & kEngineInventory) { + Common::Rect r; + _vm->_inventoryRenderer->getRect(r); + byte *data = _vm->_inventoryRenderer->getData(); + + g_system->copyRectToScreen(data, r.width(), r.left, r.top, r.width(), r.height()); + } + g_system->updateScreen(); return; } diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index 78d8df0c69..085d6c0940 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -47,94 +47,68 @@ namespace Parallaction { #define INVENTORY_WIDTH (INVENTORY_ITEMS_PER_LINE*INVENTORYITEM_WIDTH) #define INVENTORY_HEIGHT (INVENTORY_LINES*INVENTORYITEM_HEIGHT) -Inventory *_inv = 0; -InventoryRenderer *_re = 0; - int16 Parallaction::getHoverInventoryItem(int16 x, int16 y) { - return _re->hitTest(Common::Point(x,y)); + return _inventoryRenderer->hitTest(Common::Point(x,y)); } -void highlightInventoryItem(ItemPosition pos, byte color) { - _re->highlightItem(pos, color); +void Parallaction::highlightInventoryItem(ItemPosition pos, byte color) { + _inventoryRenderer->highlightItem(pos, color); } int Parallaction::addInventoryItem(ItemName item) { - return _inv->addItem(item); + return _inventory->addItem(item); } int Parallaction::addInventoryItem(ItemName item, uint32 value) { - return _inv->addItem(item, value); + return _inventory->addItem(item, value); } void Parallaction::dropItem(uint16 v) { - _inv->removeItem(v); + _inventory->removeItem(v); } bool Parallaction::isItemInInventory(int32 v) { - return (_inv->findItem(v) != -1); -} - -const InventoryItem* getInventoryItem(int16 pos) { - return _inv->getItem(pos); + return (_inventory->findItem(v) != -1); } -int16 getInventoryItemIndex(int16 pos) { - return _inv->getItemName(pos); +const InventoryItem* Parallaction::getInventoryItem(int16 pos) { + return _inventory->getItem(pos); } -void initInventory() { - _inv = new Inventory(INVENTORY_MAX_ITEMS); - _re = new InventoryRenderer(_vm); - _re->bindInventory(_inv); +int16 Parallaction::getInventoryItemIndex(int16 pos) { + return _inventory->getItemName(pos); } -void destroyInventory() { - delete _inv; - delete _re; +void Parallaction::initInventory() { + _inventory = new Inventory(INVENTORY_MAX_ITEMS); + _inventoryRenderer = new InventoryRenderer(this); + _inventoryRenderer->bindInventory(_inventory); } -void cleanInventory(bool keepVerbs) { - _inv->clear(keepVerbs); -} +void Parallaction::destroyInventory() { + delete _inventory; + delete _inventoryRenderer; -void openInventory() { - _re->showInventory(); + _inventory = 0; + _inventoryRenderer = 0; } -void closeInventory() { - _re->hideInventory(); +void Parallaction::cleanInventory(bool keepVerbs) { + _inventory->clear(keepVerbs); } - - - -void Parallaction_ns::showInventory() { - Common::Rect r; - _re->getRect(r); - _gfx->copyRect(Gfx::kBitBack, r, _re->getData(), INVENTORY_WIDTH); +void Parallaction::openInventory() { + _inventoryRenderer->showInventory(); } -void Parallaction_ns::jobHideInventory(void *parm, Job *j) { - static uint16 count = 0; - _engineFlags |= kEngineBlockInput; - - count++; - if (count == 2) { - count = 0; - j->_finished = 1; - _engineFlags &= ~kEngineBlockInput; - } - - Common::Rect r; - _re->getRect(r); - _gfx->restoreBackground(r); +void Parallaction::closeInventory() { + _inventoryRenderer->hideInventory(); } - InventoryRenderer::InventoryRenderer(Parallaction *vm) : _vm(vm) { _surf.create(INVENTORY_WIDTH, INVENTORY_HEIGHT, 1); } @@ -237,16 +211,6 @@ void InventoryRenderer::getItemRect(ItemPosition pos, Common::Rect &r) { - - - - - - - - - - Inventory::Inventory(uint16 maxItems) : _maxItems(maxItems), _numItems(0) { _items = (InventoryItem*)calloc(_maxItems, sizeof(InventoryItem)); diff --git a/engines/parallaction/inventory.h b/engines/parallaction/inventory.h index 6440f48aa6..99f77913ec 100644 --- a/engines/parallaction/inventory.h +++ b/engines/parallaction/inventory.h @@ -44,20 +44,6 @@ struct InventoryItem { #define MAKE_INVENTORY_ID(x) (((x) & 0xFFFF) << 16) -void initInventory(); -void destroyInventory(); - - - -void openInventory(); -void closeInventory(); -void highlightInventoryItem(int16 pos, byte color); - - -void cleanInventory(bool keepVerbs = true); -const InventoryItem* getInventoryItem(int16 pos); -int16 getInventoryItemIndex(int16 pos); - typedef int16 ItemPosition; typedef uint16 ItemName; diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index bb1afe8a2c..43091286af 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -296,10 +296,6 @@ void Parallaction::runGame() { drawAnimations(); drawLabel(); - if (_engineFlags & kEngineInventory) { - showInventory(); - } - updateView(); } @@ -375,7 +371,6 @@ void Parallaction::processInput(InputData *data) { closeInventory(); setInventoryCursor(data->_inventoryIndex); resumeJobs(); - addJob(kJobHideInventory, 0, kPriority20); break; case kEvHoverInventory: diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index b12ee8beeb..23506de61d 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -489,10 +489,6 @@ public: Common::RandomSource _rnd; - virtual void showInventory() = 0; - virtual void jobHideInventory(void*, Job*) = 0; - - protected: // data Debugger *_debugger; @@ -562,13 +558,7 @@ protected: // members void freeCharacter(); - - int addInventoryItem(ItemName item, uint32 value); - int addInventoryItem(ItemName item); - void dropItem(ItemName item); int16 pickupItem(Zone *z); - bool isItemInInventory(int32 v); - int16 getHoverInventoryItem(int16 x, int16 y); public: virtual void callFunction(uint index, void* parm) { } @@ -599,6 +589,23 @@ public: const char **_callableNamesRes; const char **_instructionNamesRes; + void highlightInventoryItem(ItemPosition pos, byte color); + int16 getHoverInventoryItem(int16 x, int16 y); + int addInventoryItem(ItemName item); + int addInventoryItem(ItemName item, uint32 value); + void dropItem(uint16 v); + bool isItemInInventory(int32 v); + const InventoryItem* getInventoryItem(int16 pos); + int16 getInventoryItemIndex(int16 pos); + void initInventory(); + void destroyInventory(); + void cleanInventory(bool keepVerbs = true); + void openInventory(); + void closeInventory(); + + Inventory *_inventory; + InventoryRenderer *_inventoryRenderer; + }; @@ -737,7 +744,6 @@ protected: void jobDisplayDroppedItem(void*, Job *j); void jobRemovePickedItem(void*, Job *j); void jobToggleDoor(void*, Job *j); - void jobHideInventory(void *parm, Job *j); void runScripts(); void walk(); @@ -745,7 +751,6 @@ protected: void eraseAnimations(); void drawLabel(); void eraseLabel(); - void showInventory(); // location parser diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 1b50074095..5ec2f3812c 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -451,7 +451,7 @@ void Parallaction_ns::initJobs() { 0, &Parallaction_ns::jobToggleDoor, 0, - &Parallaction_ns::jobHideInventory + 0 }; _jobsFn = jobs; |