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

Adjust Wang tiles and tile object templates, when adjusting tile meta-data to a tileset change #1851

Open
bjorn opened this issue Jan 6, 2018 · 2 comments
Labels
bug Broken behavior.

Comments

@bjorn
Copy link
Member

bjorn commented Jan 6, 2018

When the with of a tileset image is changed, this affects the number of tile columns, which affects the numbering of the tiles. Tiled can adjust the various tile references, both from the map and internally in the tileset, to make sure the same tiles are still referenced.

However, data related to new features like the Wang tiles and tile object templates are not currently handled by this code. See adjusttileindexes.cpp.

In addition, there is an issue with tracking when such an adjustment is needed. This is because the last seen column count is stored only with the tileset, and not with the map or the tile object template, which will need independent adjusting.

The annoying thing is that we need to prompt the user about such an adjustment, because the tileset may have been replaced with a higher resolution version, where the user still plans to also adjust the tile size information. In that case, no tile index adjustment should happen.

@bjorn bjorn added the bug Broken behavior. label Jan 6, 2018
bjorn added a commit that referenced this issue Apr 18, 2018
* A lot of Wang set index and Wang color index arguments were changed to
  WangSet or WangColor pointer arguments. This generally simplified the
  code.

* TilesetDocument now owns the WangColorModel instances, which are
  created on-demand. This resolves issues with undo commands, which
  previously relied on the single WangColorModel instance owned by the
  WangDock to refer to the right WangSet instance. Undo/redo after
  selecting a different Wang set would misbehave or crash.

This refactoring is a preparation for fixing issue #1851.
bjorn added a commit that referenced this issue Apr 18, 2018
A change in the number of tile columns on a tileset image affects the
tile indices. This means that when loading a map that was saved before
the size of the tileset image was changed, or when reloading an image
while Tiled is open, we may need to adjust both map data and the
meta-data stored with the tileset.

This already happened for most of the data, but not for any Wang tile
related data. This change implements that and partly resolves
issue #1851.

It also fixes the test on whether to do the adjustment to also run when
just the tileset file is opened, as opposed to opening a map that uses
the tileset.

There is unfortunately still a problem when opening multiple maps that
need adjustment. In this case, the adjustment is only offered for the
first map. Fixing that will require adding more information to the
tileset references in each map. Alternatively we could think about
changing the tile indices entirely to make these adjustments no longer
necessary (for example, referring to the tiles by their x/y coordinate).
@bjorn
Copy link
Member Author

bjorn commented Apr 18, 2018

Spent a whole day on fixing this issue, which is now halfway done since it is not fixed yet for template instances... and that while probably less than 0.1% of users will ever run into this, because who uses Wang tiles or templates AND changes the width of his tileset image after creation? ...

@eishiya
Copy link
Contributor

eishiya commented Oct 13, 2021

If #2866 is implemented, then you could be sure that the ID adjustments are desired, at least.

Also, now that Wang tiles are just Terrains, I think more people will be affected by this. While users using stock tilesets aren't likely to be resizing their tilesets, those who draw their own tilesets are very likely to need to resize their tileset at times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
Status: No status
Development

No branches or pull requests

2 participants