mapeditor/tiled

Do you want to work on this issue?
You can request for a bounty in order to promote it!
Signal: assetAboutToBeExported #3984
ninovanhooff posted onGitHub
Is your feature request related to a problem? Please describe. I've got an extension that listens to assetAboutToBeSaved to do last-minute corrections. Examples:
- ensuring that polygon vertices are in counter-clockwise winding order
- ensuring that vertices are snapped to the nearest pixel coordinate
- apply rotation and offset
This works well, but the signal is not triggered when exporting. Thus, when changes are made since the last save and a user then hits export, an invalid file can be generated
Describe the solution you'd like
A new signal assetAboutToBeExported
that works the same way as assetAboutToBeSaved
. For consistency perhaps assetExported
as well
Describe alternatives you've considered
- An
objectEdited
signal emitted whenever anything about an object changes. But there are usecases for layers, tilesets etc. too. - Doing the corrections to the map in the
write
function of a map format. Not allowed; the map is read-only. - Completely parsing the map and writing it to a custom format, doing checks and fixes along the way. Lots of work, plus the result is not visible to the user since it is only applied to the exported file; not the map
- Doing the checks in the
write
function of a map format and returning an error message "please save before exporting" when issues are found. That seems a bit annoying when the issues could be fixed automatically.