mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.26k stars 1.76k forks source link

Signal: assetAboutToBeExported #3984

Open ninovanhooff opened 5 months ago

ninovanhooff commented 5 months ago

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:

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

eishiya commented 5 months ago

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.