summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/inventorywindow.cpp9
-rw-r--r--src/gui/inventorywindow.h7
-rw-r--r--src/net/tmwa/inventoryhandler.cpp10
-rw-r--r--src/net/tmwa/inventoryhandler.h2
4 files changed, 26 insertions, 2 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 591ebd2f..16ac5409 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -288,10 +288,18 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
(item->getQuantity() - 1));
}
+ updateButtons();
+}
+
+void InventoryWindow::updateButtons()
+{
+ Item *item = mItems->getSelectedItem();
+
if (!item || item->getQuantity() == 0)
{
mUseButton->setEnabled(false);
mDropButton->setEnabled(false);
+ mSplitButton->setEnabled(false);
return;
}
@@ -322,7 +330,6 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
mSplitButton->setEnabled(false);
}
-
void InventoryWindow::setSplitAllowed(bool allowed)
{
mSplitButton->setVisible(allowed);
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index f611e934..0dce0611 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -100,7 +100,12 @@ class InventoryWindow : public Window,
* window has been closed.
*/
void close();
-
+
+ /**
+ * Updates the buttons.
+ */
+ void updateButtons();
+
/**
* Updates the weight bar.
*/
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 7363c738..f5b379b9 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -245,6 +245,8 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
inventory->setItem(index, itemId, amount, equipType != 0);
}
+
+ inventoryWindow->updateButtons();
} break;
case SMSG_PLAYER_INVENTORY_REMOVE:
@@ -255,6 +257,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
item->increaseQuantity(-amount);
if (item->getQuantity() == 0)
inventory->removeItemAt(index);
+ inventoryWindow->updateButtons();
}
break;
@@ -266,7 +269,11 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
msg.readInt8(); // type
if (Item *item = inventory->getItem(index))
+ {
item->setQuantity(amount);
+ inventoryWindow->updateButtons();
+ }
+
break;
case SMSG_ITEM_USE_RESPONSE:
@@ -280,7 +287,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
else
{
if (Item *item = inventory->getItem(index))
+ {
item->setQuantity(amount);
+ inventoryWindow->updateButtons();
+ }
}
break;
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 82738afe..0c4ad092 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -87,6 +87,8 @@ class EquipBackend : public Equipment::Backend {
{
item->setEquipped(true);
}
+
+ inventoryWindow->updateButtons();
}
private: