-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
CLI has no access to project information like custom types. #3797
Comments
This is a known issue. When you use the CLI, there's no project loaded, so it can't know what properties go with your classes. The solution to this would be to provide something like a A workaround for now is to use a custom export format that makes a copy of the map, resolves the values (e.g. by parsing the project file, or having the values hard-coded), and then writes out the file in the actually desired format (you can access an existing format you want via |
Thanks. That explanation makes perfect sense. I should have thought of that. Thanks for the workaround. I'll have a look at the existing exporter and command line interface and see if I can figure something out. Hopefully someone will be able to share a fix before I get started! |
Regarding the workaround, I fear I didn't make it very clear: this would have to be a custom format script, using the scripting API. This is not something you can do via the CLI parameters, and the existing TMX code will probably not have anything you need because it's doing different work, and is a different language (C++, whereas scripting is JavaScript). This script for copying/pasting layers may be of use in writing code to clone the map (necessary because the TileMap passed into write() is read-only), but I am not aware of any public script for resolving the class properties, though I know people have tackled that issue via scripting. |
Hm. Thanks. I'm really a C++ programmer and I don't want to get too distracted if this turns out to be a big task. I'll have a look though. The simplest workaround is to manually export all the maps from the GUI. Not ideal, but I might be able to live with it. Is it possible to write simple script to control the GUI? Perhaps I could add a command that Exports on Save, or a script to export all tmx files in the project (or from a list in a file). Is this possible? |
Yes, that's doable via scripting, but there's also a built-in "Repeat last export on save" option in the Preferences that may do what you need. |
Haha. Perfect! I'll just use that preference for now. It sounds like the lack off access to the project on the command line is the issue that really needs fixing; is there a pre-existing issue I can follow, or is this it? |
I think this issue might be it. It's been discussed multiples times elsewhere, but I don't think anyone's opened an actual issue before. At least, I couldn't find one. For clarity, it might be good to edit the title and first post of this one to reflect the specific problem, i.e. that CLI has no access to project information like custom types. |
Done. Thank you very much for your support. |
This allows the --export-map and --export-tileset parameters to use file formats defined by extensions in the project, and also enables handling of custom types. Closes mapeditor#3797
I've added the Given that I planned for the next release to be a 1.10.2 patch release, I'll wait with merging this until after the release, to be included in Tiled 1.11. |
Hi Thorbjørn. Many thanks for this. I'll test on Windows as soon as I can. |
Is the Tiled installer (Windows (64-bit, Qt 6) I guess) from this build available, or will I need to build locally? |
You can download the auto-builds here: https://github.com/mapeditor/tiled/actions/runs/5753294396?pr=3802 (scroll down) |
@bjorn I've tested this on Windows and it seems to be working just fine thanks. I don't have any custom file formats, but it seems to be working fine for the custom enums and classes I use. For my set of levels, the output from the CLI is now identical to that from the GUI (except for Please let me know if I need to do anything on this issue or the pull request. |
@howprice Thanks for testing! I've finally merged it for the next release now. :-) |
Thanks for implementing this. I'll keep an eye out for the next release. What is the best way to receive notifications or new releases? |
@howprice Tiled itself would notify you about a new release in its taskbar, unless disabled. To get a notification in your email, you can subscribe to the "Releases" on GitHub here: At least, if you have GitHub configured to send you emails on notifications. If you log in to itch.io, you can also follow me there to get notified about releases: https://thorbjorn.itch.io/tiled (top right corner). |
Describe the bug
Due to lack of project information "Resolve object types and properties" export behaviour differs between GUI and command line. When a map is exported from the commmand line with the
--resolve-types-and-properties
option, default class property values - from the .tiled-project file - are not available, so are not written into the .tmx file. The properties are present when exported from the GUI with the equivalent option.This limits the usefulness of the CLI for asset build scripts.
To Reproduce
Please see attached zip for simple repro
property-export-bug.zip
Steps to reproduce the behavior:
Create a project with a custom class and object using default properties:
Export from the Tiled GUI:
Export from the Windows command line:
Compare/diff map_export_gui.tmx vs map_export_cmd.tmx
Expected behavior
I would expect map_export_gui.tmx to be identical to map_export_cmd.tmx
In the above (and attached) repro case, the GUI-exported file contains the default resolved properties:
Whereas the command line exported file contains the object, but with no properties:
<object id="1" name="Enemy1" type="Enemy" x="160" y="64"/>
Media
Please see attached zip for repro
property-export-bug.zip
Specifications:
The text was updated successfully, but these errors were encountered: