summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/equipmentwindow.cpp23
-rw-r--r--src/gui/equipmentwindow.h5
2 files changed, 20 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);
+}
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index f6ba19f8..8bc350a4 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -24,6 +24,8 @@
#include "gui/widgets/window.h"
+#include "guichanfwd.h"
+
#include <guichan/actionlistener.hpp>
class Equipment;
@@ -102,6 +104,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener
Item *getItem(int x, int y) const;
+ void setSelected(int index);
+
Equipment *mEquipment;
#ifdef EATHENA_SUPPORT
Inventory *mInventory;
@@ -119,6 +123,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener
EquipBox mEquipBox[EQUIP_VECTOREND]; /**< Equipment Boxes. */
ItemPopup *mItemPopup;
+ gcn::Button *mUnequip;
int mSelected; /**< Index of selected item. */
};