diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-07-17 21:10:44 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-07-17 21:10:44 +0000 |
commit | 9bf3338f82bfbd425debb2855d015c7bd0e33989 (patch) | |
tree | ba390f42ebb7149e91c3494bc6a4ef3ac919ae22 /src/gui/equipment.cpp | |
parent | fbf19c2cdde592b126fe91c0dfff480f1318f50c (diff) | |
download | mana-9bf3338f82bfbd425debb2855d015c7bd0e33989.tar.gz mana-9bf3338f82bfbd425debb2855d015c7bd0e33989.tar.bz2 mana-9bf3338f82bfbd425debb2855d015c7bd0e33989.tar.xz mana-9bf3338f82bfbd425debb2855d015c7bd0e33989.zip |
Added Item and Equipment class and made the appropriate places make use of them. Plus some cleanups.
Diffstat (limited to 'src/gui/equipment.cpp')
-rw-r--r-- | src/gui/equipment.cpp | 78 |
1 files changed, 26 insertions, 52 deletions
diff --git a/src/gui/equipment.cpp b/src/gui/equipment.cpp index 37623637..dbfc4f8d 100644 --- a/src/gui/equipment.cpp +++ b/src/gui/equipment.cpp @@ -22,16 +22,16 @@ */ #include <guichan.hpp> -#include "equipment.h" +#include "gui/equipment.h" +#include "../equipment.h" #include "../log.h" #include "../resources/resourcemanager.h" -#include "../resources/itemmanager.h" #include "../resources/image.h" #include <sstream> EquipmentWindow::EquipmentWindow(): - Window("Equipment"), arrows(0) + Window("Equipment") { setContentSize(200, 90); setPosition(40, 40); @@ -40,11 +40,6 @@ EquipmentWindow::EquipmentWindow(): Image *itemImg = resman->getImage("graphics/sprites/items.png"); if (!itemImg) logger->error("Unable to load items.png"); itemset = new Spriteset(itemImg, 32, 32); - - for (int i = 0; i < 10; i++ ) { - equipments[i].id = 0; - equipments[i].inventoryIndex = -1; - } } EquipmentWindow::~EquipmentWindow() @@ -59,62 +54,41 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) // Draw window graphics Window::draw(graphics); + Equipment *equipment = Equipment::getInstance(); + Item *item; + Image *image; + for (int i = 0; i < 8; i++) { - if (equipments[i].id > 0) { - Image *image = itemset->spriteset[itemDb->getItemInfo( - equipments[i].id)->getImage() - 1]; - dynamic_cast<Graphics*>(graphics)->drawImage( - image, x + 36 * (i % 4) + 10, y + 36 * (i / 4) + 25); - } graphics->setColor(gcn::Color(0, 0, 0)); graphics->drawRectangle(gcn::Rectangle(10 + 36 * (i % 4), 36 * (i / 4) + 25, 32, 32)); - } - graphics->setColor(gcn::Color(0, 0, 0)); - graphics->drawRectangle(gcn::Rectangle(160, 25, 32, 32)); - if (arrows) { - Image *image = itemset->spriteset[ - itemDb->getItemInfo(arrows)->getImage() - 1]; + if (!(item = equipment->getEquipment(i))) { + continue; + } + + image = itemset->spriteset[item->getInfo()->getImage() - 1]; dynamic_cast<Graphics*>(graphics)->drawImage( - image, x + 160, y + 25); - std::stringstream n; - n << arrowsNumber; - graphics->drawText(n.str(), 170, 62, - gcn::Graphics::CENTER); + image, x + 36 * (i % 4) + 10, y + 36 * (i / 4) + 25); } -} - -void EquipmentWindow::action(const std::string &eventId) -{ -} -void EquipmentWindow::addEquipment(int index, int id) -{ - equipments[index].id = id; -} - -void EquipmentWindow::removeEquipment(int index) -{ - equipments[index].id = 0; -} + graphics->setColor(gcn::Color(0, 0, 0)); + graphics->drawRectangle(gcn::Rectangle(160, 25, 32, 32)); -void EquipmentWindow::setInventoryIndex(int index, int inventoryIndex) -{ - equipments[index].inventoryIndex = inventoryIndex; -} + if (!(item = equipment->getArrows())) { + return; + } -int EquipmentWindow::getInventoryIndex(int index) -{ - return equipments[index].inventoryIndex; -} + image = itemset->spriteset[item->getInfo()->getImage() - 1]; -void EquipmentWindow::setArrows(int id) -{ - arrows = id; + dynamic_cast<Graphics*>(graphics)->drawImage( + image, x + 160, y + 25); + std::stringstream n; + n << item->getQuantity(); + graphics->drawText(n.str(), 170, 62, + gcn::Graphics::CENTER); } -int EquipmentWindow::getArrows() +void EquipmentWindow::action(const std::string &eventId) { - return arrows; } |