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: Added Tile.image for accessing a tile's image data #3882

Merged
merged 4 commits into from
Feb 2, 2024

Conversation

bjorn
Copy link
Member

@bjorn bjorn commented Jan 31, 2024

Usually one could load the image based on Tile.imageFileName, but when a tile's image has been set directly using Tile.setImage, this is not possible. This can happen for example when an importer has used this function since there was no external image file to refer to, or it used an unsupported image format.

Tile.image now provides convenient access to the tile's image, falling back to the tileset's image when the tile has no individual image.

As such, this function also provides access to the tileset's image, which would ideally be available through Tileset.image, but this property was already taken and used for the image file name. To free up this property in the future it is now deprecated. Extensions should switch to the new Tileset.imageFileName property.

Part of issue #3630

Usually one could load the image based on Tile.imageFileName, but when a
tile's image has been set directly using Tile.setImage, this is not
possible. This can happen for example when an importer has used this
function since there was no external image file to refer to, or it used
an unsupported image format.

Tile.image now provides convenient access to the tile's image, falling
back to the Tileset's image when the tile has no individual image.

As such, this function also provides access to the tileset's image,
which would ideally be available through Tileset.image, but this
property was already taken and used for the image file name. To free up
this property in the future it is now deprecated. Extensions should
switch to the new Tileset.imageFileName property.

Part of issue mapeditor#3630
As a generally more convenient alternative to imageSource, which is a
URL.
Now it also clears an existing file name, when no file name is
specified. This way the function should behave more like expected, and
more consistent with ImageLayer.setImage (which takes a URL however...)
and Tileset.loadFromImage.

Also fixed updating of the map view, when using Tileset.loadFromImage
and Tile.setImage.

Issue mapeditor#3630
@bjorn bjorn merged commit f5452a3 into mapeditor:master Feb 2, 2024
12 of 13 checks passed
@bjorn bjorn deleted the scripting-tile-image branch February 2, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant