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

Signal: assetAboutToBeExported #3984

Open
ninovanhooff opened this issue Jun 22, 2024 · 1 comment
Open

Signal: assetAboutToBeExported #3984

ninovanhooff opened this issue Jun 22, 2024 · 1 comment
Labels
feature It's a feature, not a bug.

Comments

@ninovanhooff
Copy link

ninovanhooff commented Jun 22, 2024

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.
@ninovanhooff ninovanhooff added the feature It's a feature, not a bug. label Jun 22, 2024
@eishiya
Copy link
Contributor

eishiya commented Jun 22, 2024

I think making the map in write() not be read-only would be a good idea in general. There's no need for it to be read-only, since it's a copy anyway, modifying it would not modify the original map and should be harmless.

However, a signal that fires on export and which has the to-be-exported copy (also not read-only) as payload would still be useful, allowing last-second tweaks of maps that are saved using the built-in formats, without employing the hacky solution of using a proxy format. Having the original map would also work, though of course scripts would need to be mindful of which asset they have and what they're doing with it. If the original map is sent with this signal, then there should also be a signal for after the export, so that the changes can be undone if need be. If the export copy is sent, then there should be no need for an after-export signal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

No branches or pull requests

2 participants