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

Scripting: Make it easier to modify an Asset in scripted exporters #3986

Open
eishiya opened this issue Jun 24, 2024 · 0 comments
Open

Scripting: Make it easier to modify an Asset in scripted exporters #3986

eishiya opened this issue Jun 24, 2024 · 0 comments
Labels
feature It's a feature, not a bug.

Comments

@eishiya
Copy link
Contributor

eishiya commented Jun 24, 2024

The Asset you get as an argument to MapFormat.write() and TilesetFormap.write() is read-only, which makes it difficult to make temporary last-second changes to the map/tileset. Theoretically one could try to use the assetAboutToBeSaved signals to trigger such changes instead, and undo them after the asset is saved, but no such signals fire on export (see #3984), and a script may need to do substantial changes that might not be easily Undoable, all this makes for unwieldy, overcomplicated scripts.

There are two possible solutions I see:

  1. Make the argument Asset editable. When any export options are applied, it's already a copy, so it could safely be made editable. However, this means a copy would need to be made even when otherwise the original would be passed in, even if the export format doesn't need to make changes to it. Most likely only a minority of custom formats need to make changes to their Asset, so this seems wasteful.
  2. Add Asset.clone(), which creates a deep clone of the Asset. This isn't as intuitive, but it would have wider applications than just export formats, and avoids making unnecessary copies of the saved Asset. If this approach is taken, the write() methods' documentation should mention it as a way to get a modifiable copy of the Asset if one is needed.
@eishiya eishiya added the feature It's a feature, not a bug. label Jun 24, 2024
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

1 participant