From 919e6bef84e3670b206f192613558274a341b976 Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Sat, 28 Aug 2010 18:56:14 +0200 Subject: Fixing omitted items in equipment window Bug description: If a player has equipable items only, then the equipment backend gets not initialized. As a consequence the equipment window remains empty. This is particularly a problem for new characters. Signed-off-by: Jared Adams --- src/net/tmwa/inventoryhandler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/net/tmwa/inventoryhandler.cpp') diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index fd979dc6..7363c738 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -127,6 +127,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) int index, amount, itemId, equipType, arrow; int identified, cards[4], itemType; Inventory *inventory = player_node->getInventory(); + player_node->mEquipment->setBackend(&mEquips); switch (msg.getId()) { @@ -136,8 +137,6 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { // Clear inventory - this will be a complete refresh mEquips.clear(); - player_node->mEquipment->setBackend(&mEquips); - inventory->clear(); } else -- cgit v1.2.3-70-g09d2 From 173cbf107b35fb191724e5386cf3bcf0106c80ae Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Wed, 8 Sep 2010 21:56:44 +0200 Subject: Adding missing updates for buttons in InventoryWindow Reviewed-by: Thorbjorn --- src/gui/inventorywindow.cpp | 9 ++++++++- src/gui/inventorywindow.h | 7 ++++++- src/net/tmwa/inventoryhandler.cpp | 10 ++++++++++ src/net/tmwa/inventoryhandler.h | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src/net/tmwa/inventoryhandler.cpp') 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: -- cgit v1.2.3-70-g09d2 From 29e9ff188f1d64705ce53e8196e97b5eef30a547 Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Sat, 11 Sep 2010 19:27:17 +0200 Subject: Making sure the inventory window shows the correct number of used slots The SlotsBar is updated, if InventoryWindow::slotsChanged() is called. This did not happen when an item disappeared from the inventory, because of using it. Then the item quantity was just set to 0, but the SlotBar was not notified. Reviewed-by: Jaxad0127 --- src/net/tmwa/inventoryhandler.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/net/tmwa/inventoryhandler.cpp') diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index f5b379b9..3809399d 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -270,7 +270,11 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) if (Item *item = inventory->getItem(index)) { - item->setQuantity(amount); + if (amount) + item->setQuantity(amount); + else + inventory->removeItemAt(index); + inventoryWindow->updateButtons(); } @@ -288,7 +292,11 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { if (Item *item = inventory->getItem(index)) { - item->setQuantity(amount); + if (amount) + item->setQuantity(amount); + else + inventory->removeItemAt(index); + inventoryWindow->updateButtons(); } } -- cgit v1.2.3-70-g09d2