summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r--src/gui/itemcontainer.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index bd180f28..70cf8176 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -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;
}