Restore rulerOffset for all uses except hex grids (fixes #332)
This restores the functinality of gridless, but it is not a proper fix. Most likely all the functionality in foundry_imports.js has to be re-imported at this point
This commit is contained in:
+9
-4
@@ -137,6 +137,11 @@ function onEntityLeftDragStart(wrapped, event) {
|
||||
const ruler = canvas.controls.ruler;
|
||||
ruler.draggedEntity = 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")) {
|
||||
let options = {};
|
||||
setSnapParameterOnOptions(ruler, options);
|
||||
@@ -213,7 +218,7 @@ function applyGridlessSnapping(event) {
|
||||
const rasterWidth = 35 / canvas.stage.scale.x;
|
||||
const tokenX = event.interactionData.destination.x;
|
||||
const tokenY = event.interactionData.destination.y;
|
||||
const destination = {x: tokenX, y: tokenY};
|
||||
const destination = {x: tokenX + ruler.rulerOffset.x, y: tokenY + ruler.rulerOffset.y};
|
||||
const ranges = getRangesFromSpeedProvider(ruler.draggedEntity);
|
||||
|
||||
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active;
|
||||
@@ -237,8 +242,8 @@ function applyGridlessSnapping(event) {
|
||||
const deltaY = destination.y - rasterLocation.y;
|
||||
const rasterDistance = Math.hypot(deltaX, deltaY);
|
||||
if (rasterDistance < rasterWidth) {
|
||||
event.interactionData.destination.x = rasterLocation.x;
|
||||
event.interactionData.destination.y = rasterLocation.y;
|
||||
event.interactionData.destination.x = rasterLocation.x - ruler.rulerOffset.x;
|
||||
event.interactionData.destination.y = rasterLocation.y - ruler.rulerOffset.y;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -252,7 +257,7 @@ function applyGridlessSnapping(event) {
|
||||
});
|
||||
origin = segments.pop().ray.A;
|
||||
waypointDistance = canvas.grid.measureDistances(segments).reduce((a, b) => a + b);
|
||||
origin = {x: origin.x, y: origin.y};
|
||||
origin = {x: origin.x - ruler.rulerOffset.x, y: origin.y - ruler.rulerOffset.y};
|
||||
}
|
||||
|
||||
const deltaX = tokenX - origin.x;
|
||||
|
||||
Reference in New Issue
Block a user