diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-21 22:39:53 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-21 22:39:53 +0000 |
commit | e4e3f73db10d345453f2c6d06ae1dc499a4c7404 (patch) | |
tree | 7117443cf1267f9354206c21d70ac4ae0ddefcec /src/gui | |
parent | 241e2461446a830194f202b840abcd3598f804a5 (diff) | |
download | mana-e4e3f73db10d345453f2c6d06ae1dc499a4c7404.tar.gz mana-e4e3f73db10d345453f2c6d06ae1dc499a4c7404.tar.bz2 mana-e4e3f73db10d345453f2c6d06ae1dc499a4c7404.tar.xz mana-e4e3f73db10d345453f2c6d06ae1dc499a4c7404.zip |
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.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/inventory.cpp | 20 | ||||
-rw-r--r-- | src/gui/inventory.h | 17 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 3 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 4 | ||||
-rw-r--r-- | src/gui/scrollarea.cpp | 12 |
5 files changed, 31 insertions, 25 deletions
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); } diff --git a/src/gui/inventory.h b/src/gui/inventory.h index 43a23ede..37edff7f 100644 --- a/src/gui/inventory.h +++ b/src/gui/inventory.h @@ -37,7 +37,8 @@ * * \ingroup Interface */ -class InventoryWindow : public Window, gcn::ActionListener { +class InventoryWindow : public Window, gcn::ActionListener +{ public: /** * Constructor. @@ -50,6 +51,11 @@ class InventoryWindow : public Window, gcn::ActionListener { ~InventoryWindow(); /** + * Logic (updates buttons) + */ + void logic(); + + /** * Add an item the inventory. */ int addItem(int index, int id, int quantity, bool equipment); @@ -58,14 +64,17 @@ class InventoryWindow : public Window, gcn::ActionListener { * Remove a item from the inventory. */ int removeItem(int id); - + + /** + * Equips an item. + */ void equipItem(int index); /** * Unequips an item. */ void unequipItem(int index); - + /** * Change quantity of an item. */ @@ -94,7 +103,7 @@ class InventoryWindow : public Window, gcn::ActionListener { int useItem(int index, int id); void updateWidgets(); /** Updates widgets size/position */ - void updateUseButton(); /** Updates use button to selected item */ + void updateButtons(); /** Updates button states */ gcn::Label *itemNameLabel; gcn::Label *itemDescriptionLabel; diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index a5c70632..d571f739 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -32,6 +32,7 @@ ItemContainer::ItemContainer() Image *itemImg = resman->getImage("graphics/sprites/items.png", IMG_ALPHA); if (!itemImg) logger->error("Unable to load items.png"); itemset = new Spriteset(itemImg, 20, 20); + itemImg->decRef(); selImg = resman->getImage("graphics/gui/selection.png", IMG_ALPHA); if (!selImg) logger->error("Unable to load selection.png"); @@ -50,6 +51,8 @@ ItemContainer::ItemContainer() ItemContainer::~ItemContainer() { + delete itemset; + selImg->decRef(); } void ItemContainer::draw(gcn::Graphics* graphics) diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 97c17924..9ee6892a 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -117,12 +117,12 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener * Adds a new item. */ void addItem(int index, int id, int quantity, bool equipment); - + /** * Set selected item to -1. */ void selectNone(); - + /** * Reset all item slots. */ diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index a5c5542f..ad31ada8 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -277,26 +277,18 @@ void ScrollArea::drawRightButton(gcn::Graphics *graphics) void ScrollArea::drawVBar(gcn::Graphics *graphics) { - //int x, y; gcn::Rectangle dim = getVerticalBarDimension(); - //getAbsolutePosition(x, y); - graphics->setColor(gcn::Color(0, 0, 0, 32)); graphics->fillRectangle(dim); - //((Graphics*)graphics)->drawImageRect( - // x + dim.x, y + dim.y, dim.width, dim.height, background); + graphics->setColor(gcn::Color(255, 255, 255)); } void ScrollArea::drawHBar(gcn::Graphics *graphics) { - //int x, y; gcn::Rectangle dim = getHorizontalBarDimension(); - //getAbsolutePosition(x, y); - graphics->setColor(gcn::Color(0, 0, 0, 32)); graphics->fillRectangle(dim); - //((Graphics*)graphics)->drawImageRect( - // x + dim.x, y + dim.y, dim.width, dim.height, background); + graphics->setColor(gcn::Color(255, 255, 255)); } void ScrollArea::drawVMarker(gcn::Graphics *graphics) |