Do you want to work on this issue?
You can request for a bounty in order to promote it!
Avoid renumbering tiles when image width changes #2863
bjorn posted onGitHub
One problem that's common enough to cause quite some pain is that when a tileset's image width is changed, this causes all the tiles in the tileset to get renumbered. This in turn messes up any tile references from tile layers and tile objects (also affecting object templates) and requires a lot of custom code to fix (a workflow that has always been somewhat broken, see for example issues #1770 and #1851). Even tile references within a tileset definition, like for terrain images, animation frames or Wang sets need adjustment.
I'm considering a solution where adjustment to other assets is entirely avoided, by keeping the tile IDs stable (still pointing to the same location in the image). To achieve this, we can store for each tile its x and y coordinate on the tileset image. Then, when the image has grown in size next time the tileset is loaded, any new tiles will get added to the end of the list, receiving new IDs just like when adding images to an Image Collection tileset.
It would be interesting to store also the width and height of each tile, such that we can at the same time support tilesets that contain tiles of varying sizes (issue #1008), if we add some UI to manage the tiles in a tileset.
One question is what to do when the user changes the parameters of the tileset, like when halving or doubling the tile size. On the one hand, we can't expect this will keep any map using that tileset to still look alright, so it might be OK to just renumber all tiles in this case. On the other hand, this may commonly happen after changing the resolution of the tiles:
- User changes tileset image to a version 2x bigger
- Tiled detects more tiles on the image (actually 4x the amount of tiles), new tile IDs are added
- User changes tileset tile size
Probably, at the last step, Tiled should make an effort to match up tiles based on the old and new size parameters, making sure their IDs stay the same.