Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map properties defined in a custom class are not saved #3470

Closed
ChristianPervoelz opened this issue Sep 12, 2022 · 5 comments
Closed

Map properties defined in a custom class are not saved #3470

ChristianPervoelz opened this issue Sep 12, 2022 · 5 comments
Labels
bug Broken behavior.

Comments

@ChristianPervoelz
Copy link
Contributor

Describe the bug
When having a custom type class (containing properties) set to be the class type of a new map, the defined properties and their values are not stored while saving (except when modified manually)

To Reproduce
Steps to reproduce the behavior:

  1. Open a project
  2. Create a new Class using Custom Types editor
    a. Set 'Class of' to 'Map' only
    b. add a property to the class (e.g. of type float)
  3. Create a new map
  4. Assign the newly created class using the drop down box of Class field in the map editor window

As a result the property defined in the new class will be shown with its default value in the 'Custom Properties' section of the map properties.

  1. Save the new map
  2. Open the saved file with e.g. a text editor

Result:
The tmx file does not contain a properties section for the map

This might be OK, when opening the map later on with Tiled only, but when loading it with an external tool, that has no access to the project settings (where custom types are stored) all the information stored in the custom properties will miss.

Workaround
Change the values of each custom property manually and then change it back to its default value.

Expected behavior
Custom properties are stored into the saved map no matter they are changed or not, as well as into a may exported map.

Specifications:

  • OS: [e.g. Windows 11]
  • Tiled Version: 1.9.1
@ChristianPervoelz ChristianPervoelz added the bug Broken behavior. label Sep 12, 2022
@ChristianPervoelz
Copy link
Contributor Author

Adding a custom property directly to the map (not using the class) that property will be stored.

@eishiya
Copy link
Contributor

eishiya commented Sep 12, 2022

This is expected behaviour: only properties with overridden values are saved. This both saves space by avoiding storing defaults, and allows Tiled to distinguish between overridden and non-overridden values.

If you want to include the default values in the map, you can enable the "resolve object types and properties" export setting, and export the map.

@ChristianPervoelz
Copy link
Contributor Author

Understood. I would do it the same way for pure saving purposes.

But... Unfortunately using the option "Resolve object types and properties" during export does NOT work as expected either.
I tried it with various custom classes (having different types of properties and scopes set) with these results:

  • map level -> no export
  • object layer -> no export
  • image layer -> no export
  • group layer -> no export
  • object -> exported properly

@eishiya
Copy link
Contributor

eishiya commented Sep 13, 2022

Oh dear. Until 1.8, only Objects and Tiles had custom properties and that export option resolved them, and that feature hasn't been updated to reflect the new changes (nested properties and classes on things other than Objects and Tiles). Nested properties not resolving is issue #3411.

Please consider editing this issue to reflect the fact that this export option doesn't work for things other than Objects and Tiles, as that's an actual issue that needs fixing, and which would resolve your original issue. The resolve properties export option is what you're expected to use if you need defaults included with your maps.

@bjorn bjorn closed this as completed in bb44aed Sep 16, 2022
@bjorn
Copy link
Member

bjorn commented Sep 16, 2022

Thanks for the bug report @ChristianPervoelz! The fix will be in Tiled 1.9.2, and of course the next build. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
None yet
Development

No branches or pull requests

3 participants