mapeditor/tiled

Custom Enum Property Type loses dropdown menu on re-opening editor #3301

gslance posted onGitHub

Describe the bug After defining several strings to become a custom enum property type, the options drop-down menu disappears from an object's custom properties when re-opening the map. To restore the dropdown menu, you'd have to re-add the custom property to the object. I understand the value is saved as string in the file, which is working as intended, but I expect the dropdown menu to always be there if the property is defined as such.

To Reproduce Steps to reproduce the behavior:

  1. Create an Enum Property Type of at least 2 String options.
  2. Create a tile object and add the Enum Property Type from step 1 to it as a custom property. Observe the dropdown menu for its options.
  3. Save the map and close the map editor application.
  4. Re-open editor and click on the tile object from step 2 to observe its properties.
  5. Notice the dropdown menu is gone, and it is now simply a string.

Expected behavior I expect the dropdown menu to be present so altering a value, even after re-opening a map, remains convenient.

Specifications:

  • OS: Windows 11
  • Tiled Version: 1.8.2

Probably caused by not actually having a project saved, which is what stores the custum enums.

I will patch this up in 1.8.3, such that editing property types is only possible after saving a project. Either that or introduce saving for the default project.

posted by bjorn about 3 years ago

I don't know if there's anything extra I have to do but I already work from a project file where the described situation occurs.

Looking at the project source file, I do see the enumerators properly listed. However, looking at any map's TMX file, I do not see the object tile's custom properties actually referring the property by its property type, id or otherwise. The custom property just appears as its regular name/value key.

Interestingly, global map custom properties do refer to the enumerator properly by correctly using the "propertytype" value.

posted by gslance about 3 years ago

Looking at the project source file, I do see the enumerators properly listed. However, looking at any map's TMX file, I do not see the object tile's custom properties actually referring the property by its property type, id or otherwise. The custom property just appears as its regular name/value key.

Hmm, I currently have no explanation for this and I've just tested it by setting an enum property on a tile and on a tile objects, which in both cases was saved as expected (with the propertytype attribute in place):

  <object id="238" type="coin" gid="18" x="1152" y="480" width="64" height="64">
   <properties>
    <property name="state" propertytype="State" value="Closed"/>
   </properties>
  </object>

and

 <tile id="0">
  <properties>
   <property name="state" propertytype="State" value="Locked"/>
  </properties>
  <image width="160" height="192" source="alter.png"/>
 </tile>

Any additional information about how I might be able to reproduce this issue would be very welcome!

posted by bjorn about 3 years ago

With a completely new project and empty map, it works as expected though I am still unsure why my production project doesn't, I keep re-adding the enumerators to the types and it refuses to save them properly, every time. The project file and maps were created in version 1.7 and had upgraded to 1.8 during production.

The following seems not to work for some reason when we don't put the custom enumerator on a tile (with and without project file):

  1. Prepare a new Enumerator object through the Property Types Editor. It has two strings as an enum.
  2. Open the Object Types Editor and create a new custom object type.
  3. Add a property, name won't matter but associate it with the enum from step 1.
  4. Confirm the dropdown menu is visible and able to select any enumerator from that list.
  5. Close the editor, save the project if applicable and close the application.
  6. Reopening the application, go back into the Object Types Editor and view the object type from step 2.
  7. No dropdown menu visible. It is now simply a text field.

In one instance, actually, after creating an enumerator with its default name, I was unable to even see it in the list for the object type until I restarted the application. But that's unrelated to this issue.

posted by gslance about 3 years ago

In one instance, actually, after creating an enumerator with its default name, I was unable to even see it in the list for the object type until I restarted the application. But that's unrelated to this issue.

Yes, that was fixed in 69cd4a0b726a4d32a7c631f8c0415aca265ef76e, which will be in Tiled 1.8.3. I wonder if it's really unrelated. I'll try again with your last steps.

posted by bjorn about 3 years ago

Alright, to reproduce this issue, the project should not have an objecttypes.xml file (which is of course the default...). In this case, the object types are stored globally (in ~/.local/share/tiled on Linux), and since these types are then loaded before the project, the custom property types are not yet available at that point.

I think the real fix for this is to move the object types into the project as well, something I had started to work on in #3123. Or, to merge these things together in some way. For Tiled 1.8, I think a potential fix might be to reload the object types, after the project has been loaded.

posted by bjorn about 3 years ago

That should do it, I wasn't even aware of such a file or setting! Thank you for your hard work, I will await the next patch with patience. :)

posted by gslance about 3 years ago

Fund this Issue

$0.00
Funded

Pull requests