summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/inventorywindow.cpp9
-rw-r--r--src/gui/itemcontainer.cpp12
-rw-r--r--src/gui/itemcontainer.h12
-rw-r--r--src/gui/itemshortcutcontainer.cpp1
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);
}
-