diff options
author | Chuck Miller <shadowmil@gmail.com> | 2009-05-08 02:12:22 -0400 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2009-05-08 02:12:22 -0400 |
commit | f1c460190f7d2c0e2b9fd70ac21ba11a11fc8464 (patch) | |
tree | 4412f10f318fdbfe9b866d47f6ae02aa3555e18a | |
parent | ec4656af8e2d1946ea2b1d036457c885a9e420dd (diff) | |
download | mana-f1c460190f7d2c0e2b9fd70ac21ba11a11fc8464.tar.gz mana-f1c460190f7d2c0e2b9fd70ac21ba11a11fc8464.tar.bz2 mana-f1c460190f7d2c0e2b9fd70ac21ba11a11fc8464.tar.xz mana-f1c460190f7d2c0e2b9fd70ac21ba11a11fc8464.zip |
Correctly disables the use and drop buttons when no items are selected
-rw-r--r-- | src/gui/inventorywindow.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 027c6aa8..08abaf92 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -163,7 +163,8 @@ void InventoryWindow::action(const gcn::ActionEvent &event) if (event.getId() == "use") { - if (item->isEquipment()) { + if (item->isEquipment()) + { if (item->isEquipped()) player_node->unequipItem(item); else @@ -241,6 +242,7 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event) } } + void InventoryWindow::setSplitAllowed(bool allowed) { mSplitButton->setVisible(allowed); @@ -250,7 +252,17 @@ void InventoryWindow::updateButtons() { const Item *selectedItem = mItems->getSelectedItem(); - if (selectedItem && selectedItem->isEquipment()) + if (!selectedItem || selectedItem->getQuantity() == 0) + { + mUseButton->setEnabled(false); + mDropButton->setEnabled(false); + return; + } + + mUseButton->setEnabled(true); + mDropButton->setEnabled(true); + + if (selectedItem->isEquipment()) { if (selectedItem->isEquipped()) mUseButton->setCaption(_("Unequip")); @@ -258,10 +270,9 @@ void InventoryWindow::updateButtons() mUseButton->setCaption(_("Equip")); } else + { mUseButton->setCaption(_("Use")); - - mUseButton->setEnabled(selectedItem != 0); - mDropButton->setEnabled(selectedItem != 0); + } if (Net::getInventoryHandler()->canSplit(selectedItem)) { |