summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-07-01 14:51:23 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-07-01 14:51:23 +0000
commitd3ccf6a0b97ce4189eef4fde606cf5b5f93fac14 (patch)
treef4c4e5b1cc87b34d0a3946c3409882ba222e2ad7 /src/gui/itemcontainer.cpp
parent59c17d5f465ddcf1956e8cdf1aae1dbda0a1431f (diff)
downloadmana-d3ccf6a0b97ce4189eef4fde606cf5b5f93fac14.tar.gz
mana-d3ccf6a0b97ce4189eef4fde606cf5b5f93fac14.tar.bz2
mana-d3ccf6a0b97ce4189eef4fde606cf5b5f93fac14.tar.xz
mana-d3ccf6a0b97ce4189eef4fde606cf5b5f93fac14.zip
Ported some GUI improvements from Legend of Mazeroth (GUI skinning via XML files, item descriptions on mouse-over, map names in minimap window, speech bubbles)
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r--src/gui/itemcontainer.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index eddb6011..4c528a16 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -65,6 +65,7 @@ ItemContainer::ItemContainer(Inventory *inventory,
mSelectionStatus(SEL_NONE),
mSwapItems(false)
{
+ mItemPopup = new ItemPopup();
setFocusable(true);
ResourceManager *resman = ResourceManager::getInstance();
@@ -281,14 +282,46 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
mSelectionStatus = SEL_NONE;
}
-int
-ItemContainer::getSlotIndex(const int posX, const int posY) const
+
+// Show ItemTooltip
+void ItemContainer::mouseMoved(gcn::MouseEvent &event)
+{
+ Item *item = mInventory->getItem( getSlotIndex(event.getX(), event.getY() ) );
+
+ if( item )
+ {
+ mItemPopup->setPosition(getParent()->getParent()->getX() + getParent()->getParent()->getWidth(), getParent()->getParent()->getY());
+
+ mItemPopup->setItem(item);
+
+ mItemPopup->setVisible(true);
+ }
+ else
+ {
+ mItemPopup->setVisible(false);
+ }
+}
+
+
+// Show ItemTooltip
+void ItemContainer::mouseEntered(gcn::MouseEvent &event)
+{
+
+}
+
+
+// Hide ItemTooltip
+void ItemContainer::mouseExited(gcn::MouseEvent &event)
+{
+ mItemPopup->setVisible(false);
+}
+
+int ItemContainer::getSlotIndex(const int posX, const int posY) const
{
if (getDimension().isPointInRect(posX, posY))
{
// Takes into account, boxes are overlapping each other.
- return (posY / (BOX_HEIGHT - 1)) * mGridColumns +
- (posX / (BOX_WIDTH - 1));
+ return (posY / (BOX_HEIGHT - 1)) * mGridColumns + (posX / (BOX_WIDTH - 1));
}
return Inventory::NO_SLOT_INDEX;
}