From cc4ac1e1884378e861efd577507a28ae668156f1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 7 May 2013 17:18:14 +0300 Subject: improve inventorywindow class. --- src/gui/inventorywindow.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 6ff6506b3..11c15a012 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -80,10 +80,10 @@ public: virtual ~SortListModelInv() { } - virtual int getNumberOfElements() + virtual int getNumberOfElements() override { return 6; } - virtual std::string getElementAt(int i) + virtual std::string getElementAt(int i) override { if (i >= getNumberOfElements() || i < 0) return "???"; @@ -173,14 +173,14 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): if (isMainInventory()) { // TRANSLATORS: inventory button - std::string equip = _("Equip"); + const std::string equip = _("Equip"); // TRANSLATORS: inventory button - std::string use = _("Use"); + const std::string use = _("Use"); // TRANSLATORS: inventory button - std::string unequip = _("Unequip"); + const std::string unequip = _("Unequip"); std::string longestUseString = getFont()->getWidth(equip) > - getFont()->getWidth(use) ? equip : use; + getFont()->getWidth(use) ? equip : use; if (getFont()->getWidth(longestUseString) < getFont()->getWidth(unequip)) @@ -577,8 +577,8 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED) if (mSplit && item && Net::getInventoryHandler()-> canSplit(mItems->getSelectedItem())) { - ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item, - (item->getQuantity() - 1)); + ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, + this, item, item->getQuantity() - 1); } updateButtons(item); } @@ -655,7 +655,8 @@ void InventoryWindow::close() } else { - Net::getInventoryHandler()->closeStorage(Inventory::STORAGE); + if (Net::getInventoryHandler()) + Net::getInventoryHandler()->closeStorage(Inventory::STORAGE); scheduleDelete(); } } @@ -720,7 +721,6 @@ void InventoryWindow::updateDropButton() else { const Item *const item = mItems->getSelectedItem(); - if (item && item->getQuantity() > 1) { // TRANSLATORS: inventory button -- cgit v1.2.3-60-g2f50