Apply changes for v11 compatibility (#277)
This commit is contained in:
@@ -133,8 +133,8 @@ export function onMouseMove(event) {
|
|||||||
|
|
||||||
// Extract event data
|
// Extract event data
|
||||||
const destination = {
|
const destination = {
|
||||||
x: event.data.destination.x + this.rulerOffset.x,
|
x: event.interactionData.destination.x + this.rulerOffset.x,
|
||||||
y: event.data.destination.y + this.rulerOffset.y,
|
y: event.interactionData.destination.y + this.rulerOffset.y,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hide any existing Token HUD
|
// Hide any existing Token HUD
|
||||||
@@ -148,7 +148,7 @@ export function onMouseMove(event) {
|
|||||||
function scheduleMeasurement(destination, event) {
|
function scheduleMeasurement(destination, event) {
|
||||||
const measurementInterval = 50;
|
const measurementInterval = 50;
|
||||||
const mt = event._measureTime || 0;
|
const mt = event._measureTime || 0;
|
||||||
const originalEvent = event.data.originalEvent;
|
const originalEvent = event.interactionData.originalEvent;
|
||||||
if (Date.now() - mt > measurementInterval) {
|
if (Date.now() - mt > measurementInterval) {
|
||||||
this.measure(destination, {snap: !disableSnap});
|
this.measure(destination, {snap: !disableSnap});
|
||||||
event._measureTime = Date.now();
|
event._measureTime = Date.now();
|
||||||
|
|||||||
+9
-9
@@ -138,8 +138,8 @@ function onEntityLeftDragStart(wrapped, event) {
|
|||||||
ruler.draggedEntity = this;
|
ruler.draggedEntity = this;
|
||||||
const entityCenter = getEntityCenter(this);
|
const entityCenter = getEntityCenter(this);
|
||||||
ruler.rulerOffset = {
|
ruler.rulerOffset = {
|
||||||
x: entityCenter.x - event.data.origin.x,
|
x: entityCenter.x - event.interactionData.origin.x,
|
||||||
y: entityCenter.y - event.data.origin.y,
|
y: entityCenter.y - event.interactionData.origin.y,
|
||||||
};
|
};
|
||||||
if (game.settings.get(settingsKey, "autoStartMeasurement")) {
|
if (game.settings.get(settingsKey, "autoStartMeasurement")) {
|
||||||
let options = {};
|
let options = {};
|
||||||
@@ -215,8 +215,8 @@ function applyGridlessSnapping(event) {
|
|||||||
if (canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS) return;
|
if (canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS) return;
|
||||||
|
|
||||||
const rasterWidth = 35 / canvas.stage.scale.x;
|
const rasterWidth = 35 / canvas.stage.scale.x;
|
||||||
const tokenX = event.data.destination.x;
|
const tokenX = event.interactionData.destination.x;
|
||||||
const tokenY = event.data.destination.y;
|
const tokenY = event.interactionData.destination.y;
|
||||||
const destination = {x: tokenX + ruler.rulerOffset.x, y: tokenY + ruler.rulerOffset.y};
|
const destination = {x: tokenX + ruler.rulerOffset.x, y: tokenY + ruler.rulerOffset.y};
|
||||||
const ranges = getRangesFromSpeedProvider(ruler.draggedEntity);
|
const ranges = getRangesFromSpeedProvider(ruler.draggedEntity);
|
||||||
|
|
||||||
@@ -241,13 +241,13 @@ 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.data.destination.x = rasterLocation.x - ruler.rulerOffset.x;
|
event.interactionData.destination.x = rasterLocation.x - ruler.rulerOffset.x;
|
||||||
event.data.destination.y = rasterLocation.y - ruler.rulerOffset.y;
|
event.interactionData.destination.y = rasterLocation.y - ruler.rulerOffset.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let waypointDistance = 0;
|
let waypointDistance = 0;
|
||||||
let origin = event.data.origin;
|
let origin = event.interactionData.origin;
|
||||||
if (ruler.waypoints.length > 1) {
|
if (ruler.waypoints.length > 1) {
|
||||||
const segments = ruler.constructor
|
const segments = ruler.constructor
|
||||||
.dragRulerGetRaysFromWaypoints(ruler.waypoints, destination)
|
.dragRulerGetRaysFromWaypoints(ruler.waypoints, destination)
|
||||||
@@ -271,8 +271,8 @@ function applyGridlessSnapping(event) {
|
|||||||
.reduce((a, b) => Math.max(a, b), 0);
|
.reduce((a, b) => Math.max(a, b), 0);
|
||||||
if (targetDistance) {
|
if (targetDistance) {
|
||||||
if (distance < targetDistance + rasterWidth) {
|
if (distance < targetDistance + rasterWidth) {
|
||||||
event.data.destination.x = origin.x + (deltaX * targetDistance) / distance;
|
event.interactionData.destination.x = origin.x + (deltaX * targetDistance) / distance;
|
||||||
event.data.destination.y = origin.y + (deltaY * targetDistance) / distance;
|
event.interactionData.destination.y = origin.y + (deltaY * targetDistance) / distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -17,6 +17,7 @@ import {
|
|||||||
getTokenShape,
|
getTokenShape,
|
||||||
isPathfindingEnabled,
|
isPathfindingEnabled,
|
||||||
} from "./util.js";
|
} from "./util.js";
|
||||||
|
import {getPointer} from "./util.js";
|
||||||
|
|
||||||
export function extendRuler() {
|
export function extendRuler() {
|
||||||
class DragRulerRuler extends CONFIG.Canvas.rulerClass {
|
class DragRulerRuler extends CONFIG.Canvas.rulerClass {
|
||||||
@@ -379,7 +380,7 @@ export function extendRuler() {
|
|||||||
options.snap = options.snap ?? true;
|
options.snap = options.snap ?? true;
|
||||||
if (this.waypoints.filter(w => !w.isPrevious).length > 1) {
|
if (this.waypoints.filter(w => !w.isPrevious).length > 1) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(
|
const mousePosition = getPointer().getLocalPosition(
|
||||||
canvas.tokens,
|
canvas.tokens,
|
||||||
);
|
);
|
||||||
const rulerOffset = this.rulerOffset;
|
const rulerOffset = this.rulerOffset;
|
||||||
@@ -483,7 +484,7 @@ export function extendRuler() {
|
|||||||
if (isToken && game.settings.get(settingsKey, "enableMovementHistory"))
|
if (isToken && game.settings.get(settingsKey, "enableMovementHistory"))
|
||||||
ruler.dragRulerAddWaypointHistory(getMovementHistory(entity));
|
ruler.dragRulerAddWaypointHistory(getMovementHistory(entity));
|
||||||
ruler.dragRulerAddWaypoint(entityCenter, {snap: false});
|
ruler.dragRulerAddWaypoint(entityCenter, {snap: false});
|
||||||
const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(
|
const mousePosition = getPointer().getLocalPosition(
|
||||||
canvas.tokens,
|
canvas.tokens,
|
||||||
);
|
);
|
||||||
const destination = {
|
const destination = {
|
||||||
|
|||||||
+5
-1
@@ -285,8 +285,12 @@ export function isClose(a, b, delta) {
|
|||||||
return Math.abs(a - b) <= delta;
|
return Math.abs(a - b) <= delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPointer() {
|
||||||
|
return canvas.app.renderer.plugins.interaction?.mouse ?? canvas.app.renderer.events.pointer
|
||||||
|
}
|
||||||
|
|
||||||
export function getMeasurePosition() {
|
export function getMeasurePosition() {
|
||||||
const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(
|
const mousePosition = getPointer().getLocalPosition(
|
||||||
canvas.tokens,
|
canvas.tokens,
|
||||||
);
|
);
|
||||||
const rulerOffset = canvas.controls.ruler.rulerOffset;
|
const rulerOffset = canvas.controls.ruler.rulerOffset;
|
||||||
|
|||||||
Reference in New Issue
Block a user