From b2df8047e6c2d1215ef7debf1a42e02188725471 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 28 Mar 2009 01:01:10 +0100 Subject: Make the full inventory accessible again Was broken due to tmwserv having only 50 as opposed to 100 places in the inventory at the moment. --- src/gui/itemcontainer.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/gui/itemcontainer.cpp') 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; } -- cgit v1.2.3-70-g09d2