summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index a35ff7e..c5accb1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -118,7 +118,7 @@ process_object(cJSON *json)
JSON_GET(json, height);
JSON_GET(json, rotation);
JSON_GET(json, visible);
- printf("{\"%s\",\"%s\",%d,%d,%d,%d,%d,%d,%f,%d,",
+ printf("{\"%s\",\"%s\",%d,%d,%d,%d,%d,%d,%f,%d",
name->valuestring,
type->valuestring,
id->valueint,
@@ -130,9 +130,9 @@ process_object(cJSON *json)
cJSON *properties = cJSON_GetObjectItem(json, "properties");
if (!cJSON_IsArray(properties) || cJSON_GetArraySize(properties) == 0)
- printf("0,0");
+ printf(",0,0");
else {
- printf("%d,(const Tiled2cProperty[]){",
+ printf(",%d,(const Tiled2cProperty[]){",
cJSON_GetArraySize(properties));
cJSON *property;
cJSON_ArrayForEach(property, properties) {
@@ -270,6 +270,20 @@ process_tile(cJSON *json)
printf("}");
}
+ cJSON *objectgroup = cJSON_GetObjectItem(json, "objectgroup");
+ if (!cJSON_IsObject(objectgroup))
+ printf(",0,0");
+ else {
+ JSON_GET_ARRAY(objectgroup, objects);
+ printf(",%d,(const Tiled2cObject[]){", cJSON_GetArraySize(objects));
+ cJSON *object;
+ cJSON_ArrayForEach(object, objects) {
+ if (process_object(object) < 0)
+ return -1;
+ }
+ printf("}");
+ }
+
printf("},");
return 0;
}