Skip to content

Commit 587b38f

Browse files
committed
Change macro functions to use image bounds
Macros written in 1.17 will not expect the change to strict footprint bounds, so these all have to continue using the token image bounds. E.g., without this change, macros written in 1.17 using `movedOverPoints()` and `movedOverToken()` will no longer detect the same cases in 1.18.
1 parent 1750070 commit 587b38f

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/main/java/net/rptools/maptool/client/functions/TokenLocationFunctions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private String tokenMoveMap(boolean fromCurrentMap, List<Object> args) throws Pa
241241
private TokenLocation getTokenLocation(boolean useDistancePerCell, Token token) {
242242
TokenLocation loc = new TokenLocation();
243243
if (useDistancePerCell) {
244-
Rectangle tokenBounds = token.getFootprintBounds(token.getZoneRenderer().getZone());
244+
Rectangle tokenBounds = token.getImageBounds(token.getZoneRenderer().getZone());
245245
loc.x = tokenBounds.x;
246246
loc.y = tokenBounds.y;
247247
} else {
@@ -337,10 +337,10 @@ public double getDistance(Token source, Token target, boolean units, String metr
337337
}
338338
} else {
339339
// take distance between center of the two tokens
340-
Rectangle sourceBounds = source.getFootprintBounds(zone);
340+
Rectangle sourceBounds = source.getImageBounds(zone);
341341
double sourceCenterX = sourceBounds.x + sourceBounds.width / 2.0;
342342
double sourceCenterY = sourceBounds.y + sourceBounds.height / 2.0;
343-
Rectangle targetBounds = target.getFootprintBounds(zone);
343+
Rectangle targetBounds = target.getImageBounds(zone);
344344
double targetCenterX = targetBounds.x + targetBounds.width / 2.0;
345345
double targetCenterY = targetBounds.y + targetBounds.height / 2.0;
346346

@@ -418,7 +418,7 @@ public double getDistance(
418418
}
419419

420420
// get the pixel coords for the center of the token
421-
Rectangle sourceBounds = source.getFootprintBounds(zone);
421+
Rectangle sourceBounds = source.getImageBounds(zone);
422422
double sourceCenterX = sourceBounds.x + sourceBounds.width / 2.0;
423423
double sourceCenterY = sourceBounds.y + sourceBounds.height / 2.0;
424424
double a = (int) (sourceCenterX - targetX);
@@ -452,7 +452,7 @@ public static boolean isTokenAtXY(Token token, Zone zone, Point[] points) {
452452
}
453453
}
454454
} else {
455-
Rectangle bounds = token.getFootprintBounds(zone);
455+
Rectangle bounds = token.getImageBounds(zone);
456456
for (Point point : points) {
457457
if (bounds.contains(point)) return true;
458458
}

src/main/java/net/rptools/maptool/client/functions/TokenMoveFunctions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private List<Map<String, Integer>> crossedPoints(
267267
.getFootprint(grid)
268268
.getBounds(grid, grid.convert(new ZonePoint(entry.get("x"), entry.get("y"))));
269269
} else {
270-
originalArea = tokenInContext.getFootprintBounds(zone);
270+
originalArea = tokenInContext.getImageBounds(zone);
271271
}
272272
Rectangle2D oa = originalArea.getBounds2D();
273273
if (targetArea.contains(oa) || targetArea.intersects(oa)) {
@@ -300,7 +300,7 @@ private List<Map<String, Integer>> crossedToken(
300300
* if-else sequence...
301301
*/
302302
Grid grid = zone.getGrid();
303-
Rectangle targetArea = target.getFootprintBounds(zone);
303+
Rectangle targetArea = target.getImageBounds(zone);
304304

305305
if (pathPoints == null) {
306306
return returnPoints;
@@ -326,7 +326,7 @@ private List<Map<String, Integer>> crossedToken(
326326
Map<String, Integer> firstPoint = new HashMap<String, Integer>(),
327327
secondPoint = new HashMap<String, Integer>();
328328
for (Map<String, Integer> entry : pathPoints) {
329-
Rectangle tokenArea = tokenInContext.getFootprintBounds(zone);
329+
Rectangle tokenArea = tokenInContext.getImageBounds(zone);
330330
Point currentPoint = new Point(entry.get("x"), entry.get("y"));
331331
if (ctr > 0) {
332332
if (targetArea.intersectsLine(new Line2D.Double(previousPoint, currentPoint))

src/main/java/net/rptools/maptool/client/functions/TokenPropertyFunctions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ public Object childEvaluate(
779779
Zone zone = zoneR.getZone();
780780

781781
// Get the pixel width or height of a given token
782-
Rectangle tokenBounds = token.getFootprintBounds(zone);
782+
Rectangle tokenBounds = token.getImageBounds(zone);
783783

784784
if (functionName.equalsIgnoreCase("getTokenWidth")) {
785785
return BigDecimal.valueOf(tokenBounds.width);
@@ -803,7 +803,7 @@ public Object childEvaluate(
803803
Zone zone = zoneR.getZone();
804804

805805
double magnitude = getBigDecimalFromParam(functionName, parameters, 0).doubleValue();
806-
Rectangle tokenBounds = token.getFootprintBounds(zone);
806+
Rectangle tokenBounds = token.getImageBounds(zone);
807807

808808
double oldWidth = tokenBounds.width;
809809
double oldHeight = tokenBounds.height;

src/main/java/net/rptools/maptool/client/functions/TokenSightFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public Object childEvaluate(
110110
target
111111
.getFootprint(grid)
112112
.getBounds(grid, grid.convert(new ZonePoint(target.getX(), target.getY())));
113-
if (!target.isSnapToGrid()) bounds = target.getFootprintBounds(zone);
113+
if (!target.isSnapToGrid()) bounds = target.getImageBounds(zone);
114114

115115
int x = (int) bounds.getX();
116116
int y = (int) bounds.getY();

0 commit comments

Comments
 (0)