summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-23 17:09:31 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-23 17:09:31 +0300
commit59425e630f91a1ad7de847142ef21ab99a1ca194 (patch)
tree35bc8f9e5b457d669c6758b6bcbb973a99b451cb /src/gui
parent4327ba13441b3f7cf8b7c5e66d0e445463142779 (diff)
downloadManaVerse-59425e630f91a1ad7de847142ef21ab99a1ca194.tar.gz
ManaVerse-59425e630f91a1ad7de847142ef21ab99a1ca194.tar.bz2
ManaVerse-59425e630f91a1ad7de847142ef21ab99a1ca194.tar.xz
ManaVerse-59425e630f91a1ad7de847142ef21ab99a1ca194.zip
Move equipment window slot names into file equipmentslots.xml
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/equipmentwindow.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 3aa4ca241..ce2d9fa67 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -46,9 +46,11 @@
#include "resources/equipmentslots.h"
#include "resources/imageset.h"
+#include "utils/checkutils.h"
#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
+#include "utils/xml.h"
#include "net/inventoryhandler.h"
@@ -741,12 +743,34 @@ void EquipmentWindow::loadSlot(const XmlNodePtr slotNode,
void EquipmentWindow::prepareSlotNames()
{
- const int sz = sizeof(equipmentSlots) / sizeof(EquipmentSlotMap);
mSlotNames.clear();
- for (int f = 0; f < sz; f ++)
+ XML::Document doc(paths.getStringValue("equipmentSlotsFile"),
+ UseResman_true,
+ SkipError_false);
+ const XmlNodePtrConst root = doc.rootNode();
+ if (!root)
+ return;
+
+ for_each_xml_child_node(slotNode, root)
{
- const EquipmentSlotMap &slotMap = equipmentSlots[f];
- mSlotNames[slotMap.name] = slotMap.id;
+ if (!xmlNameEqual(slotNode, "slot"))
+ continue;
+ const std::string name = XML::getProperty(slotNode, "name", "");
+ if (name.empty())
+ {
+ reportAlways("Empty slot name detected.");
+ continue;
+ }
+
+ const int slot = XML::getProperty(slotNode, "slot", -1);
+ if (slot < 0 || slot >= BOX_COUNT)
+ {
+ reportAlways("Wrong slot id '%d' for slot with name '%s'",
+ slot,
+ name.c_str());
+ continue;
+ }
+ mSlotNames[name] = slot;
}
}