summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-12 02:46:54 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-12 02:46:54 +0300
commit37f8e4429b9620e6734fa5f1c9a760181dc35001 (patch)
treec5562f94fd8f890a3427b6f3e14b138819999e8a
parent474a96f27843a544b0a340c7a3b24d262490d5c8 (diff)
downloadplus-37f8e4429b9620e6734fa5f1c9a760181dc35001.tar.gz
plus-37f8e4429b9620e6734fa5f1c9a760181dc35001.tar.bz2
plus-37f8e4429b9620e6734fa5f1c9a760181dc35001.tar.xz
plus-37f8e4429b9620e6734fa5f1c9a760181dc35001.zip
Updating equip/unequip buttons in inventory.
-rw-r--r--src/gui/inventorywindow.cpp16
-rw-r--r--src/gui/inventorywindow.h2
-rw-r--r--src/net/tmwa/inventoryhandler.h3
3 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 403868cd1..a41334d06 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -427,6 +427,20 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event _UNUSED_)
ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
(item->getQuantity() - 1));
}
+ updateButtons(item);
+}
+
+void InventoryWindow::updateButtons(Item *item)
+{
+ if (!mInventory || !mInventory->isMainInventory())
+ return;
+
+ Item *selectedItem = mItems->getSelectedItem();
+ if (item && selectedItem != item)
+ return;
+
+ if (!item)
+ item = selectedItem;
if (!item || item->getQuantity() == 0)
{
@@ -472,8 +486,8 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event _UNUSED_)
else
mSplitButton->setEnabled(false);
}
-}
+}
void InventoryWindow::setSplitAllowed(bool allowed)
{
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 63da97173..9ca45aaea 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -126,6 +126,8 @@ class InventoryWindow : public Window,
void event(Mana::Channels channel, const Mana::Event &event);
+ void updateButtons(Item *item = 0);
+
private:
/**
* Updates the weight bar.
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 8dd39a781..c91fb01f7 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -94,6 +94,9 @@ class EquipBackend : public Equipment::Backend
item = PlayerInfo::getInventory()->getItem(inventoryIndex);
if (item)
item->setEquipped(true);
+
+ if (inventoryWindow)
+ inventoryWindow->updateButtons();
}
private: