summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-03-29 18:33:44 +0200
committerPhilipp Sehmisch <crush@themanaworld.org>2009-03-29 18:33:44 +0200
commit9587fb9b86ee4081ba14d23c1133bf1a09ee4578 (patch)
tree7682df3ec17534be553caae85ffa9e5a68c9a815 /src/gui/itemcontainer.cpp
parent63b41440a0555c6b39141eab94ef4627f712b476 (diff)
parent8748f26234bba1e71bbe059147fb02256f8cec2a (diff)
downloadmana-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.gz
mana-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.bz2
mana-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.xz
mana-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.zip
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r--src/gui/itemcontainer.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index abce257d..70cf8176 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -61,7 +61,7 @@ ItemContainer::ItemContainer(Inventory *inventory,
mSwapItems(false),
mDescItems(false)
{
- mItemPopup = new ItemPopup();
+ mItemPopup = new ItemPopup;
setFocusable(true);
ResourceManager *resman = ResourceManager::getInstance();
@@ -281,9 +281,11 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
};
int index = getSlotIndex(event.getX(), event.getY());
- if (index == Inventory::NO_SLOT_INDEX) return;
+ if (index == Inventory::NO_SLOT_INDEX)
+ return;
Item *item = mInventory->getItem(index);
- if (item == mSelectedItem) return;
+ if (item == mSelectedItem)
+ return;
player_node->moveInvItem(mSelectedItem, index);
setSelectedItem(NULL);
mSelectionStatus = SEL_NONE;
@@ -314,12 +316,12 @@ void ItemContainer::mouseExited(gcn::MouseEvent &event)
mItemPopup->setVisible(false);
}
-int ItemContainer::getSlotIndex(const int posX, const int posY) const
+int ItemContainer::getSlotIndex(int x, int y) const
{
- if (getDimension().isPointInRect(posX, posY))
+ if (x < getWidth() && y < getHeight())
{
// Takes into account, boxes are overlapping each other.
- return (posY / (BOX_HEIGHT - 1)) * mGridColumns + (posX / (BOX_WIDTH - 1));
+ return (y / (BOX_HEIGHT - 1)) * mGridColumns + (x / (BOX_WIDTH - 1));
}
return Inventory::NO_SLOT_INDEX;
}