-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: Set fileName when using TilesetFormat.read() or MapFormat.read() #3517
Comments
BackstoryNone of the formats set the file name of the type they return, which traditionally did not even have a file name field. Like an image also does not store the file name from which it was loaded. The file name only comes into play for assets open in the editor, since they have a Eventually, it became a little more complicated, and there was reason to move the file name (and format) into the Another thing that made things complicated is the introduction of the Way forward
I think that's the best solution, yes. Naming the function is difficult, but I am considering The tricky part may be, to unload this asset when the last
Yes, I think the addition of a |
Thanks for the info! I thought it might be something complex like that, but it's cool to have the details. |
Currently, if you |
@eishiya I think you'd just never close an asset loaded with |
This |
A common task in scripted MapFormats is to read an external tileset from file and assign it to the newly created TileMap. There are two ways to open a Tileset from a file:
tiled.open()
, which opens the Tileset as a document in Tiled. This is not usually desirable, and takes extra code to close the tab afterwards, and extra work to only close the document if the user didn't already have it open.TilesetFormat.read()
, which doesn't open a tab... but also doesn't set the Tileset'sfileName
, so when that Tileset is added to a map, it becomes embedded.It's easy to miss the unintentional proliferation of tileset clones this causes. Here's an example from the forum of this unintentional embedding. Unless there's some specific reason not to, I think
TilesetFormat.read()
andTilemapFormat.read()
should set the Asset'sfileName
, which should hopefully fix this embedding issue. Why is this not set in the first place?Of course, sometimes it's desirable to create an embedded tileset on purpose. For this and other purposes, I think
Tileset.clone()
andTileMap.clone()
would be good additions - the clones should have an emptyfileName
.If there is a reason that TilesetFormat/TileMapFormat.read don't set the fileName, then the API should provide methods to open files, maintain their link to their file, but without opening a document tab for them, e.g.
tiled.openSilently()
, ortiled.open(path, silent?)
.The text was updated successfully, but these errors were encountered: