Skip to content

Commit 252af6e

Browse files
committed
add support for POINT type objects
add placeholder parsing of object template files
1 parent d674539 commit 252af6e

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

tmxlite/include/tmxlite/Object.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace tmx
8686
{
8787
Rectangle,
8888
Ellipse,
89+
Point,
8990
Polygon,
9091
Polyline,
9192
Text
@@ -103,50 +104,60 @@ namespace tmx
103104
\brief Returns the unique ID of the Object
104105
*/
105106
std::uint32_t getUID() const { return m_UID; }
107+
106108
/*!
107109
\brief Returns the name of the Object
108110
*/
109111
const std::string& getName() const { return m_name; }
112+
110113
/*!
111114
\brief Returns the type of the Object, as defined in the editor
112115
*/
113116
const std::string& getType() const { return m_type; }
117+
114118
/*!
115119
\brief Returns the position of the Object in pixels
116120
*/
117121
const Vector2f& getPosition() const { return m_position; }
122+
118123
/*!
119124
\brief Returns the global Axis Aligned Bounding Box.
120125
The AABB is positioned via the left and top properties, and
121126
define the Object's width and height. This can be used to derive
122127
the shape of the Object if it is rectangular or elliptical.
123128
*/
124129
const FloatRect& getAABB() const { return m_AABB; }
130+
125131
/*!
126132
\brief Returns the rotation of the Object in degrees clockwise
127133
*/
128134
float getRotation() const { return m_rotation; }
135+
129136
/*!
130137
\brief Returns the global tile ID associated with the Object
131138
if there is one. This is used to draw the Object (and therefore
132139
the Object must be rectangular)
133140
*/
134141
uint32_t getTileID() const { return m_tileID; }
142+
135143
/*!
136144
\brief Returns whether or not the Object is visible
137145
*/
138146
bool visible() const { return m_visible; }
147+
139148
/*!
140149
\brief Returns the Shape type of the Object
141150
*/
142151
Shape getShape() const { return m_shape; }
152+
143153
/*!
144154
\brief Returns a reference to the vector of points which
145155
make up the Object. If the Object is rectangular or elliptical
146156
then the vector will be empty. Point coordinates are in pixels,
147157
relative to the object position.
148158
*/
149159
const std::vector<Vector2f>& getPoints() const { return m_points; }
160+
150161
/*!
151162
\brief Returns a reference to the vector of properties belonging to
152163
the Object.
@@ -181,6 +192,7 @@ namespace tmx
181192

182193
void parsePoints(const pugi::xml_node&);
183194
void parseText(const pugi::xml_node&);
195+
void parseTemplate(const std::string&);
184196
};
185197
}
186198

tmxlite/src/Object.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ void Object::parse(const pugi::xml_node& node)
6767
m_tileID = node.attribute("gid").as_uint();
6868
m_visible = node.attribute("visible").as_bool(true);
6969

70+
std::string templateStr = node.attribute("template").as_string();
71+
if (!templateStr.empty())
72+
{
73+
parseTemplate(templateStr);
74+
}
75+
7076
for (const auto& child : node.children())
7177
{
7278
attribString = child.name();
@@ -82,6 +88,10 @@ void Object::parse(const pugi::xml_node& node)
8288
{
8389
m_shape = Shape::Ellipse;
8490
}
91+
else if (attribString == "point")
92+
{
93+
m_shape = Shape::Point;
94+
}
8595
else if (attribString == "polygon")
8696
{
8797
m_shape = Shape::Polygon;
@@ -181,3 +191,8 @@ void Object::parseText(const pugi::xml_node& node)
181191

182192
m_textData.content = node.text().as_string();
183193
}
194+
195+
void Object::parseTemplate(const std::string& path)
196+
{
197+
Logger::log("Requested a template at " + path + " - but this is not yet implemented *sadface*", Logger::Type::Info);
198+
}

0 commit comments

Comments
 (0)