diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-30 21:04:12 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-30 21:04:12 +0200 |
commit | aa8a8adb90c17e2a61c5245ea0dc3552ea78794f (patch) | |
tree | 52df77ded5c1621fc10e6d762f05235e029a46cc /src/net/manaserv/inventoryhandler.cpp | |
parent | ebe29a9410458abac19c4ba10d5dce476e7ca34b (diff) | |
download | mana-aa8a8adb90c17e2a61c5245ea0dc3552ea78794f.tar.gz mana-aa8a8adb90c17e2a61c5245ea0dc3552ea78794f.tar.bz2 mana-aa8a8adb90c17e2a61c5245ea0dc3552ea78794f.tar.xz mana-aa8a8adb90c17e2a61c5245ea0dc3552ea78794f.zip |
Added a way to specify where the equipment boxes will display.
A <box> sub tag was added to the <slot> tag with a x and y
parameter to do so.
Diffstat (limited to 'src/net/manaserv/inventoryhandler.cpp')
-rw-r--r-- | src/net/manaserv/inventoryhandler.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp index 1a74f732..94494319 100644 --- a/src/net/manaserv/inventoryhandler.cpp +++ b/src/net/manaserv/inventoryhandler.cpp @@ -211,19 +211,19 @@ void EquipBackend::readEquipFile() unsigned int slotIndex = 0; mVisibleSlots = 0; - for_each_xml_child_node(childNode, rootNode) + for_each_xml_child_node(slotNode, rootNode) { - if (!xmlStrEqual(childNode->name, BAD_CAST "slot")) + if (!xmlStrEqual(slotNode->name, BAD_CAST "slot")) continue; Slot slot; - slot.slotTypeId = XML::getProperty(childNode, "id", 0); - std::string name = XML::getProperty(childNode, "name", std::string()); - const int capacity = XML::getProperty(childNode, "capacity", 1); - slot.weaponSlot = XML::getBoolProperty(childNode, "weapon", false); - slot.ammoSlot = XML::getBoolProperty(childNode, "ammo", false); + slot.slotTypeId = XML::getProperty(slotNode, "id", 0); + std::string name = XML::getProperty(slotNode, "name", std::string()); + const int capacity = XML::getProperty(slotNode, "capacity", 1); + slot.weaponSlot = XML::getBoolProperty(slotNode, "weapon", false); + slot.ammoSlot = XML::getBoolProperty(slotNode, "ammo", false); - if (XML::getBoolProperty(childNode, "visible", false)) + if (XML::getBoolProperty(slotNode, "visible", false)) ++mVisibleSlots; if (slot.slotTypeId > 0 && capacity > 0) @@ -249,6 +249,23 @@ void EquipBackend::readEquipFile() ++slotIndex; } } + + // Read the box properties + readBoxNode(slotNode); + } +} + +void EquipBackend::readBoxNode(xmlNodePtr slotNode) +{ + for_each_xml_child_node(boxNode, slotNode) + { + if (!xmlStrEqual(boxNode->name, BAD_CAST "box")) + continue; + + int x = XML::getProperty(boxNode, "x" , 0); + int y = XML::getProperty(boxNode, "y" , 0); + + mBoxesPositions.push_back(Position(x, y)); } } @@ -274,6 +291,13 @@ bool EquipBackend::isAmmoSlot(int slotTypeId) const return false; } +Position EquipBackend::getBoxPosition(unsigned int slotIndex) const +{ + if (slotIndex < mBoxesPositions.size()) + return mBoxesPositions.at(slotIndex); + return Position(0, 0); +} + InventoryHandler::InventoryHandler() { static const Uint16 _messages[] = { |