diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-01-11 03:06:38 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-01-11 03:15:22 +0200 |
commit | 987120463333c3e412927e49234173de0b894490 (patch) | |
tree | 463fb196a29f2a949d077333b0a8b782cc1c652d /src/gui/widgets | |
parent | fcced13d9972ac70f0f01f19583b7868e255b6a7 (diff) | |
download | manaplus-987120463333c3e412927e49234173de0b894490.tar.gz manaplus-987120463333c3e412927e49234173de0b894490.tar.bz2 manaplus-987120463333c3e412927e49234173de0b894490.tar.xz manaplus-987120463333c3e412927e49234173de0b894490.zip |
Fix drawing inventory and selecting items.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 3f6a6b45c..0ba676fe5 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -140,7 +140,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) Image *image = item->getImage(); if (image) { - if (itemIndex == mSelectedIndex) + if (mShowMatrix[itemIndex] == mSelectedIndex) { if (mSelectionStatus == SEL_DRAGGING) { @@ -401,18 +401,18 @@ void ItemContainer::adjustHeight() void ItemContainer::updateMatrix() { - delete mShowMatrix; + delete []mShowMatrix; mShowMatrix = new int[mGridRows * mGridColumns]; - memset(mShowMatrix, -1, mGridRows * mGridColumns); int i = 0; int j = 0; for (int idx = 0; idx < mInventory->getSize(); idx ++) { -// int itemX = i * BOX_WIDTH; -// int itemY = j * BOX_HEIGHT; int itemIndex = idx; + if (j >= mGridRows) + break; + Item *item = mInventory->getItem(itemIndex); if (!item || item->getId() == 0 || !item->isHaveTag(mTag)) @@ -426,15 +426,20 @@ void ItemContainer::updateMatrix() i = 0; j ++; } - if (j >= mGridRows) - break; } + + for (int idx = j * mGridColumns + i; idx < mGridRows * mGridColumns; idx ++) + mShowMatrix[idx] = -1; } int ItemContainer::getSlotIndex(int x, int y) const { if (x < getWidth() && y < getHeight()) - return (y / BOX_HEIGHT) * mGridColumns + (x / BOX_WIDTH); + { + int idx = (y / BOX_HEIGHT) * mGridColumns + (x / BOX_WIDTH); + if (idx < mGridRows * mGridColumns && mShowMatrix[idx] >= 0) + return mShowMatrix[idx]; + } return Inventory::NO_SLOT_INDEX; } |