Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52b64c3016 | |||
| 48d0d17628 | |||
| 8101381cc4 | |||
| 844df150a6 | |||
| 47715e95f6 | |||
| 1dccbcb081 | |||
| 4c3d7ab42a | |||
| 61fc795f7b | |||
| f10fa049b9 | |||
| c844318836 | |||
| 9af692566c | |||
| d08416777b |
@@ -0,0 +1,4 @@
|
||||
*.md
|
||||
*.html
|
||||
*.json
|
||||
foundry.js
|
||||
@@ -1,3 +1,18 @@
|
||||
## 1.13.6
|
||||
### Bugfixes
|
||||
- Fixed a bug that caused no measurements to be shown next to the ruler
|
||||
- Fixed a bug where diagonal paths would sometimes highlight squares that don't blong to the path on square maps
|
||||
|
||||
|
||||
## 1.13.5
|
||||
### Compatibility
|
||||
- Drag Ruler is now compatible with Foundry VTT v11 (thanks to pkonshik for doing much of the porting work!)
|
||||
- Drag Ruler's generic speed provider is now aware of good defaults for Warhammer Fantasy Roleplay 4th Edition
|
||||
|
||||
### Translations
|
||||
- Updated Portugese (Brazil) translation (thanks eunaumtenhoid!)
|
||||
|
||||
|
||||
## 1.13.4
|
||||
### Translations
|
||||
- New translation: Portuguese (Brazil) (thanks eunaumtenhoid!)
|
||||
|
||||
+2
-2
@@ -78,7 +78,7 @@
|
||||
},
|
||||
"showGMRulerToPlayers": {
|
||||
"name": "Mostrar régua do GM aos jogadores",
|
||||
"hint": "Se desativado, o governante dos GMs não será exibido para jogadores não-GM."
|
||||
"hint": "Se desativado, a régua dos GMs não será exibido para jogadores não-GM."
|
||||
},
|
||||
"speedProviderSettings": {
|
||||
"name": "Configurações do provedor de velocidade",
|
||||
@@ -114,7 +114,7 @@
|
||||
},
|
||||
"useGridlessRaster": {
|
||||
"name": "Use o ajuste baseado em velocidade",
|
||||
"hint": "Em cenas Gridless, isso faz com que os tokens se encaixem nas faixas de velocidade do token."
|
||||
"hint": "Em cenas sem grid, isso faz com que os tokens se encaixem nas faixas de velocidade do token."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -2,10 +2,10 @@
|
||||
"id": "drag-ruler",
|
||||
"title": "Drag Ruler",
|
||||
"description": "When dragging a token displays a ruler showing how far you've moved that token.",
|
||||
"version": "1.13.4",
|
||||
"version": "1.13.6",
|
||||
"compatibility": {
|
||||
"minimum": "10",
|
||||
"verified": "10"
|
||||
"minimum": "11",
|
||||
"verified": "11"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
@@ -80,7 +80,7 @@
|
||||
},
|
||||
"socket": true,
|
||||
"url": "https://github.com/manuelVo/foundryvtt-drag-ruler",
|
||||
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.13.4.zip",
|
||||
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.13.6.zip",
|
||||
"manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/master/module.json",
|
||||
"readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md",
|
||||
"changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md",
|
||||
|
||||
@@ -18,7 +18,7 @@ export function measureDistances(segments, entity, shape, options = {}) {
|
||||
const opts = duplicate(options);
|
||||
if (canvas.grid.diagonalRule === "EUCL") {
|
||||
opts.ignoreGrid = true;
|
||||
opts.gridSpaes = false;
|
||||
opts.gridSpaces = false;
|
||||
}
|
||||
if (opts.enableTerrainRuler) {
|
||||
opts.gridSpaces = true;
|
||||
|
||||
@@ -133,8 +133,8 @@ export function onMouseMove(event) {
|
||||
|
||||
// Extract event data
|
||||
const destination = {
|
||||
x: event.data.destination.x + this.rulerOffset.x,
|
||||
y: event.data.destination.y + this.rulerOffset.y,
|
||||
x: event.interactionData.destination.x + this.rulerOffset.x,
|
||||
y: event.interactionData.destination.y + this.rulerOffset.y,
|
||||
};
|
||||
|
||||
// Hide any existing Token HUD
|
||||
@@ -148,7 +148,7 @@ export function onMouseMove(event) {
|
||||
function scheduleMeasurement(destination, event) {
|
||||
const measurementInterval = 50;
|
||||
const mt = event._measureTime || 0;
|
||||
const originalEvent = event.data.originalEvent;
|
||||
const originalEvent = event.interactionData.originalEvent;
|
||||
if (Date.now() - mt > measurementInterval) {
|
||||
this.measure(destination, {snap: !disableSnap});
|
||||
event._measureTime = Date.now();
|
||||
@@ -185,7 +185,7 @@ export function highlightMeasurementNative(
|
||||
tokenShape = [{x: 0, y: 0}],
|
||||
alpha = 1,
|
||||
) {
|
||||
const spacer = canvas.scene.gridType === CONST.GRID_TYPES.SQUARE ? 1.41 : 1;
|
||||
const spacer = canvas.scene.grid.type === CONST.GRID_TYPES.SQUARE ? 1.41 : 1;
|
||||
const nMax = Math.max(
|
||||
Math.floor(ray.distance / (spacer * Math.min(canvas.grid.w, canvas.grid.h))),
|
||||
1,
|
||||
|
||||
+9
-9
@@ -138,8 +138,8 @@ function onEntityLeftDragStart(wrapped, event) {
|
||||
ruler.draggedEntity = this;
|
||||
const entityCenter = getEntityCenter(this);
|
||||
ruler.rulerOffset = {
|
||||
x: entityCenter.x - event.data.origin.x,
|
||||
y: entityCenter.y - event.data.origin.y,
|
||||
x: entityCenter.x - event.interactionData.origin.x,
|
||||
y: entityCenter.y - event.interactionData.origin.y,
|
||||
};
|
||||
if (game.settings.get(settingsKey, "autoStartMeasurement")) {
|
||||
let options = {};
|
||||
@@ -215,8 +215,8 @@ function applyGridlessSnapping(event) {
|
||||
if (canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS) return;
|
||||
|
||||
const rasterWidth = 35 / canvas.stage.scale.x;
|
||||
const tokenX = event.data.destination.x;
|
||||
const tokenY = event.data.destination.y;
|
||||
const tokenX = event.interactionData.destination.x;
|
||||
const tokenY = event.interactionData.destination.y;
|
||||
const destination = {x: tokenX + ruler.rulerOffset.x, y: tokenY + ruler.rulerOffset.y};
|
||||
const ranges = getRangesFromSpeedProvider(ruler.draggedEntity);
|
||||
|
||||
@@ -241,13 +241,13 @@ function applyGridlessSnapping(event) {
|
||||
const deltaY = destination.y - rasterLocation.y;
|
||||
const rasterDistance = Math.hypot(deltaX, deltaY);
|
||||
if (rasterDistance < rasterWidth) {
|
||||
event.data.destination.x = rasterLocation.x - ruler.rulerOffset.x;
|
||||
event.data.destination.y = rasterLocation.y - ruler.rulerOffset.y;
|
||||
event.interactionData.destination.x = rasterLocation.x - ruler.rulerOffset.x;
|
||||
event.interactionData.destination.y = rasterLocation.y - ruler.rulerOffset.y;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let waypointDistance = 0;
|
||||
let origin = event.data.origin;
|
||||
let origin = event.interactionData.origin;
|
||||
if (ruler.waypoints.length > 1) {
|
||||
const segments = ruler.constructor
|
||||
.dragRulerGetRaysFromWaypoints(ruler.waypoints, destination)
|
||||
@@ -271,8 +271,8 @@ function applyGridlessSnapping(event) {
|
||||
.reduce((a, b) => Math.max(a, b), 0);
|
||||
if (targetDistance) {
|
||||
if (distance < targetDistance + rasterWidth) {
|
||||
event.data.destination.x = origin.x + (deltaX * targetDistance) / distance;
|
||||
event.data.destination.y = origin.y + (deltaY * targetDistance) / distance;
|
||||
event.interactionData.destination.x = origin.x + (deltaX * targetDistance) / distance;
|
||||
event.interactionData.destination.y = origin.y + (deltaY * targetDistance) / distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-29
@@ -17,6 +17,7 @@ import {
|
||||
getTokenShape,
|
||||
isPathfindingEnabled,
|
||||
} from "./util.js";
|
||||
import {getPointer} from "./util.js";
|
||||
|
||||
export function extendRuler() {
|
||||
class DragRulerRuler extends CONFIG.Canvas.rulerClass {
|
||||
@@ -261,29 +262,23 @@ export function extendRuler() {
|
||||
if (!this.isDragRuler) {
|
||||
return super._computeDistance(gridSpaces);
|
||||
}
|
||||
if (!this.dragRulerEnableTerrainRuler) {
|
||||
if (!this.dragRulerIgnoreGrid) {
|
||||
gridSpaces = true;
|
||||
}
|
||||
super._computeDistance(gridSpaces);
|
||||
} else {
|
||||
const shape = this.draggedEntity ? getTokenShape(this.draggedEntity) : null;
|
||||
const options = {
|
||||
ignoreGrid: this.dragRulerIgnoreGrid,
|
||||
gridSpaces,
|
||||
enableTerrainRuler: this.dragRulerEnableTerrainRuler,
|
||||
};
|
||||
const distances = measureDistances(this.segments, this.draggedEntity, shape, options);
|
||||
let totalDistance = 0;
|
||||
for (const [i, d] of distances.entries()) {
|
||||
let s = this.segments[i];
|
||||
s.startDistance = totalDistance;
|
||||
totalDistance += d;
|
||||
s.last = i === this.segments.length - 1;
|
||||
s.distance = d;
|
||||
s.text = this._getSegmentLabel(s, totalDistance);
|
||||
}
|
||||
const shape = this.draggedEntity ? getTokenShape(this.draggedEntity) : null;
|
||||
const options = {
|
||||
ignoreGrid: this.dragRulerIgnoreGrid,
|
||||
gridSpaces,
|
||||
enableTerrainRuler: this.dragRulerEnableTerrainRuler,
|
||||
};
|
||||
const distances = measureDistances(this.segments, this.draggedEntity, shape, options);
|
||||
let totalDistance = 0;
|
||||
for (const [i, d] of distances.entries()) {
|
||||
let s = this.segments[i];
|
||||
s.startDistance = totalDistance;
|
||||
totalDistance += d;
|
||||
s.last = i === this.segments.length - 1;
|
||||
s.distance = d;
|
||||
s.text = this._getSegmentLabel(s, totalDistance);
|
||||
}
|
||||
|
||||
for (const [i, segment] of this.segments.entries()) {
|
||||
const unsnappedSegment = this.dragRulerUnsnappedSegments[i];
|
||||
unsnappedSegment.startDistance = segment.startDistance;
|
||||
@@ -379,9 +374,7 @@ export function extendRuler() {
|
||||
options.snap = options.snap ?? true;
|
||||
if (this.waypoints.filter(w => !w.isPrevious).length > 1) {
|
||||
event.preventDefault();
|
||||
const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(
|
||||
canvas.tokens,
|
||||
);
|
||||
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
||||
const rulerOffset = this.rulerOffset;
|
||||
|
||||
// Options are not passed to _removeWaypoint in vanilla Foundry.
|
||||
@@ -416,7 +409,7 @@ export function extendRuler() {
|
||||
this._endMeasurement();
|
||||
|
||||
// Deactivate the drag workflow in mouse
|
||||
token.mouseInteractionManager._deactivateDragEvents();
|
||||
token.mouseInteractionManager.cancel(event);
|
||||
token.mouseInteractionManager.state = token.mouseInteractionManager.states.HOVER;
|
||||
|
||||
// This will cancel the current drag operation
|
||||
@@ -483,9 +476,7 @@ export function extendRuler() {
|
||||
if (isToken && game.settings.get(settingsKey, "enableMovementHistory"))
|
||||
ruler.dragRulerAddWaypointHistory(getMovementHistory(entity));
|
||||
ruler.dragRulerAddWaypoint(entityCenter, {snap: false});
|
||||
const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(
|
||||
canvas.tokens,
|
||||
);
|
||||
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
||||
const destination = {
|
||||
x: mousePosition.x + ruler.rulerOffset.x,
|
||||
y: mousePosition.y + ruler.rulerOffset.y,
|
||||
|
||||
@@ -23,6 +23,8 @@ export function getDefaultSpeedAttribute() {
|
||||
return "actor.system.combatValues.movement.total";
|
||||
case "splittermond":
|
||||
return "actor.derivedValues.speed.value";
|
||||
case "wfrp4e":
|
||||
return "actor.system.details.move.walk";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -45,6 +47,8 @@ export function getDefaultDashMultiplier() {
|
||||
return 5;
|
||||
case "splittermond":
|
||||
return 3;
|
||||
case "wfrp4e":
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+5
-3
@@ -285,10 +285,12 @@ export function isClose(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() {
|
||||
const mousePosition = canvas.app.renderer.plugins.interaction.mouse.getLocalPosition(
|
||||
canvas.tokens,
|
||||
);
|
||||
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
||||
const rulerOffset = canvas.controls.ruler.rulerOffset;
|
||||
const measurePosition = {x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y};
|
||||
return measurePosition;
|
||||
|
||||
Reference in New Issue
Block a user