From c90660f93d2f2b367a55726bd6f8943b82b73efb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 May 2013 00:30:06 +0300 Subject: Show money popup in inventory window if mouse over weight or count bars. --- src/gui/inventorywindow.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/gui/inventorywindow.cpp') 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(&event)->getActionId() -- cgit v1.2.3-60-g2f50