Skip to content

Commit

Permalink
Merge pull request #151 from Karamu98/master
Browse files Browse the repository at this point in the history
Partial Tiled 1.8 Support
  • Loading branch information
fallahn committed Nov 12, 2023
2 parents d259a59 + 6c01634 commit a534fe3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tmxlite/include/tmxlite/Property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ source distribution.

#include <string>
#include <cassert>
#include <vector>

namespace pugi
{
Expand Down Expand Up @@ -60,6 +61,7 @@ namespace tmx
Colour,
File,
Object,
Class,
Undef
};

Expand Down Expand Up @@ -122,6 +124,16 @@ namespace tmx
*/
const std::string& getFileValue() const { assert(m_type == Type::File); return m_stringValue; }

/*!
\brief Returns an array of properties
*/
const std::vector<Property>& getClassValue() const {assert(m_type == Type::Class); return m_classValue; }

/*!
\brief Returns an the propertytype value
*/
const std::string getPropertyType() const {assert(m_type == Type::Class); return m_propertyType; }

/*!
\brief Returns the property's value as an integer object handle
*/
Expand All @@ -137,7 +149,10 @@ namespace tmx
};
std::string m_stringValue;
std::string m_name;
std::string m_propertyType;

Colour m_colourValue;
std::vector<Property> m_classValue;

Type m_type;
};
Expand Down
16 changes: 16 additions & 0 deletions tmxlite/src/Property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,20 @@ void Property::parse(const pugi::xml_node& node, bool isObjectTypes)
m_type = Type::Object;
return;
}
else if (attribData == "class")
{
m_type = Type::Class;
m_propertyType = node.attribute("propertytype").as_string("null");

const std::string firstChildName = node.first_child().name();
if (firstChildName == "properties")
{
for(const auto& childProp : node.first_child().children())
{
m_classValue.emplace_back();
m_classValue.back().parse(childProp);
}
}
return;
}
}

0 comments on commit a534fe3

Please sign in to comment.