summaryrefslogtreecommitdiffstats
path: root/src/Data/Level.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Level.cpp')
-rw-r--r--src/Data/Level.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/Data/Level.cpp b/src/Data/Level.cpp
index e3c69fd..ff6f8fb 100644
--- a/src/Data/Level.cpp
+++ b/src/Data/Level.cpp
@@ -22,20 +22,37 @@
namespace ZoomEdit {
namespace Data {
-Level::Level(xmlpp::Element *levelNode) {
+Level::Level(xmlpp::Element *levelNode) : info(dynamic_cast<xmlpp::Element*>(levelNode->get_children("info").front())) {
roomsNode = dynamic_cast<xmlpp::Element*>(levelNode->get_children("rooms").front());
+ gatesNode = dynamic_cast<xmlpp::Element*>(levelNode->get_children("gates").front());
+ texturesNode = dynamic_cast<xmlpp::Element*>(levelNode->get_children("textures").front());
- if(!roomsNode)
- return;
+ xmlpp::Node::NodeList nodeList = roomsNode->get_children("room");
- xmlpp::Node::NodeList roomList = roomsNode->get_children("room");
-
- for(xmlpp::Node::NodeList::iterator room = roomList.begin(); room != roomList.end(); ++room) {
+ for(xmlpp::Node::NodeList::iterator room = nodeList.begin(); room != nodeList.end(); ++room) {
xmlpp::Element *roomNode = dynamic_cast<xmlpp::Element*>(*room);
if(roomNode)
rooms.push_front(Room(roomNode));
}
+
+ nodeList = gatesNode->get_children("gate");
+
+ for(xmlpp::Node::NodeList::iterator gate = nodeList.begin(); gate != nodeList.end(); ++gate) {
+ xmlpp::Element *gateNode = dynamic_cast<xmlpp::Element*>(*gate);
+
+ if(gateNode)
+ gates.push_front(Gate(gateNode));
+ }
+
+ nodeList = texturesNode->get_children("texture");
+
+ for(xmlpp::Node::NodeList::iterator tex = nodeList.begin(); tex != nodeList.end(); ++tex) {
+ xmlpp::Element *texNode = dynamic_cast<xmlpp::Element*>(*tex);
+
+ if(texNode)
+ textures.push_front(Texture(texNode));
+ }
}
}