summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlue <bluesansdouze@gmail.com>2009-05-08 20:32:31 +0200
committerJared Adams <jaxad0127@gmail.com>2009-05-08 12:38:39 -0600
commitc587af8bf7ef422765e8a8cdcdb6b4b1aadeb51f (patch)
tree4382607d33f5cffe3a1f5bfc44fe593f13228986 /src
parent2fdfb7b8eb9987620628d68d2193a0ae4de7fa40 (diff)
downloadmana-c587af8bf7ef422765e8a8cdcdb6b4b1aadeb51f.tar.gz
mana-c587af8bf7ef422765e8a8cdcdb6b4b1aadeb51f.tar.bz2
mana-c587af8bf7ef422765e8a8cdcdb6b4b1aadeb51f.tar.xz
mana-c587af8bf7ef422765e8a8cdcdb6b4b1aadeb51f.zip
Item image on item amount windows
Adds the item's image with the popup on the amount selector window.
Diffstat (limited to 'src')
-rw-r--r--src/gui/itemamount.cpp47
-rw-r--r--src/gui/itemamount.h11
2 files changed, 48 insertions, 10 deletions
diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp
index a8389913..8cc28039 100644
--- a/src/gui/itemamount.cpp
+++ b/src/gui/itemamount.cpp
@@ -23,11 +23,14 @@
#include "gui/storagewindow.h"
#include "gui/trade.h"
+#include "gui/itempopup.h"
+#include "gui/viewport.h"
#include "gui/widgets/button.h"
#include "gui/widgets/inttextfield.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/slider.h"
+#include "gui/widgets/icon.h"
#include "item.h"
#include "localplayer.h"
@@ -80,6 +83,10 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
mItemAmountSlide->setActionEventId("Slide");
mItemAmountSlide->addActionListener(this);
+ //Item icon
+ Image *image = item->getImage();
+ mItemIcon = new Icon(image);
+
// Buttons
Button *minusButton = new Button("-", "Minus", this);
Button *plusButton = new Button("+", "Plus", this);
@@ -93,15 +100,17 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
// Set positions
ContainerPlacer place;
place = getPlacer(0, 0);
- place(0, 0, minusButton);
- place(1, 0, mItemAmountTextField);
- place(2, 0, plusButton);
- place(3, 0, addAllButton);
- place = getPlacer(0, 1);
- place(0, 0, mItemAmountSlide, 6);
- place = getPlacer(0, 2);
- place(4, 0, cancelButton);
- place(5, 0, okButton);
+ place(1, 0, minusButton);
+ place(2, 0, mItemAmountTextField);
+ place(3, 0, plusButton);
+ place(4, 0, addAllButton);
+
+ place(0, 1, mItemIcon);
+ place(1, 1, mItemAmountSlide, 5);
+
+ place(4, 2, cancelButton);
+ place(5, 2, okButton);
+
reflowLayout(225, 0);
resetAmount();
@@ -127,6 +136,25 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
setLocationRelativeTo(getParentWindow());
setVisible(true);
+
+ mItemPopup = new ItemPopup;
+ mItemIcon->addMouseListener(this);
+}
+
+// Show ItemTooltip
+void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
+{
+ if(event.getSource() == mItemIcon)
+ {
+ mItemPopup->setItem(mItem->getInfo());
+ mItemPopup->view(viewport->getMouseX(), viewport->getMouseY());
+ }
+}
+
+// Hide ItemTooltip
+void ItemAmountWindow::mouseExited(gcn::MouseEvent &event)
+{
+ mItemPopup->setVisible(false);
}
void ItemAmountWindow::resetAmount()
@@ -170,6 +198,7 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event)
void ItemAmountWindow::close()
{
+ delete mItemPopup;
scheduleDelete();
}
diff --git a/src/gui/itemamount.h b/src/gui/itemamount.h
index 312b9fc3..214f8b6b 100644
--- a/src/gui/itemamount.h
+++ b/src/gui/itemamount.h
@@ -29,13 +29,16 @@
class IntTextField;
class Item;
+class ItemPopup;
+class Icon;
/**
* Window used for selecting the amount of items to drop, trade or split.
*
* \ingroup Interface
*/
-class ItemAmountWindow : public Window, public gcn::ActionListener,
+class ItemAmountWindow : public Window,
+ public gcn::ActionListener,
public gcn::KeyListener
{
public:
@@ -57,6 +60,10 @@ class ItemAmountWindow : public Window, public gcn::ActionListener,
*/
void resetAmount();
+ // MouseListener
+ void mouseMoved(gcn::MouseEvent &event);
+ void mouseExited(gcn::MouseEvent &event);
+
/**
* Schedules the Item Amount window for deletion.
*/
@@ -78,9 +85,11 @@ class ItemAmountWindow : public Window, public gcn::ActionListener,
IntTextField *mItemAmountTextField; /**< Item amount caption. */
Item *mItem;
+ Icon *mItemIcon;
int mMax;
Usage mUsage;
+ ItemPopup *mItemPopup;
/**
* Item Amount buttons.