Revert "Restore rulerOffset for all uses except hex grids (fixes #332)"
This reverts commit ab1f5b4c9b.
This commit is contained in:
@@ -140,10 +140,6 @@ export function onMouseMove(event) {
|
|||||||
x: event.interactionData.destination.x,
|
x: event.interactionData.destination.x,
|
||||||
y: event.interactionData.destination.y,
|
y: event.interactionData.destination.y,
|
||||||
};
|
};
|
||||||
if (!canvas.grid.isHex) {
|
|
||||||
destination.x += this.rulerOffset.x;
|
|
||||||
destination.y += this.rulerOffset.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide any existing Token HUD
|
// Hide any existing Token HUD
|
||||||
canvas.hud.token.clear();
|
canvas.hud.token.clear();
|
||||||
|
|||||||
+4
-9
@@ -137,11 +137,6 @@ function onEntityLeftDragStart(wrapped, event) {
|
|||||||
const ruler = canvas.controls.ruler;
|
const ruler = canvas.controls.ruler;
|
||||||
ruler.draggedEntity = this;
|
ruler.draggedEntity = this;
|
||||||
const entityCenter = getEntityCenter(this);
|
const entityCenter = getEntityCenter(this);
|
||||||
const isV11 = game.release.generation === 11;
|
|
||||||
ruler.rulerOffset = {
|
|
||||||
x: isV11 ? entityCenter.x - event.interactionData.origin.x : 0,
|
|
||||||
y: isV11 ? entityCenter.y - event.interactionData.origin.y : 0,
|
|
||||||
};
|
|
||||||
if (game.settings.get(settingsKey, "autoStartMeasurement")) {
|
if (game.settings.get(settingsKey, "autoStartMeasurement")) {
|
||||||
let options = {};
|
let options = {};
|
||||||
setSnapParameterOnOptions(ruler, options);
|
setSnapParameterOnOptions(ruler, options);
|
||||||
@@ -218,7 +213,7 @@ function applyGridlessSnapping(event) {
|
|||||||
const rasterWidth = 35 / canvas.stage.scale.x;
|
const rasterWidth = 35 / canvas.stage.scale.x;
|
||||||
const tokenX = event.interactionData.destination.x;
|
const tokenX = event.interactionData.destination.x;
|
||||||
const tokenY = event.interactionData.destination.y;
|
const tokenY = event.interactionData.destination.y;
|
||||||
const destination = {x: tokenX + ruler.rulerOffset.x, y: tokenY + ruler.rulerOffset.y};
|
const destination = {x: tokenX, y: tokenY};
|
||||||
const ranges = getRangesFromSpeedProvider(ruler.draggedEntity);
|
const ranges = getRangesFromSpeedProvider(ruler.draggedEntity);
|
||||||
|
|
||||||
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active;
|
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active;
|
||||||
@@ -242,8 +237,8 @@ function applyGridlessSnapping(event) {
|
|||||||
const deltaY = destination.y - rasterLocation.y;
|
const deltaY = destination.y - rasterLocation.y;
|
||||||
const rasterDistance = Math.hypot(deltaX, deltaY);
|
const rasterDistance = Math.hypot(deltaX, deltaY);
|
||||||
if (rasterDistance < rasterWidth) {
|
if (rasterDistance < rasterWidth) {
|
||||||
event.interactionData.destination.x = rasterLocation.x - ruler.rulerOffset.x;
|
event.interactionData.destination.x = rasterLocation.x;
|
||||||
event.interactionData.destination.y = rasterLocation.y - ruler.rulerOffset.y;
|
event.interactionData.destination.y = rasterLocation.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -257,7 +252,7 @@ function applyGridlessSnapping(event) {
|
|||||||
});
|
});
|
||||||
origin = segments.pop().ray.A;
|
origin = segments.pop().ray.A;
|
||||||
waypointDistance = canvas.grid.measureDistances(segments).reduce((a, b) => a + b);
|
waypointDistance = canvas.grid.measureDistances(segments).reduce((a, b) => a + b);
|
||||||
origin = {x: origin.x - ruler.rulerOffset.x, y: origin.y - ruler.rulerOffset.y};
|
origin = {x: origin.x, y: origin.y};
|
||||||
}
|
}
|
||||||
|
|
||||||
const deltaX = tokenX - origin.x;
|
const deltaX = tokenX - origin.x;
|
||||||
|
|||||||
+3
-7
@@ -391,14 +391,10 @@ export function extendRuler() {
|
|||||||
if (this.waypoints.filter(w => !w.isPrevious).length > 1) {
|
if (this.waypoints.filter(w => !w.isPrevious).length > 1) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
||||||
const rulerOffset = this.rulerOffset;
|
|
||||||
|
|
||||||
// Options are not passed to _removeWaypoint in vanilla Foundry.
|
// Options are not passed to _removeWaypoint in vanilla Foundry.
|
||||||
// Send them in case other modules have overriden that behavior and accept an options parameter (Toggle Snap to Grid)
|
// Send them in case other modules have overriden that behavior and accept an options parameter (Toggle Snap to Grid)
|
||||||
this._removeWaypoint(
|
this._removeWaypoint({x: mousePosition.x, y: mousePosition.y}, options);
|
||||||
{x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y},
|
|
||||||
options,
|
|
||||||
);
|
|
||||||
this.performPostPathfindingActions(options);
|
this.performPostPathfindingActions(options);
|
||||||
} else {
|
} else {
|
||||||
this.dragRulerAbortDrag(event);
|
this.dragRulerAbortDrag(event);
|
||||||
@@ -494,8 +490,8 @@ export function extendRuler() {
|
|||||||
ruler.dragRulerAddWaypoint(entityCenter, {snap: false});
|
ruler.dragRulerAddWaypoint(entityCenter, {snap: false});
|
||||||
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
||||||
const destination = {
|
const destination = {
|
||||||
x: mousePosition.x + ruler.rulerOffset.x,
|
x: mousePosition.x,
|
||||||
y: mousePosition.y + ruler.rulerOffset.y,
|
y: mousePosition.y,
|
||||||
};
|
};
|
||||||
if (measureImmediately) ruler.measure(destination, options);
|
if (measureImmediately) ruler.measure(destination, options);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -301,8 +301,7 @@ export function getPointer() {
|
|||||||
|
|
||||||
export function getMeasurePosition() {
|
export function getMeasurePosition() {
|
||||||
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
||||||
const rulerOffset = canvas.controls.ruler.rulerOffset;
|
const measurePosition = {x: mousePosition.x, y: mousePosition.y};
|
||||||
const measurePosition = {x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y};
|
|
||||||
return measurePosition;
|
return measurePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user