diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-04-22 13:12:46 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-04-22 13:12:46 +0000 |
commit | 09f8e3e9d9c6ca2bc39c3178c4f21b027ac07bcb (patch) | |
tree | 73e0da7b621cebe406e3b456388a4d261f8b170b | |
parent | 00b3b347f845f8b1550777f09464463af3805098 (diff) | |
download | mana-09f8e3e9d9c6ca2bc39c3178c4f21b027ac07bcb.tar.gz mana-09f8e3e9d9c6ca2bc39c3178c4f21b027ac07bcb.tar.bz2 mana-09f8e3e9d9c6ca2bc39c3178c4f21b027ac07bcb.tar.xz mana-09f8e3e9d9c6ca2bc39c3178c4f21b027ac07bcb.zip |
New equipment window layout and some improvements to equip management
-rw-r--r-- | src/engine.cpp | 2 | ||||
-rw-r--r-- | src/game.cpp | 69 | ||||
-rw-r--r-- | src/gui/equipment.cpp | 39 | ||||
-rw-r--r-- | src/gui/equipment.h | 6 |
4 files changed, 74 insertions, 42 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 85c737c9..bed0b1d1 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -390,7 +390,7 @@ void Engine::draw() playerset->spriteset[4 * pf + dir]->draw(screen, being->text_x - 16, being->text_y - 80); if (being->weapon != 0 && being->action == ATTACK) { - weaponset->spriteset[4 * being->frame + dir]->draw(screen, + weaponset->spriteset[16 * (being->weapon - 1) + 4 * being->frame + dir]->draw(screen, being->text_x - 64, being->text_y - 80); } diff --git a/src/game.cpp b/src/game.cpp index 753b5a34..954bc63b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -571,11 +571,11 @@ void do_parse() { } fclose(file); */ -#ifdef __DEBUG +//#ifdef __DEBUG FILE *file = fopen("./docs/packet.list", "a"); fprintf(file, "%x\n", RFIFOW(0)); fclose(file); -#endif +//#endif // Parse packet based on their id switch (id) { case SMSG_LOGIN_SUCCESS: @@ -876,7 +876,8 @@ void do_parse() { RFIFOW(4 + loop * 18 + 2), RFIFOW(4 + loop * 18 + 6), false); // Trick because arrows are not considered equipment - if (RFIFOW(4 + loop * 18 + 2) == 1199) + if (RFIFOW(4 + loop * 18 + 2) == 1199 || + RFIFOW(4 + loop * 18 + 2) == 529) inventoryWindow->items->setEquipment( RFIFOW(4 + loop * 18), true); /*char info[40]; @@ -1226,6 +1227,12 @@ void do_parse() { case 0x00af: printf("sell %i\n", -RFIFOW(4)); inventoryWindow->increaseQuantity(RFIFOW(2), -RFIFOW(4)); + // If the item is arrow decrease number from equipment + // window when equipped + if (inventoryWindow->items->isEquipped(RFIFOW(2)) && ( + inventoryWindow->items->getId(RFIFOW(2)) == 529 || + inventoryWindow->items->getId(RFIFOW(2)) == 1199 ) ) + equipmentWindow->arrowsNumber -= RFIFOW(4); break; // Use an item case 0x01c8: @@ -1327,6 +1334,7 @@ void do_parse() { // Answer to equip item case 0x00aa: + logger.log("Equipping: %i %i %i", RFIFOW(2), RFIFOW(4), RFIFOB(6)); if (RFIFOB(6) == 0) chatWindow->chat_log("Unable to equip.", BY_SERVER); else { @@ -1337,14 +1345,13 @@ void do_parse() { mask *= 2; position++; } + logger.log("Position %i", position-1); int equippedId = equipmentWindow->equipments[position - 1].id; if (equippedId > 0) inventoryWindow->items->setEquipped( equipmentWindow->equipments[position - 1].inventoryIndex, false); - /*char info3[40]; - sprintf(info3, "info3 %i %i", position-1,equippedId); - chatWindow->chat_log(info3, BY_SERVER);*/ + inventoryWindow->items->setEquipped(RFIFOW(2), true); @@ -1360,21 +1367,18 @@ void do_parse() { case 1201: player_node->weapon = 1; break; + case 530: case 1200: player_node->weapon = 2; break; } + //player_node->weapon = 0; } } - /*char info[40]; - sprintf(info, "aa %i %i %i", RFIFOW(2),RFIFOW(4),RFIFOB(6)); - chatWindow->chat_log(info, BY_SERVER);*/ break; // Equipment related case 0x01d7: - /*char content[40]; - sprintf(content, "1d7 %i %i %i", RFIFOB(6), RFIFOW(7), RFIFOW(9)); - chatWindow->chat_log(content, BY_SERVER);*/ + logger.log("1d7 %i %i %i %i", RFIFOL(2), RFIFOB(6), RFIFOW(7), RFIFOW(9)); break; // Answer to unequip item case 0x00ac: @@ -1388,34 +1392,39 @@ void do_parse() { mask *= 2; position++; } - int equipmentId = equipmentWindow->equipments[position-1].id; - if (equipmentId > 0) - inventoryWindow->items->setEquipped( - equipmentWindow->equipments[position-1].inventoryIndex, false); - equipmentWindow->removeEquipment(position - 1); - inventoryWindow->items->setEquipped( - inventoryWindow->items->getIndex(), false); + inventoryWindow->items->setEquipped(RFIFOW(2), false); + switch (inventoryWindow->items->getId(RFIFOW(2))) { + case 529: + case 1199: + equipmentWindow->setArrows(0); + equipmentWindow->arrowsNumber = 0; + break; + default: + equipmentWindow->removeEquipment(position - 1); + break; + } player_node->weapon = 0; - } + logger.log("Unequipping: %i %i(%i) %i", RFIFOW(2),RFIFOW(4),RFIFOB(6), position -1); + } } - /*char info2[40]; - sprintf(info2, "ac %i %i %i", RFIFOW(2),RFIFOW(4),RFIFOB(6)); - chatWindow->chat_log(info2, BY_SERVER);*/ break; // Arrows equipped case 0x013c: - /*char info3[40]; - sprintf(info3, "13c %i", RFIFOW(2)); - chatWindow->chat_log(info3, BY_SERVER);*/ - inventoryWindow->items->setEquipped(RFIFOW(2), true); + if (RFIFOW(2) > 1) { + inventoryWindow->items->setEquipped(RFIFOW(2), true); + equipmentWindow->setArrows( + inventoryWindow->items->getId(RFIFOW(2))); + equipmentWindow->arrowsNumber = + inventoryWindow->items->getQuantity(RFIFOW(2)); + logger.log("Arrows equipped: %i", RFIFOW(2)); + } break; // Various messages case 0x013b: - /*char msg[40]; - sprintf(msg, "13b %i", RFIFOW(2)); - chatWindow->chat_log(msg, BY_SERVER);*/ if (RFIFOW(2) == 0) chatWindow->chat_log("Equip arrows first", BY_SERVER); + else + logger.log("0x013b: Unhandled message %i", RFIFOW(2)); break; // Updates a stat value case 0x00bc: diff --git a/src/gui/equipment.cpp b/src/gui/equipment.cpp index 95e9998c..e55b01b6 100644 --- a/src/gui/equipment.cpp +++ b/src/gui/equipment.cpp @@ -27,10 +27,12 @@ #include "../resources/resourcemanager.h" #include "../resources/image.h" +#include <sstream> + EquipmentWindow::EquipmentWindow(): - Window("Equipment") + Window("Equipment"), arrows(0) { - setContentSize(60, 200); + setContentSize(134, 60); setPosition(40, 40); ResourceManager *resman = ResourceManager::getInstance(); @@ -60,12 +62,21 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) if (equipments[i].id > 0) { itemset->spriteset[itemDb.getItemInfo( equipments[i].id)->getImage() - 1]->draw( - screen, x + 22, y + 24 * i + 20); + screen, x + 24 * (i % 4) + 10, y + 24 * (i / 4) + 25); } graphics->setColor(gcn::Color(0, 0, 0)); - graphics->drawRectangle(gcn::Rectangle(22, 24 * i + 20, 20, 20)); - - + graphics->drawRectangle(gcn::Rectangle(10 + 24 * (i % 4), + 24 * (i / 4) + 25, 20, 20)); + } + graphics->setColor(gcn::Color(0, 0, 0)); + graphics->drawRectangle(gcn::Rectangle(110, 25, 20, 20)); + if (arrows) { + itemset->spriteset[itemDb.getItemInfo(arrows)->getImage() - 1]->draw( + screen, x + 110, y + 25); + std::stringstream n; + n << arrowsNumber; + graphics->drawText(n.str(), 120, 50, + gcn::Graphics::CENTER); } } @@ -73,19 +84,27 @@ void EquipmentWindow::action(const std::string &eventId) { } -void EquipmentWindow::addEquipment(int index, int id) { +void EquipmentWindow::addEquipment(int index, int id) +{ equipments[index].id = id; } -void EquipmentWindow::removeEquipment(int index) { +void EquipmentWindow::removeEquipment(int index) +{ equipments[index].id = 0; } -void EquipmentWindow::setInventoryIndex(int index, int inventoryIndex) { +void EquipmentWindow::setInventoryIndex(int index, int inventoryIndex) +{ equipments[index].inventoryIndex = inventoryIndex; } -int EquipmentWindow::getInventoryIndex(int index) { +int EquipmentWindow::getInventoryIndex(int index) +{ return equipments[index].inventoryIndex; } +void EquipmentWindow::setArrows(int id) +{ + arrows = id; +} diff --git a/src/gui/equipment.h b/src/gui/equipment.h index 7a945f4c..8dde09d6 100644 --- a/src/gui/equipment.h +++ b/src/gui/equipment.h @@ -68,10 +68,14 @@ class EquipmentWindow : public Window, gcn::ActionListener { int getInventoryIndex(int index); + void setArrows(int id); + EQUIPMENT_HOLDER equipments[10]; - private: + int arrowsNumber; + private: + int arrows; Spriteset *itemset; }; |