53 doc = xmlReadFile( _filename, NULL, 0 );
61 xmlNode *root_element = NULL;
62 xmlNode *cur_node = NULL;
64 root_element = xmlDocGetRootElement(doc);
66 for (cur_node = root_element; cur_node; cur_node = cur_node->next) {
67 if (cur_node->type == XML_ELEMENT_NODE) {
68 if ( strcmp( cur_node->name,
"tileset" ) == 0 ) {
70 struct _xmlAttr * properties = cur_node->properties;
72 if ( properties->type == XML_ATTRIBUTE_NODE ) {
73 xmlChar* value = xmlNodeListGetString(cur_node->doc, properties->children, 1);
74 if ( strcmp( properties->name,
"version") == 0 ) {
75 result->
version = strdup( value );
76 }
else if ( strcmp( properties->name,
"tiledVersion") == 0 ) {
78 }
else if ( strcmp( properties->name,
"name") == 0 ) {
79 result->
name = strdup( value );
80 }
else if ( strcmp( properties->name,
"tilewidth") == 0 ) {
82 }
else if ( strcmp( properties->name,
"tileheight") == 0 ) {
84 }
else if ( strcmp( properties->name,
"tilecount") == 0 ) {
86 }
else if ( strcmp( properties->name,
"columns") == 0 ) {
87 result->
columns = atoi( value );
88 }
else if ( strcmp( properties->name,
"spacing") == 0 ) {
89 result->
spacing = atoi( value );
90 }
else if ( strcmp( properties->name,
"margin") == 0 ) {
91 result->
margin = atoi( value );
92 }
else if ( strcmp( properties->name,
"objectalignment") == 0 ) {
105 }
else if ( strcmp( properties->name,
"tilerendersize") == 0 ) {
109 }
else if ( strcmp( properties->name,
"backgroundcolor") == 0 ) {
113 }
else if ( strcmp( properties->name,
"fillmode") == 0 ) {
120 properties = properties->next;
123 xmlNode * child = cur_node->children;
125 if ( strcmp( child->name,
"image" ) == 0 ) {
128 memset( image, 0,
sizeof (
TsxImage ) );
130 struct _xmlAttr * properties = child->properties;
131 while( properties ) {
132 if ( properties->type == XML_ATTRIBUTE_NODE ) {
133 xmlChar* value = xmlNodeListGetString(child->doc, properties->children, 1);
134 if ( strcmp( properties->name,
"source") == 0 ) {
135 image->
source = strdup( value );
136 }
if ( strcmp( properties->name,
"width") == 0 ) {
137 image->
width = atoi( value );
138 }
if ( strcmp( properties->name,
"height") == 0 ) {
139 image->
height = atoi( value );
143 properties = properties->next;
146 result->
image = image;
148 }
else if ( strcmp( child->name,
"tileoffset" ) == 0 ) {
157 }
else if ( strcmp( child->name,
"grid" ) == 0 ) {
168 }
else if ( strcmp( child->name,
"transformations" ) == 0 ) {
196 }
else if ( strcmp( child->name,
"tile" ) == 0 ) {
199 memset( tile, 0,
sizeof (
TsxTile ) );
203 struct _xmlAttr * properties = child->properties;
204 while( properties ) {
205 if ( properties->type == XML_ATTRIBUTE_NODE ) {
206 xmlChar* value = xmlNodeListGetString(child->doc, properties->children, 1);
207 if ( strcmp( properties->name,
"id") == 0 ) {
208 tile->
id = atoi( value );
209 }
if ( strcmp( properties->name,
"type") == 0 ) {
210 tile->
type = strdup( value );
211 }
if ( strcmp( properties->name,
"probability") == 0 ) {
216 properties = properties->next;
219 if ( result->
tiles ) {
221 result->
tiles = tile;
223 result->
tiles = tile;