summaryrefslogtreecommitdiff
path: root/src/gui/equipmentwindow.cpp
diff options
context:
space:
mode:
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);
+}