Request to Add Support for Enumeration Properties #1211

Open
lazybotter opened this Issue Feb 25, 2016 · 8 comments

Comments

Projects
None yet
3 participants
@lazybotter

One really good option to add to the "Add Property" dialogue would be the ability to add multiple string values that would display as a "Select" or "Dropdown Menu".

So for an example:

I could create an object that has a Type of "Box".
The "Box" could then have a "BoxType" property. "Solid Box, Mystery Box, Danger Box".
Then when creating the object on the map we can just select what "BoxType" we would like the "Box" to be.
This would be great for custom game engines etc when creating the maps.

Thanks! Carl ;-)

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Feb 28, 2016

Owner

Definitely. The main challenge here is that such enumeration properties would need to be based on enumeration types, which would have to be defined before you can define a property of that type. So this means a new section in objecttypes.xml for complex type definitions (I could also imagine supporting types that have sub-properties here later) and then coding some way in which these types get used by the property browser.

Starting with just enumeration properties would be a good idea, I just want to be prepared a little for sub-properties later.

Owner

bjorn commented Feb 28, 2016

Definitely. The main challenge here is that such enumeration properties would need to be based on enumeration types, which would have to be defined before you can define a property of that type. So this means a new section in objecttypes.xml for complex type definitions (I could also imagine supporting types that have sub-properties here later) and then coding some way in which these types get used by the property browser.

Starting with just enumeration properties would be a good idea, I just want to be prepared a little for sub-properties later.

@bjorn bjorn added the feature label Feb 28, 2016

@lazybotter

This comment has been minimized.

Show comment
Hide comment
@lazybotter

lazybotter Apr 11, 2016

Any movement on this? :-)

Any movement on this? :-)

@lazybotter

This comment has been minimized.

Show comment
Hide comment
@lazybotter

lazybotter Aug 8, 2016

Anyone started on this yet?

Anyone started on this yet?

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Aug 8, 2016

Owner

I haven't gotten around to this yet. If it is any comfort, for Tiled 0.17 I did get around to several other property enhancements, like adding "file" and "color" types and supporting multi-line values for "string" properties.

This feature is definitely still on the list of things to improve about the custom properties system.

Owner

bjorn commented Aug 8, 2016

I haven't gotten around to this yet. If it is any comfort, for Tiled 0.17 I did get around to several other property enhancements, like adding "file" and "color" types and supporting multi-line values for "string" properties.

This feature is definitely still on the list of things to improve about the custom properties system.

@jeremyherbert

This comment has been minimized.

Show comment
Hide comment
@jeremyherbert

jeremyherbert Mar 19, 2017

Has any work been done on the UI of this? ie how would one define the enum types? Would you have a separate editor window, much like the object types editor, but one that is used just for defining enums? Or something in the same window? Are enums defined as a simple integer->string mapping like in C, or something else?

I'd be interested in giving this a go, but I am not sure which is the best way to proceed. I'd of course like to try and have the code merged eventually.

Has any work been done on the UI of this? ie how would one define the enum types? Would you have a separate editor window, much like the object types editor, but one that is used just for defining enums? Or something in the same window? Are enums defined as a simple integer->string mapping like in C, or something else?

I'd be interested in giving this a go, but I am not sure which is the best way to proceed. I'd of course like to try and have the code merged eventually.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Mar 20, 2017

Owner

@jeremyherbert No work has been done on this. Indeed it would be good to mock up the UI before starting to code this. Thanks for your interest to work on this and to try getting it merged!

Are enums defined as a simple integer->string mapping like in C, or something else?

I imagine the enum will be defined only as the list of options (strings), and these strings will be used when saving/loading. A downside of that is that you can't easily rename one of the enum options, but it does mean you can add/remove them without causing many issues (and without requiring the user to be careful with value assignment in this case).

Would you have a separate editor window, much like the object types editor, but one that is used just for defining enums? Or something in the same window?

I'm hope we don't need too many separate windows and am thinking of something like this to start with:

object-types-dialog

When you'd click the button to add a new property type, then a new window would pop up where you could define what the new property type would be (eventually, it could be more than just enum, and it could even base on existing types like 'int' and just add a min/max value - not sure yet at which level that makes most sense). In case of an enum, you'd have a list of strings there with +/- buttons and Ok/Cancel buttons.

As a bonus it would be cool if you could drag-n-drop from Property Types into Properties to add a new property of that type. :-)

Owner

bjorn commented Mar 20, 2017

@jeremyherbert No work has been done on this. Indeed it would be good to mock up the UI before starting to code this. Thanks for your interest to work on this and to try getting it merged!

Are enums defined as a simple integer->string mapping like in C, or something else?

I imagine the enum will be defined only as the list of options (strings), and these strings will be used when saving/loading. A downside of that is that you can't easily rename one of the enum options, but it does mean you can add/remove them without causing many issues (and without requiring the user to be careful with value assignment in this case).

Would you have a separate editor window, much like the object types editor, but one that is used just for defining enums? Or something in the same window?

I'm hope we don't need too many separate windows and am thinking of something like this to start with:

object-types-dialog

When you'd click the button to add a new property type, then a new window would pop up where you could define what the new property type would be (eventually, it could be more than just enum, and it could even base on existing types like 'int' and just add a min/max value - not sure yet at which level that makes most sense). In case of an enum, you'd have a list of strings there with +/- buttons and Ok/Cancel buttons.

As a bonus it would be cool if you could drag-n-drop from Property Types into Properties to add a new property of that type. :-)

@jeremyherbert

This comment has been minimized.

Show comment
Hide comment
@jeremyherbert

jeremyherbert Mar 21, 2017

Do you think it would be ok to put it in the object properties window when these types can also apply to tiles? The feature I'm personally looking for is the ability to attach enums to tiles, rather than objects.

Do you think it would be ok to put it in the object properties window when these types can also apply to tiles? The feature I'm personally looking for is the ability to attach enums to tiles, rather than objects.

@bjorn

This comment has been minimized.

Show comment
Hide comment
@bjorn

bjorn Mar 21, 2017

Owner

Do you think it would be ok to put it in the object properties window when these types can also apply to tiles? The feature I'm personally looking for is the ability to attach enums to tiles, rather than objects.

Yes, that's alright. Actually, there is another issue open for defining custom properties for other data types (#1410) which means this dialog will probably be further extended to support that as well.

Owner

bjorn commented Mar 21, 2017

Do you think it would be ok to put it in the object properties window when these types can also apply to tiles? The feature I'm personally looking for is the ability to attach enums to tiles, rather than objects.

Yes, that's alright. Actually, there is another issue open for defining custom properties for other data types (#1410) which means this dialog will probably be further extended to support that as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment