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

World Tool: Adding Map often end up offsetted #2970

Closed
meniku opened this issue Dec 24, 2020 · 4 comments
Closed

World Tool: Adding Map often end up offsetted #2970

meniku opened this issue Dec 24, 2020 · 4 comments
Assignees
Labels
bug Broken behavior.

Comments

@meniku
Copy link
Contributor

meniku commented Dec 24, 2020

On a map that isn't part of a loaded world: When using the World Tool to add it to an opened world, it might end up in slightly offset positions, so it doesn't properly fit into the grid ( see screenshot below )

offset

I did not encounter that issue when using the "Add another map" action. So it's not a big deal, but maybe the other action should be disabled or fixed

@bjorn
Copy link
Member

bjorn commented Jan 13, 2021

Hmm, the various actions work differently as follows:

  • The "Add another map to the current world" tool bar action positions the map such that its origin is in the center of the map view.
  • The "Add a Map to World ..." context menu action positions the map with its origin at the clicked location.
  • The "Add to " tool bar and context menu actions position the map with its origin in the top-right of the last map added to the world.

It appears the last action is not working for you as expected. Could you provide some more details, or possibly upload some files so I could reproduce this problem? Asking because it's working fine in my tests.

@meniku
Copy link
Contributor Author

meniku commented Jan 13, 2021

sample.zip

@bjorn
Copy link
Member

bjorn commented Jan 13, 2021

Turns out this was an off-by-one on the X axis since QRect::topRight is, for historical reasons, not exactly where you'd expect:

image

I just hadn't noticed is while testing.

Another issue stems from the fact that all move operations on the map appear to be rounding the offset to whole tiles, but if the original position of a map is not aligned to the grid, this makes it essentially impossible to put it at an aligned position. I think I should change it to snap the target position instead.

Edit: Actually, when moving with the arrow keys the target position is snapped. It's only when dragging a world with the mouse, that the offset is snapped instead.

@bjorn bjorn added the bug Broken behavior. label Jan 13, 2021
@bjorn bjorn closed this as completed in 8693dce Jan 13, 2021
@bjorn
Copy link
Member

bjorn commented Jan 13, 2021

Thanks for bringing this up! The fix will be available in the next development snapshot and the Tiled 1.5 release.

To work around the issue in Tiled 1.4, move your maps with the arrow keys to ensure they are each aligned to the grid.

@bjorn bjorn self-assigned this Jan 13, 2021
bjorn added a commit that referenced this issue Jan 13, 2021
* Fixed an off-by-one error when adding the current map to a loaded world.
  The map was placed one pixel too much to the right.

* Fixed grid snapping when dragging a map to snap the target position
  rather than the offset. Also added handling of Control modifier to
  disable the grid snapping.

Closes #2970

(cherry picked from commit 8693dce)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
None yet
Development

No branches or pull requests

2 participants