Skip to content

Commit

Permalink
FULLPIPE: Implement CInventory2::draw()
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent 2a59b51 commit 8748818
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 14 deletions.
15 changes: 15 additions & 0 deletions engines/fullpipe/gfx.cpp
Expand Up @@ -196,6 +196,21 @@ void PictureObject::draw() {
_picture->draw(_ox, _oy, 0, 0);
}

void PictureObject::drawAt(int x, int y) {
if (x == -1)
x = _ox;
if (y == -1)
y = _oy;

_picture->_x = x;
_picture->_y = y;

if (_flags & 1)
_picture->draw(x, y, 2, 0);
else
_picture->draw(x, y, 0, 0);
}

bool PictureObject::setPicAniInfo(PicAniInfo *picAniInfo) {
if (!(picAniInfo->type & 2) || (picAniInfo->type & 1)) {
error("Picture::setPicAniInfo(): Wrong type: %d", picAniInfo->type);
Expand Down
1 change: 1 addition & 0 deletions engines/fullpipe/gfx.h
Expand Up @@ -155,6 +155,7 @@ class PictureObject : public GameObject {
bool load(MfcArchive &file, bool bigPicture);
Common::Point *getDimensions(Common::Point *p);
void draw();
void drawAt(int x, int y);

bool setPicAniInfo(PicAniInfo *picAniInfo);
bool isPointInside(int x, int y);
Expand Down
85 changes: 77 additions & 8 deletions engines/fullpipe/inventory.cpp
Expand Up @@ -37,10 +37,10 @@ bool CInventory::load(MfcArchive &file) {
for (int i = 0; i < numInvs; i++) {
InventoryPoolItem *t = new InventoryPoolItem();
t->id = file.readUint16LE();
t->pictureObjectNormalId = file.readUint16LE();
t->pictureObjectNormal = file.readUint16LE();
t->pictureObjectId1 = file.readUint16LE();
t->pictureObjectMouseHover = file.readUint16LE();
t->pictureObjectId3 = file.readUint16LE();
t->pictureObjectHover = file.readUint16LE();
t->pictureObjectSelected = file.readUint16LE();
t->flags = file.readUint32LE();
t->field_C = 0;
t->field_A = -536;
Expand Down Expand Up @@ -117,7 +117,7 @@ void CInventory2::rebuildItemRects() {
PictureObject *pic = (PictureObject *)_scene->_picObjList[i];

for (uint j = 0; j < _itemsPool.size(); j++) {
if (_itemsPool[j]->pictureObjectNormalId == pic->_id) {
if (_itemsPool[j]->pictureObjectNormal == pic->_id) {
if (pic->_okeyCode)
_scene->deletePictureObject(pic);
else
Expand All @@ -135,9 +135,9 @@ void CInventory2::rebuildItemRects() {

icn->inventoryItemId = _itemsPool[idx]->id;

icn->pictureObjectNormal = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectNormalId, 0);
icn->pictureObjectHover = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectMouseHover, 0);
icn->pictureObjectId3 = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectId3, 0);
icn->pictureObjectNormal = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectNormal, 0);
icn->pictureObjectHover = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectHover, 0);
icn->pictureObjectSelected = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectSelected, 0);

icn->pictureObjectNormal->getDimensions(&point);

Expand All @@ -164,7 +164,76 @@ void CInventory2::rebuildItemRects() {
}

void CInventory2::draw() {
warning("STUB: CInventory2::draw()");
if (!_scene)
return;

int oldScLeft = g_fullpipe->_sceneRect.left;
int oldScTop = g_fullpipe->_sceneRect.top;

g_fullpipe->_sceneRect.top = -_topOffset;
g_fullpipe->_sceneRect.left = 0;

_picture->draw(-1, -1, 0, 0);

for (uint i = 0; i < _inventoryIcons.size(); i++) {
InventoryIcon *icn = _inventoryIcons[i];

if (icn->isSelected) {
icn->pictureObjectSelected->drawAt(icn->x1, icn->y1 + 10);
} else {
if (icn->isMouseHover)
icn->pictureObjectHover->drawAt(icn->x1, icn->y1 + 10);
else
icn->pictureObjectNormal->drawAt(icn->x1, icn->y1 + 10);
}
}

if (!_isInventoryOut)
goto LABEL_30;

int v10, v11, v12;

if (_topOffset != -10) {
if (_topOffset < -10) {
v10 = -10;
goto LABEL_13;
}
if (_topOffset + 10 >= 20) {
v11 = -20;
cont:
_topOffset += v11;
goto reset;
}
v12 = -10;
goto LABEL_25;
}
if (!_isInventoryOut) {
LABEL_30:
if (_topOffset != -65) {
if (_topOffset < -65) {
v10 = -65;
LABEL_13:
v11 = v10 - _topOffset;
if (v11 >= 20)
v11 = 20;
goto cont;
}
if (_topOffset + 65 >= 20) {
v11 = -20;
goto cont;
}
v12 = -65;
LABEL_25:
v11 = v12 - _topOffset;
goto cont;
}
}

reset:

g_fullpipe->_sceneRect.top = oldScTop;
g_fullpipe->_sceneRect.left = oldScLeft;

}

void CInventory2::slideIn() {
Expand Down
11 changes: 5 additions & 6 deletions engines/fullpipe/inventory.h
Expand Up @@ -30,10 +30,10 @@ class BigPicture;

struct InventoryPoolItem {
int16 id;
int16 pictureObjectNormalId;
int16 pictureObjectNormal;
int16 pictureObjectId1;
int16 pictureObjectMouseHover;
int16 pictureObjectId3;
int16 pictureObjectHover;
int16 pictureObjectSelected;
int16 field_A;
int field_C;
int obj;
Expand Down Expand Up @@ -70,15 +70,14 @@ class PictureObject;
struct InventoryIcon {
PictureObject *pictureObjectNormal;
PictureObject *pictureObjectHover;
PictureObject *pictureObjectId3;
PictureObject *pictureObjectSelected;
int x1;
int y1;
int x2;
int y2;
int16 inventoryItemId;
int16 field_1E;
int isSelected;
int isMouseInside;
int isMouseHover;
};

typedef Common::Array<InventoryIcon *> InventoryIcons;
Expand Down

0 comments on commit 8748818

Please sign in to comment.