diff options
author | kdx <kikoodx@paranoici.org> | 2023-12-09 22:02:48 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-12-09 22:02:48 +0100 |
commit | ebde0a200e1db431170452fcadd247771d1f2664 (patch) | |
tree | 73a104fbe1e4df775df8b48dfbabbdb66772f566 | |
parent | 6e52997d0db19c557677adb8f5694e29437d027f (diff) | |
download | tiled2c-ebde0a200e1db431170452fcadd247771d1f2664.tar.gz |
layer class
-rw-r--r-- | src/main.c | 12 | ||||
-rw-r--r-- | tiled2c.h | 1 |
2 files changed, 12 insertions, 1 deletions
@@ -15,6 +15,12 @@ return -1; \ } +#define JSON_GET_OPT_STRING(j, s) cJSON *const s = cJSON_GetObjectItem(j, #s); \ + if (s != NULL && !cJSON_IsString(s)) { \ + fprintf(stderr, #s " is no string\n"); \ + return -1; \ + } + #define JSON_GET_ARRAY(j, s) JSON_GET(j, s); \ if (!cJSON_IsArray(s)) { \ fprintf(stderr, #s " is no array\n"); \ @@ -28,13 +34,17 @@ process_layer(cJSON *json) { JSON_GET_STRING(json, type); JSON_GET_STRING(json, name); + JSON_GET_OPT_STRING(json, class); JSON_GET(json, opacity); JSON_GET(json, visible); cJSON *const parallaxx = cJSON_GetObjectItem(json, "parallaxx"); cJSON *const parallaxy = cJSON_GetObjectItem(json, "parallaxy"); - printf("{\"%s\",'%c',%f,%d,%f,%f,", + printf("{\"%s\",%c%s%c,'%c',%f,%d,%f,%f,", name->valuestring, + class ? '"' : 'N', + class ? class->valuestring : "UL", + class ? '"' : 'L', type->valuestring[0], opacity->valuedouble, cJSON_IsTrue(visible), @@ -51,6 +51,7 @@ typedef struct { typedef struct { const char *name; + const char *class; unsigned int type; double opacity; unsigned int visible; |