summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-26 00:30:06 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-26 00:30:06 +0300
commitc90660f93d2f2b367a55726bd6f8943b82b73efb (patch)
tree0c7066492c102a98b7bdc9d23a8e37111f13a53e
parent5544b7e2e0b8fcdb9f0ac3762751f34a3383ef84 (diff)
downloadmanaplus-c90660f93d2f2b367a55726bd6f8943b82b73efb.tar.gz
manaplus-c90660f93d2f2b367a55726bd6f8943b82b73efb.tar.bz2
manaplus-c90660f93d2f2b367a55726bd6f8943b82b73efb.tar.xz
manaplus-c90660f93d2f2b367a55726bd6f8943b82b73efb.zip
Show money popup in inventory window if mouse over weight or count bars.
-rw-r--r--src/gui/inventorywindow.cpp28
-rw-r--r--src/gui/inventorywindow.h6
2 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 11c15a012..fd1916a58 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -34,6 +34,7 @@
#include "gui/outfitwindow.h"
#include "gui/setup.h"
#include "gui/shopwindow.h"
+#include "gui/textpopup.h"
#include "gui/tradewindow.h"
#include "gui/viewport.h"
@@ -123,6 +124,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mNameFilterCell(nullptr),
mFilterCell(nullptr),
mSlotsBarCell(nullptr),
+ mTextPopup(new TextPopup),
mSplit(false),
mCompactMode(false)
{
@@ -273,6 +275,8 @@ InventoryWindow::~InventoryWindow()
invInstances.front()->updateDropButton();
delete mSortModel;
mSortModel = nullptr;
+ delete mTextPopup;
+ mTextPopup = nullptr;
}
void InventoryWindow::action(const gcn::ActionEvent &event)
@@ -549,6 +553,30 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
}
}
+void InventoryWindow::mouseMoved(gcn::MouseEvent &event)
+{
+ Window::mouseMoved(event);
+ gcn::Widget *const src = event.getSource();
+ if (src == mSlotsBar || src == mWeightBar)
+ {
+ const int x = event.getX();
+ const int y = event.getY();
+ const gcn::Rectangle &rect = mDimension;
+ mTextPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"),
+ Units::formatCurrency(PlayerInfo::getAttribute(
+ PlayerInfo::MONEY)).c_str()));
+ }
+ else
+ {
+ mTextPopup->hide();
+ }
+}
+
+void InventoryWindow::mouseExited(gcn::MouseEvent &event)
+{
+ mTextPopup->hide();
+}
+
void InventoryWindow::keyPressed(gcn::KeyEvent &event)
{
if (static_cast<KeyEvent*>(&event)->getActionId()
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 952eb2afc..74e16d5f2 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -45,6 +45,7 @@ class ProgressBar;
class SortListModelInv;
class TabStrip;
class TextField;
+class TextPopup;
/**
* Inventory dialog.
@@ -144,6 +145,10 @@ class InventoryWindow final : public Window,
void widgetResized(const gcn::Event &event) override;
+ void mouseMoved(gcn::MouseEvent &event) override;
+
+ void mouseExited(gcn::MouseEvent &event) override;
+
static bool isAnyInputFocused();
private:
@@ -181,6 +186,7 @@ class InventoryWindow final : public Window,
LayoutCell *mNameFilterCell;
LayoutCell *mFilterCell;
LayoutCell *mSlotsBarCell;
+ TextPopup *mTextPopup;
bool mSplit;
bool mCompactMode;