From e4e3f73db10d345453f2c6d06ae1dc499a4c7404 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 21 May 2005 22:39:53 +0000 Subject: Numerous things: * Fixed two non-virtual destructor warnings showing up with GCC 4. * Fixed OpenGL inventory text drawing that broke in last commit * Removed glClear cause screen is redrawn completely anyway * Fixed updating of buttons in inventory window * Made items.xml be loaded through resource manager. --- src/gui/inventory.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/gui/inventory.cpp') diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp index 4a1c0ca3..f73c240e 100644 --- a/src/gui/inventory.cpp +++ b/src/gui/inventory.cpp @@ -76,6 +76,13 @@ InventoryWindow::~InventoryWindow() delete itemDescriptionLabel; } +void InventoryWindow::logic() +{ + // It would be nicer if this update could be event based, needs some + // redesign of InventoryWindow and ItemContainer probably. + updateButtons(); +} + int InventoryWindow::addItem(int index, int id, int quantity, bool equipment) { items->addItem(index, id, quantity, equipment); @@ -90,14 +97,12 @@ int InventoryWindow::removeItem(int id) int InventoryWindow::changeQuantity(int index, int quantity) { - //items[index].quantity = quantity; items->changeQuantity(index, quantity); return 0; } int InventoryWindow::increaseQuantity(int index, int quantity) { - //items[index].quantity += quantity; items->increaseQuantity(index, quantity); return 0; } @@ -147,8 +152,8 @@ void InventoryWindow::action(const std::string &eventId) if (selectedItem != -1) { if (eventId == "use") { - if(items->isEquipment(selectedItem)) { - if(items->isEquipped(selectedItem)) { + if (items->isEquipment(selectedItem)) { + if (items->isEquipped(selectedItem)) { unequipItem(selectedItem); } else { @@ -164,8 +169,6 @@ void InventoryWindow::action(const std::string &eventId) // Choose amount of items to drop new ItemAmountWindow(AMOUNT_ITEM_DROP, this); } - - updateUseButton(); } } @@ -173,8 +176,6 @@ void InventoryWindow::mouseClick(int x, int y, int button, int count) { Window::mouseClick(x, y, button, count); - updateUseButton(); - if (items->getIndex() != -1) { // Show Name and Description @@ -213,7 +214,7 @@ void InventoryWindow::updateWidgets() setContentSize(getWidth(), getHeight()); } -void InventoryWindow::updateUseButton() +void InventoryWindow::updateButtons() { if (items->getIndex() != -1 && items->isEquipment(items->getIndex())) { @@ -229,4 +230,5 @@ void InventoryWindow::updateUseButton() } useButton->setEnabled(items->getIndex() != -1); + dropButton->setEnabled(items->getIndex() != -1); } -- cgit v1.2.3-70-g09d2