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 · 1 comment

Comments

1 participant
@bjorn
Copy link
Owner

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 label Jan 6, 2018

@bjorn bjorn added this to Tiled 1.1 (bugfixes) in Roadmap Jan 16, 2018

bjorn added a commit that referenced this issue Apr 18, 2018

Large cleanup of WangSet and WangColor related code
* 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

Adjust Wang tile data when tileset column count changes
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

This comment has been minimized.

Copy link
Owner

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? ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment