diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-28 01:01:10 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-28 01:02:44 +0100 |
commit | b2df8047e6c2d1215ef7debf1a42e02188725471 (patch) | |
tree | 0d826f7d0fcd911ddcfd53eaf96afe6e5d585e5f /src/gui | |
parent | a5ed5126e8498d53a5f843d591ff183951418d1f (diff) | |
download | mana-client-b2df8047e6c2d1215ef7debf1a42e02188725471.tar.gz mana-client-b2df8047e6c2d1215ef7debf1a42e02188725471.tar.bz2 mana-client-b2df8047e6c2d1215ef7debf1a42e02188725471.tar.xz mana-client-b2df8047e6c2d1215ef7debf1a42e02188725471.zip |
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.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/inventorywindow.cpp | 9 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 12 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 12 | ||||
-rw-r--r-- | src/gui/itemshortcutcontainer.cpp | 1 |
4 files changed, 17 insertions, 17 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 612c978a..51c1372c 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -57,7 +57,7 @@ InventoryWindow::InventoryWindow(int invSize): setResizable(false); setCloseButton(true); - setDefaultSize(375, 307, ImageRect::CENTER); + setDefaultSize(387, 307, ImageRect::CENTER); addKeyListener(this); std::string longestUseString = getFont()->getWidth(_("Equip")) > @@ -74,14 +74,13 @@ InventoryWindow::InventoryWindow(int invSize): mDropButton = new Button(_("Drop"), "drop", this); #ifdef TMWSERV_SUPPORT mSplitButton = new Button(_("Split"), "split", this); -#endif - mItems = new ItemContainer(player_node->getInventory(), 10, 5); +#else + mItems = new ItemContainer(player_node->getInventory(), 10, 10); +#endif mItems->addSelectionListener(this); - // The window is supposed to be exactly large enough for now mInvenScroll = new ScrollArea(mItems); - mInvenScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mTotalWeight = -1; 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; } diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index a28ca392..b2857563 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -69,9 +69,12 @@ class ItemContainer : public gcn::Widget, void keyPressed(gcn::KeyEvent &event); void keyReleased(gcn::KeyEvent &event); + void mousePressed(gcn::MouseEvent &event); void mouseDragged(gcn::MouseEvent &event); void mouseReleased(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event); /** * Returns the selected item. @@ -125,9 +128,6 @@ class ItemContainer : public gcn::Widget, */ void keyAction(); - void mouseExited(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); - /** * Moves the highlight in the direction specified. * @@ -158,11 +158,11 @@ class ItemContainer : public gcn::Widget, /** * Gets the slot index based on the cursor position. * - * @param posX The X Coordinate position. - * @param posY The Y Coordinate position. + * @param x The X coordinate position. + * @param y The Y coordinate position. * @return The slot index on success, -1 on failure. */ - int getSlotIndex(int posX, int posY) const; + int getSlotIndex(int x, int y) const; Inventory *mInventory; int mGridColumns, mGridRows; diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index a7bb229f..97c3b640 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -252,4 +252,3 @@ void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event) { mItemPopup->setVisible(false); } - |