diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-22 16:17:03 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-22 16:17:03 +0300 |
commit | 2131f55532ee9e71b41de99aff0718346fb184c6 (patch) | |
tree | 1aa214c995d2d5a05d8a02cf6b35dc4c6129d687 /src/gui/windows/equipmentwindow.cpp | |
parent | abdb8299382a797728b8dac80f6e687c90fb07ab (diff) | |
download | manaplus-2131f55532ee9e71b41de99aff0718346fb184c6.tar.gz manaplus-2131f55532ee9e71b41de99aff0718346fb184c6.tar.bz2 manaplus-2131f55532ee9e71b41de99aff0718346fb184c6.tar.xz manaplus-2131f55532ee9e71b41de99aff0718346fb184c6.zip |
Move equipment window slots names mapping to id to separate file.
Diffstat (limited to 'src/gui/windows/equipmentwindow.cpp')
-rw-r--r-- | src/gui/windows/equipmentwindow.cpp | 109 |
1 files changed, 15 insertions, 94 deletions
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index c5933b106..e37d623d6 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -45,6 +45,7 @@ #include "gui/widgets/playerbox.h" #include "gui/widgets/tabstrip.h" +#include "resources/equipmentslots.h" #include "resources/imageset.h" #include "resources/itemslot.h" @@ -57,6 +58,7 @@ EquipmentWindow *equipmentWindow = nullptr; EquipmentWindow *beingEquipmentWindow = nullptr; static const int BOX_COUNT = 22; +std::map<std::string, int> EquipmentWindow::mSlotNames; EquipmentWindow::EquipmentWindow(Equipment *const equipment, Being *const being, @@ -644,104 +646,23 @@ void EquipmentWindow::loadSlot(const XmlNodePtr slotNode, mMaxY = y + mBoxSize; } -int EquipmentWindow::parseSlotName(const std::string &name) +void EquipmentWindow::prepareSlotNames() { - int id = -1; - if (name == "shoes" || name == "boot" - || name == "boots" || name == "slot4") - { - id = 4; - } - else if (name == "bottomclothes" || name == "bottom" - || name == "pants" || name == "slot3") - { - id = 3; - } - else if (name == "topclothes" || name == "top" - || name == "torso" || name == "body" || name == "slot0") - { - id = 0; - } - else if (name == "misc1" || name == "cape" || name == "slot5") - { - id = 5; - } - else if (name == "misc2" || name == "scarf" - || name == "scarfs" || name == "slot7") - { - id = 7; - } - else if (name == "hat" || name == "hats" || name == "slot2") - { - id = 2; - } - else if (name == "wings" || name == "slot6") - { - id = 6; - } - else if (name == "glove" || name == "gloves" || name == "slot1") - { - id = 1; - } - else if (name == "weapon" || name == "weapons" || name == "slot8") - { - id = 8; - } - else if (name == "shield" || name == "shields" || name == "slot9") - { - id = 9; - } - else if (name == "amulet" || name == "amulets" || name == "slot11") - { - id = 11; - } - else if (name == "ring" || name == "rings" || name == "slot12") + const int sz = sizeof(equipmentSlots) / sizeof(EquipmentSlotMap); + mSlotNames.clear(); + for (int f = 0; f < sz; f ++) { - id = 12; - } - else if (name == "arrow" || name == "arrows" - || name == "ammo" || name == "slot10") - { - id = 10; - } - else if (name == "slot13") - { - id = 13; - } - else if (name == "slot14") - { - id = 14; - } - else if (name == "slot15") - { - id = 15; - } - else if (name == "slot16") - { - id = 16; - } - else if (name == "slot17") - { - id = 17; - } - else if (name == "slot18") - { - id = 18; - } - else if (name == "slot19") - { - id = 19; - } - else if (name == "slot20") - { - id = 20; - } - else if (name == "slot21") - { - id = 21; + const EquipmentSlotMap &slotMap = equipmentSlots[f]; + mSlotNames[slotMap.name] = slotMap.id; } +} - return id; +int EquipmentWindow::parseSlotName(const std::string &name) +{ + std::map<std::string, int>::const_iterator it = mSlotNames.find(name); + if (it != mSlotNames.end()) + return (*it).second; + return -1; } void EquipmentWindow::fillDefault() |