diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/inventorywindow.cpp | 28 | ||||
-rw-r--r-- | src/gui/inventorywindow.h | 6 |
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; |