[cute_tiled_h] Support for tiled > 1.8 custom classes
One of the most useful new features of Tiled is the ability to define custom classes for properties. I'm trying to add support for it in the header but would like any guidance that could help.
From the Tiled Changelog
Added support for user-defined custom property types. A reference to the type is saved as the new propertytype property of [Property](https://doc.mapeditor.org/en/latest/reference/json-map-format/#json-property).
The [Property](https://doc.mapeditor.org/en/latest/reference/json-map-format/#json-property) element can now have an arbitrary JSON object as its value, in case the property value is a class. In this case the type property is set to the new value class.
Right now the cute tiled properties are an union of simple values
struct cute_tiled_property_t {
union {
int integer;
int boolean;
float floating;
cute_tiled_string_t string;
cute_tiled_string_t file;
uint32_t color;
} data;
CUTE_TILED_PROPERTY_TYPE type;
cute_tiled_string_t name;
};
I'm thinking that following cute_tiled.h design would be to add a new element to the union that would be a linked list of properties called object, like so:
struct cute_tiled_property_t {
union {
int integer;
int boolean;
float floating;
cute_tiled_string_t string;
cute_tiled_string_t file;
uint32_t color;
struct cute_tiled_property_t *object;
} data;
CUTE_TILED_PROPERTY_TYPE type;
cute_tiled_string_t name;
};
And then when parsing detecting if the property is a custom user defined object and store the properties in the object.
Does this make sense?
Yep this makes sense and can totally work. You should try allocating objects with the paged allocator so that you don't need to bother manually free'ing them later. Please do draft up a PR and post it! I'll help make sure you can get it merged in then.