summaryrefslogtreecommitdiff
path: root/src/resources/mapreader.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-09 23:16:24 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-12 01:30:01 +0300
commit0671c9981e922e37b8caacc84abfceb60b32aaff (patch)
tree7e5b40d7131e0b6b091475df0ed27766b6845391 /src/resources/mapreader.cpp
parent5692fe8584be17966f7bed2e97d22139f71619e3 (diff)
downloadmv-0671c9981e922e37b8caacc84abfceb60b32aaff.tar.gz
mv-0671c9981e922e37b8caacc84abfceb60b32aaff.tar.bz2
mv-0671c9981e922e37b8caacc84abfceb60b32aaff.tar.xz
mv-0671c9981e922e37b8caacc84abfceb60b32aaff.zip
Add support for tileset properties.
Diffstat (limited to 'src/resources/mapreader.cpp')
-rw-r--r--src/resources/mapreader.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 67959b819..4e38d5b0f 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -678,6 +678,7 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
XML::Document* doc = nullptr;
Tileset *set = nullptr;
std::string pathDir(path);
+ std::map<std::string, std::string> props;
if (xmlHasProp(node, BAD_CAST "source"))
{
@@ -723,6 +724,19 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
}
}
}
+ else if (xmlNameEqual(childNode, "properties"))
+ {
+ for_each_xml_child_node(propertyNode, childNode)
+ {
+ if (!xmlNameEqual(propertyNode, "property"))
+ continue;
+ std::string name = XML::getProperty(propertyNode, "name", "");
+ std::string value = XML::getProperty(
+ propertyNode, "value", "");
+ if (!name.empty())
+ props[name] = value;
+ }
+ }
else if (xmlNameEqual(childNode, "tile"))
{
for_each_xml_child_node(tileNode, childNode)
@@ -741,9 +755,12 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
std::string name = XML::getProperty(
propertyNode, "name", "");
int value = XML::getProperty(propertyNode, "value", 0);
- tileProperties[name] = value;
- logger->log("Tile Prop of %d \"%s\" = \"%d\"",
- tileGID, name.c_str(), value);
+ if (!name.empty())
+ {
+ tileProperties[name] = value;
+ logger->log("Tile Prop of %d \"%s\" = \"%d\"",
+ tileGID, name.c_str(), value);
+ }
}
// create animation
@@ -787,6 +804,8 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
delete doc;
+ if (set)
+ set->setProperties(props);
return set;
}