Skip to content

Commit

Permalink
Merge pull request #110 from ironpowertga/1.9
Browse files Browse the repository at this point in the history
update to be compatible with tiled 1.9
  • Loading branch information
fallahn authored Jun 28, 2022
2 parents 6c0f878 + 1eb6988 commit 7872ea6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Debug
Release

*.swp
/.vs/tmxlite
/tmxlite/tmxlite.vcxproj.user
13 changes: 9 additions & 4 deletions tmxlite/include/tmxlite/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ namespace tmx
const std::string& getName() const { return m_name; }

/*!
\brief Returns the type of the Object, as defined in the editor
\brief Returns the type (equal to class) of the Object, as defined in the editor Tiled < 1.9
*/
const std::string& getType() const { return m_type; }

const std::string& getType() const { return m_class; }

/*!
\brief Returns the class (equal to type) of the Object, as defined in the editor Tiled 1.9
*/
const std::string& getClass() const { return m_class; }

/*!
\brief Returns the position of the Object in pixels
*/
Expand Down Expand Up @@ -193,7 +198,7 @@ namespace tmx
private:
std::uint32_t m_UID;
std::string m_name;
std::string m_type;
std::string m_class;
Vector2f m_position;
FloatRect m_AABB;
float m_rotation;
Expand Down
2 changes: 1 addition & 1 deletion tmxlite/include/tmxlite/Tileset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace tmx
\brief The position of the tile within the image.
*/
Vector2u imagePosition;
std::string type;
std::string Class;
};

/*!
Expand Down
12 changes: 9 additions & 3 deletions tmxlite/src/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ void Object::parse(const pugi::xml_node& node, Map* map)

m_UID = node.attribute("id").as_int();
m_name = node.attribute("name").as_string();
m_type = node.attribute("type").as_string();

m_class = node.attribute("type").as_string();
if (m_class.empty())
{
m_class = node.attribute("class").as_string();
}

m_position.x = node.attribute("x").as_float();
m_AABB.left = m_position.x;
m_position.y = node.attribute("y").as_float();
Expand Down Expand Up @@ -274,9 +280,9 @@ void Object::parseTemplate(const std::string& path, Map* map)
m_name = obj.m_name;
}

if (m_type.empty())
if (m_class.empty())
{
m_type = obj.m_type;
m_class = obj.m_class;
}

if (m_rotation == 0)
Expand Down
7 changes: 6 additions & 1 deletion tmxlite/src/Tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,12 @@ void Tileset::parseTileNode(const pugi::xml_node& node, Map* map)
}

tile.probability = node.attribute("probability").as_int(100);
tile.type = node.attribute("type").as_string();

tile.Class = node.attribute("type").as_string();
if (tile.Class.empty())
{
tile.Class = node.attribute("class").as_string();
}

//by default we set the tile's values as in an Image tileset
tile.imagePath = m_imagePath;
Expand Down

0 comments on commit 7872ea6

Please sign in to comment.