summaryrefslogtreecommitdiff
path: root/src/gui/inventory.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-14 15:22:32 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-14 15:22:32 +0000
commit0dd8bc994b172f65d96e11e50e51643c24111907 (patch)
tree0eb6f2d51842b9a448a5f684508cb43cb6a4849f /src/gui/inventory.cpp
parentf0af955173deacbb11c6eda1766498cd781aa2e5 (diff)
downloadmana-0dd8bc994b172f65d96e11e50e51643c24111907.tar.gz
mana-0dd8bc994b172f65d96e11e50e51643c24111907.tar.bz2
mana-0dd8bc994b172f65d96e11e50e51643c24111907.tar.xz
mana-0dd8bc994b172f65d96e11e50e51643c24111907.zip
Mainly separating core GUI classes from game interface.
Diffstat (limited to 'src/gui/inventory.cpp')
-rw-r--r--src/gui/inventory.cpp43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index 088cb81c..bb8b7bf5 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -163,25 +163,20 @@ void InventoryWindow::action(const std::string &eventId)
itemAmountWindow->setUsage(AMOUNT_ITEM_DROP);
itemAmountWindow->setVisible(true);
itemAmountWindow->requestMoveToTop();
- }
+ }
+
+ updateUseButton();
}
}
void InventoryWindow::mouseClick(int x, int y, int button, int count)
{
Window::mouseClick(x, y, button, count);
+
+ updateUseButton();
if (items->getIndex() != -1)
{
- // Differentiate items & equipment
- if (items->isEquipment(items->getIndex()))
- if (items->isEquipped(items->getIndex()))
- useButton->setCaption("Unequip");
- else
- useButton->setCaption("Equip");
- else
- useButton ->setCaption("Use");
-
// Show Name and Description
std::string SomeText;
SomeText = "Name: " + itemDb->getItemInfo(items->getId())->getName();
@@ -198,20 +193,40 @@ void InventoryWindow::mouseMotion(int mx, int my)
int tmpWidth = getWidth(), tmpHeight = getHeight();
Window::mouseMotion(mx, my);
if (getWidth() != tmpWidth || getHeight() != tmpHeight) {
- updateWidgets();
+ updateWidgets();
}
}
void InventoryWindow::updateWidgets()
{
- //resize widgets
+ // Resize widgets
useButton->setPosition(8, getHeight() - 24);
dropButton->setPosition(48 + 16, getHeight() - 24);
- items->setSize(getWidth() - 24 - 12 - 1, (INVENTORY_SIZE * 24) / (getWidth() / 24) - 1);
+ items->setSize(getWidth() - 24 - 12 - 1,
+ (INVENTORY_SIZE * 24) / (getWidth() / 24) - 1);
invenScroll->setSize(getWidth() - 16, getHeight() - 72);
itemNameLabel->setPosition(8, invenScroll->getY() + invenScroll->getHeight() + 4);
- itemDescriptionLabel->setPosition(8, itemNameLabel->getY() + itemNameLabel->getHeight() + 4);
+ itemDescriptionLabel->setPosition(8,
+ itemNameLabel->getY() + itemNameLabel->getHeight() + 4);
setContentSize(getWidth(), getHeight());
}
+
+void InventoryWindow::updateUseButton()
+{
+ if (items->getIndex() != -1 && items->isEquipment(items->getIndex()))
+ {
+ if (items->isEquipped(items->getIndex())) {
+ useButton->setCaption("Unequip");
+ }
+ else {
+ useButton->setCaption("Equip");
+ }
+ }
+ else {
+ useButton ->setCaption("Use");
+ }
+
+ useButton->setEnabled(items->getIndex() != -1);
+}