From 209a5bb20f9ae861f078622804a81cfee2af2945 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 26 Jan 2015 14:04:24 +0300 Subject: Show tooltips in inventory buttons. --- src/gui/windows/inventorywindow.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index d99717c9b..e85207ec5 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -212,6 +212,15 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) : mWeightBar->setColor(getThemeColor(Theme::WEIGHT_BAR), getThemeColor(Theme::WEIGHT_BAR_OUTLINE)); + // TRANSLATORS: outfits button tooltip + mOutfitButton->setDescription(_("Outfits")); + // TRANSLATORS: cart button tooltip + mCartButton->setDescription(_("Cart")); + // TRANSLATORS: shop button tooltip + mShopButton->setDescription(_("Shop")); + // TRANSLATORS: equipment button tooltip + mEquipmentButton->setDescription(_("Equipment")); + place(0, 0, mWeightBar, 4); mSlotsBarCell = &place(4, 0, mSlotsBar, 4); mSortDropDownCell = &place(8, 0, mSortDropDown, 3); @@ -628,18 +637,29 @@ void InventoryWindow::mouseMoved(MouseEvent &event) return; const Widget *const src = event.getSource(); + if (!src) + { + textPopup->hide(); + return; + } + const int x = event.getX(); + const int y = event.getY(); + const Rect &rect = mDimension; if (src == mSlotsBar || src == mWeightBar) { - const int x = event.getX(); - const int y = event.getY(); - const Rect &rect = mDimension; textPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"), Units::formatCurrency(PlayerInfo::getAttribute( Attributes::MONEY)).c_str())); } else { - textPopup->hide(); + const Button *const btn = dynamic_cast(src); + if (!btn) + { + textPopup->hide(); + return; + } + textPopup->show(x + rect.x, y + rect.y, btn->getDescription()); } } -- cgit v1.2.3-60-g2f50