TSAGE: Bugfixes for inventory dialog display with a large number of items

This commit is contained in:
Paul Gilbert 2011-05-01 10:35:03 +10:00
parent 4ac0e73907
commit de592e07f3
2 changed files with 13 additions and 7 deletions

View File

@ -412,10 +412,11 @@ InventoryDialog::InventoryDialog() {
imgHeight = MAX(imgHeight, (int)itemSurface.getBounds().height()); imgHeight = MAX(imgHeight, (int)itemSurface.getBounds().height());
// Add the item to the display list // Add the item to the display list
_images.push_back(GfxInvImage()); GfxInvImage *img = new GfxInvImage();
_images[_images.size() - 1].setDetails(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum); _images.push_back(img);
_images[_images.size() - 1]._invObject = invObject; img->setDetails(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);
add(&_images[_images.size() - 1]); img->_invObject = invObject;
add(img);
} }
} }
assert(_images.size() > 0); assert(_images.size() > 0);
@ -437,7 +438,7 @@ InventoryDialog::InventoryDialog() {
cellX = 0; cellX = 0;
} }
_images[idx]._bounds.moveTo(pt.x, pt.y); _images[idx]->_bounds.moveTo(pt.x, pt.y);
pt.x += imgWidth + 2; pt.x += imgWidth + 2;
++cellX; ++cellX;
@ -455,6 +456,11 @@ InventoryDialog::InventoryDialog() {
setCenter(SCREEN_CENTER_X, SCREEN_CENTER_Y); setCenter(SCREEN_CENTER_X, SCREEN_CENTER_Y);
} }
InventoryDialog::~InventoryDialog() {
for (uint idx = 0; idx < _images.size(); ++idx)
delete _images[idx];
}
void InventoryDialog::execute() { void InventoryDialog::execute() {
if ((RING_INVENTORY._selectedItem) && RING_INVENTORY._selectedItem->inInventory()) if ((RING_INVENTORY._selectedItem) && RING_INVENTORY._selectedItem->inInventory())
RING_INVENTORY._selectedItem->setCursor(); RING_INVENTORY._selectedItem->setCursor();

View File

@ -105,11 +105,11 @@ public:
class InventoryDialog : public ModalDialog { class InventoryDialog : public ModalDialog {
private: private:
Common::Array<GfxInvImage> _images; Common::Array<GfxInvImage *> _images;
GfxButton _btnOk, _btnLook; GfxButton _btnOk, _btnLook;
public: public:
InventoryDialog(); InventoryDialog();
virtual ~InventoryDialog() {} virtual ~InventoryDialog();
void execute(); void execute();
static void show(); static void show();