Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,15 @@ public void commitMoveSelectionSet(GUID keyTokenId) {
var lastPoint = tokenPath.getWayPointList().getLast();
var endPoint =
switch (lastPoint) {
case CellPoint cp -> token.getDragAnchorAsIfLocatedInCell(zone, cp);
case CellPoint cp -> {
// Anchor at the cell center.
var grid = zone.getGrid();
var zp = grid.convert(cp);
var centerOffset = grid.getCenterOffset();
zp.x += (int) centerOffset.x;
zp.y += (int) centerOffset.y;
yield zp;
}
case ZonePoint zp -> zp;
};
token.moveDragAnchorTo(zone, endPoint);
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/net/rptools/maptool/model/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -1633,23 +1633,6 @@ public void moveDragAnchorTo(Zone zone, ZonePoint newDragAnchorPosition) {
setY(newDragAnchorPosition.y - offsetY);
}

/**
* Like {@link #getDragAnchor(Zone)}, but assume the token is in cell {@code cellPoint}.
*
* @param zone The zone that the token lives in.
* @param cellPoint The cell in which the token should pretend to be located.
* @return The drag anchor the token would have if located at {@code cellPoint}.
*/
public ZonePoint getDragAnchorAsIfLocatedInCell(Zone zone, CellPoint cellPoint) {
ZonePoint anchor = getDragAnchor(zone);
ZonePoint nearestGridCellVertex = zone.getGrid().convert(zone.getGrid().convert(anchor));
ZonePoint targetCellVertex = zone.getGrid().convert(cellPoint);

return new ZonePoint(
targetCellVertex.x + (anchor.x - nearestGridCellVertex.x),
targetCellVertex.y + (anchor.y - nearestGridCellVertex.y));
}

/**
* Gets the point where the token should go, if it were to be snapped to the grid.
*
Expand Down
Loading