Skip to content

Commit 1eb6988

Browse files
committed
Change type to class
1 parent 6c0f878 commit 1eb6988

5 files changed

Lines changed: 27 additions & 9 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ Debug
88
Release
99

1010
*.swp
11+
/.vs/tmxlite
12+
/tmxlite/tmxlite.vcxproj.user

tmxlite/include/tmxlite/Object.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,15 @@ namespace tmx
112112
const std::string& getName() const { return m_name; }
113113

114114
/*!
115-
\brief Returns the type of the Object, as defined in the editor
115+
\brief Returns the type (equal to class) of the Object, as defined in the editor Tiled < 1.9
116116
*/
117-
const std::string& getType() const { return m_type; }
118-
117+
const std::string& getType() const { return m_class; }
118+
119+
/*!
120+
\brief Returns the class (equal to type) of the Object, as defined in the editor Tiled 1.9
121+
*/
122+
const std::string& getClass() const { return m_class; }
123+
119124
/*!
120125
\brief Returns the position of the Object in pixels
121126
*/
@@ -193,7 +198,7 @@ namespace tmx
193198
private:
194199
std::uint32_t m_UID;
195200
std::string m_name;
196-
std::string m_type;
201+
std::string m_class;
197202
Vector2f m_position;
198203
FloatRect m_AABB;
199204
float m_rotation;

tmxlite/include/tmxlite/Tileset.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ namespace tmx
9999
\brief The position of the tile within the image.
100100
*/
101101
Vector2u imagePosition;
102-
std::string type;
102+
std::string Class;
103103
};
104104

105105
/*!

tmxlite/src/Object.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ void Object::parse(const pugi::xml_node& node, Map* map)
5959

6060
m_UID = node.attribute("id").as_int();
6161
m_name = node.attribute("name").as_string();
62-
m_type = node.attribute("type").as_string();
62+
63+
m_class = node.attribute("type").as_string();
64+
if (m_class.empty())
65+
{
66+
m_class = node.attribute("class").as_string();
67+
}
68+
6369
m_position.x = node.attribute("x").as_float();
6470
m_AABB.left = m_position.x;
6571
m_position.y = node.attribute("y").as_float();
@@ -274,9 +280,9 @@ void Object::parseTemplate(const std::string& path, Map* map)
274280
m_name = obj.m_name;
275281
}
276282

277-
if (m_type.empty())
283+
if (m_class.empty())
278284
{
279-
m_type = obj.m_type;
285+
m_class = obj.m_class;
280286
}
281287

282288
if (m_rotation == 0)

tmxlite/src/Tileset.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,12 @@ void Tileset::parseTileNode(const pugi::xml_node& node, Map* map)
353353
}
354354

355355
tile.probability = node.attribute("probability").as_int(100);
356-
tile.type = node.attribute("type").as_string();
356+
357+
tile.Class = node.attribute("type").as_string();
358+
if (tile.Class.empty())
359+
{
360+
tile.Class = node.attribute("class").as_string();
361+
}
357362

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

0 commit comments

Comments
 (0)