diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/inventory.cpp | 115 | ||||
-rw-r--r-- | engines/fullpipe/inventory.h | 27 |
2 files changed, 127 insertions, 15 deletions
diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp index 36ee7129ab..35b516b587 100644 --- a/engines/fullpipe/inventory.cpp +++ b/engines/fullpipe/inventory.cpp @@ -104,7 +104,120 @@ void CInventory2::addItem(int itemId, int count) { void CInventory2::rebuildItemRects() { _scene = g_fullpipe->accessScene(_sceneId); - warning("STUB: CInventory2::rebuildItemRects()"); + if (!_scene) + return; + + _picture = _scene->getBigPicture(0, 0); + _picture->setAlpha(50); + + int itemX = 9; + int itemY = 0; + + for (uint i = 0; i < _scene->_picObjList.size(); i++) { + PictureObject *pic = (PictureObject *)_scene->_picObjList[i]; + + for (uint j = 0; j < _itemsPool.size(); j++) { + if (_itemsPool[j]->pictureObjectNormalId == pic->_id) { + if (pic->okeyCode) + _scene->deletePictureObject(pic); + else + pic->_flags &= 0xFFFB; + } + } + } + + for (uint i = 0; i < _inventoryItems.size(); i++) { + Common::Point point; + + idx = getInventoryPoolItemIndexById(_inventoryItems[i]->itemId); + + InventoryIcon *icn = new InventoryIcon(); + + icn->inventoryItemId = _itemsPool[idx]->id; + + PictureObject *pic = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectNormalId, 0); + + icn->pictureObjectNormal = pic; + + icn->icons = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectMouseInsideId, 0); + + icn->numIcons = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectId3, 0); // Weird + + pic->getDimensions(point); + + if (_itemsPool[idx]->flags & 0x10000) { + icn->x1 = 730; + icn->y1 = itemY; + icn->x2 = point.x + 730; + icn->y2 = point.y + itemY + 10; + } else { + icn->x1 = itemX; + icn->y1 = itemY; + icn->x2 = itemX + point.x; + itemX = icn->x2 + 1; + icn->y2 = point.y + itemY + 10; + } + v22 = _inventoryIcons->numIcons; + _inventoryIcons->numIcons++; + v38 = v23; + v24 = v23 + 1; + if (v24) { + v25 = _inventoryIcons->icons; + if (v25) { + v27 = _inventoryIcons->x1; + if (v24 > v27) { + v28 = _inventoryIcons->y1; + if (!v28) { + v28 = v22 / 8; + if (v22 / 8 >= 4) { + if (v28 > 1024) + v28 = 1024; + } else { + v28 = 4; + } + } + v29 = v27 + v28; + if (v24 >= v29) { + v34 = v24; + v29 = v24; + } else { + v34 = v29; + } + v30 = operator new(40 * v29); + memcpy(v30, _inventoryIcons->icons, 40 * _inventoryIcons->numIcons); + memset((char *)v30 + 40 * _inventoryIcons->numIcons, 0, 4 * ((unsigned int)(40 * (v24 - _inventoryIcons->numIcons)) >> 2)); + CObjectFree(_inventoryIcons->icons); + _inventoryIcons->icons = (InventoryIcon **)v30; + _inventoryIcons->numIcons = v24; + _inventoryIcons->x1 = v34; + } else if (v22 >= v24) { + _inventoryIcons->numIcons = v24; + } else { + memset(&v25[10 * v22], 0, 40 * (v24 - v22)); + _inventoryIcons->numIcons = v24; + } + } else { + v26 = (InventoryIcon **)operator new(40 * v24); + _inventoryIcons->icons = v26; + memset(v26, 0, 4 * ((unsigned int)(40 * v24) >> 2)); + _inventoryIcons->x1 = v24; + _inventoryIcons->numIcons = v24; + } + } else { + if (_inventoryIcons->icons) { + CObjectFree(_inventoryIcons->icons); + _inventoryIcons->icons = 0; + } + _inventoryIcons->x1 = 0; + _inventoryIcons->numIcons = 0; + } + v31 = icn->x1; + memcpy(&_inventoryIcons->icons[10 * v38], &inventoryIcon, 0x28u); + if (itemX >= 2 * (v31 - icn->x2) + 800) { + itemX = 9; + itemY = icn->y2 + 1; + } + } } void CInventory2::draw() { diff --git a/engines/fullpipe/inventory.h b/engines/fullpipe/inventory.h index 0d16909f6a..6193c4a2bb 100644 --- a/engines/fullpipe/inventory.h +++ b/engines/fullpipe/inventory.h @@ -29,7 +29,6 @@ class Scene; class BigPicture; struct InventoryPoolItem { - public: int16 id; int16 pictureObjectNormalId; int16 pictureObjectId1; @@ -68,21 +67,21 @@ typedef Common::Array<InventoryItem *> InventoryItems; class PictureObject; -class InventoryIcon { - PictureObject *_pictureObjectNormal; - InventoryIcon **_icons; - int _numIcons; - int _x1; - int _y1; - int _x2; - int _y2; - int16 _inventoryItemId; - int16 _field_1E; - int _isSelected; - int _isMouseInside; +struct InventoryIcon { + PictureObject *pictureObjectNormal; + InventoryIcon **icons; + int numIcons; + int x1; + int y1; + int x2; + int y2; + int16 inventoryItemId; + int16 field_1E; + int isSelected; + int isMouseInside; }; -typedef Common::Array<InventoryIcon> InventoryIcons; +typedef Common::Array<InventoryIcon *> InventoryIcons; class CInventory2 : public CInventory { InventoryItems _inventoryItems; |