summaryrefslogtreecommitdiff
path: root/src/gui/equipmentwindow.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-10 16:13:40 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-10 16:13:40 +0200
commitcab1abe41887d8b3ab426fbb56716ce99a3a1807 (patch)
treea9c3a2b08dbcbb7ca91879eb18b550e7b3b7daa2 /src/gui/equipmentwindow.cpp
parent4a6cd2bb9168348a7f9521678bd71b72de755405 (diff)
downloadmana-cab1abe41887d8b3ab426fbb56716ce99a3a1807.tar.gz
mana-cab1abe41887d8b3ab426fbb56716ce99a3a1807.tar.bz2
mana-cab1abe41887d8b3ab426fbb56716ce99a3a1807.tar.xz
mana-cab1abe41887d8b3ab426fbb56716ce99a3a1807.zip
Make sure Unequip button is disabled when appropriate
Diffstat (limited to 'src/gui/equipmentwindow.cpp')
-rw-r--r--src/gui/equipmentwindow.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 8934f7ce..aa81361d 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -84,13 +84,14 @@ EquipmentWindow::EquipmentWindow():
setDefaultSize(180, 300, ImageRect::CENTER);
loadWindowState();
- gcn::Button *unequip = new Button(_("Unequip"), "unequip", this);
- gcn::Rectangle const &area = getChildrenArea();
- unequip->setPosition(area.width - unequip->getWidth() - 5,
- area.height - unequip->getHeight() - 5);
+ mUnequip = new Button(_("Unequip"), "unequip", this);
+ const gcn::Rectangle &area = getChildrenArea();
+ mUnequip->setPosition(area.width - mUnequip->getWidth() - 5,
+ area.height - mUnequip->getHeight() - 5);
+ mUnequip->setEnabled(false);
add(playerBox);
- add(unequip);
+ add(mUnequip);
for (int i = 0; i < EQUIP_VECTOREND; i++)
{
@@ -176,11 +177,11 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
mInventory->getItem(mEquipment->getArrows());
#endif
player_node->unequipItem(item);
- mSelected = -1;
+ setSelected(-1);
}
}
-Item* EquipmentWindow::getItem(int x, int y) const
+Item *EquipmentWindow::getItem(int x, int y) const
{
for (int i = 0; i < EQUIP_VECTOREND; i++)
{
@@ -224,7 +225,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
BOX_WIDTH, BOX_HEIGHT);
if (tRect.isPointInRect(x, y) && item)
- mSelected = i;
+ setSelected(i);
}
}
else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
@@ -268,3 +269,9 @@ void EquipmentWindow::mouseExited(gcn::MouseEvent &event)
{
mItemPopup->setVisible(false);
}
+
+void EquipmentWindow::setSelected(int index)
+{
+ mSelected = index;
+ mUnequip->setEnabled(mSelected != -1);
+}