Compare commits

...

7 Commits

Author SHA1 Message Date
Manuel Vögele f18ce33779 Release v1.10.2 2022-01-17 21:24:15 +01:00
Manuel Vögele 34cead5cba Clean up vision of clones when dropping a token (fixes #140) 2022-01-17 13:42:48 +01:00
Manuel Vögele eeb6db76a6 Measure the full path to determine highlight color (fixes #142) 2022-01-17 12:50:05 +01:00
Manuel Vögele 9c44994fd2 Add "A5e Drag Ruler Integration" to the list of game system integrations 2022-01-14 12:58:38 +01:00
Manuel Vögele 23c1a903a0 Release v1.10.1 2022-01-07 15:12:24 +01:00
Manuel Vögele 1b3f563c4e Keybindings no longer break if no scene is active (fixes #113) 2022-01-07 15:10:17 +01:00
José Lozano c4595f408f Spanish updated (#141) 2022-01-07 15:07:54 +01:00
8 changed files with 72 additions and 15 deletions
+14
View File
@@ -1,3 +1,17 @@
## 1.10.2
### Bugfixes
- Fixed a bug that could cause squares to be highlighted in the wrong color when using waypoints on a 5/10/5 gird
- When using Token Drag Vision, the temporary vision is now correctly cleaned up when dropping the token (resolves a conflict with the "Perfect Vision" module)
## 1.10.1
### Bugfixes
- Fixed a bug that caused keybindings to break if no scene is active
### Translation
- Updated Spanish translation (thanks to Viriato139ac#342)
## 1.10.0 ## 1.10.0
**BREAKING** Drag Ruler 1.10.0 and onward cannot update directly from Drag Ruler versions older than 1.3.0. If you've been using Drag Ruler 1.2.2 or earlier in your world make sure to update to any Version between (inclusive) Drag Ruler 1.3.0 and 1.9.1, launch your world and log in as GM at least once. After doing so you can safely update to v1.10.0 or newer versions. Updating directly from 1.2.2 or older to 1.10.0 or newer will cause Drag Ruler to forget your Speed Prover Settings. **BREAKING** Drag Ruler 1.10.0 and onward cannot update directly from Drag Ruler versions older than 1.3.0. If you've been using Drag Ruler 1.2.2 or earlier in your world make sure to update to any Version between (inclusive) Drag Ruler 1.3.0 and 1.9.1, launch your world and log in as GM at least once. After doing so you can safely update to v1.10.0 or newer versions. Updating directly from 1.2.2 or older to 1.10.0 or newer will cause Drag Ruler to forget your Speed Prover Settings.
+1
View File
@@ -40,6 +40,7 @@ The game systems that offer Drag Ruler integration are:
- GURPS 4th Edition Game Aid (Unofficial) (starting with version 0.9.1) - GURPS 4th Edition Game Aid (Unofficial) (starting with version 0.9.1)
- Ironclaw Second Edition (starting with version 0.2.2) - Ironclaw Second Edition (starting with version 0.2.2)
- Lancer (via the module [Lancer Speed Provider](https://foundryvtt.com/packages/lancer-speed-provider)) - Lancer (via the module [Lancer Speed Provider](https://foundryvtt.com/packages/lancer-speed-provider))
- Level Up: Advanced 5th Edition (Official) (via the module [A5E Drag Ruler Integration](https://foundryvtt.com/packages/a5edragruler))
- Pathfinder 1 (starting with version 0.77.3) - Pathfinder 1 (starting with version 0.77.3)
- Pathfinder 2e (via the module [PF2E Drag Ruler Integration](https://foundryvtt.com/packages/pf2e-dragruler/)) - Pathfinder 2e (via the module [PF2E Drag Ruler Integration](https://foundryvtt.com/packages/pf2e-dragruler/))
- Shadowrun 5th Edition (via the module [Drag Ruler Integration for Shadowrun 5E](https://foundryvtt.com/packages/drag-ruler-integration-for-shadowrun-5e)) - Shadowrun 5th Edition (via the module [Drag Ruler Integration for Shadowrun 5E](https://foundryvtt.com/packages/drag-ruler-integration-for-shadowrun-5e))
+22
View File
@@ -33,6 +33,19 @@
"dash": "correr" "dash": "correr"
} }
}, },
"keybindings": {
"cancelDrag": "Cancelar arrastre",
"createWaypoint": "Crear punto de ruta",
"deleteWaypoint": "Borrar punto de ruta",
"disableSnap": {
"name": "Deshabilitar ajuste",
"hint": "El ajuste a la rejilla se deshabilitará temporalmente mientras se presione esta tecla"
},
"moveWithoutAnimation": {
"name": "Deshabilitar animación de icono",
"hint": "Si al soltar un icono se presiona esta tecla, se deshabilitará la animación del icono al moverse al destino"
}
},
"settings": { "settings": {
"alwaysShowSpeedForPCs": { "alwaysShowSpeedForPCs": {
"name": "Mostrar velocidad de los PJs a todo el mundo", "name": "Mostrar velocidad de los PJs a todo el mundo",
@@ -46,6 +59,15 @@
"name": "Habilitar historial de movimiento durante el combate", "name": "Habilitar historial de movimiento durante el combate",
"hint": "Si se habilita, Drag Ruler recordará la ruta que ha seguido un icono en su turno y la mostrará al seleccionarlo de nuevo" "hint": "Si se habilita, Drag Ruler recordará la ruta que ha seguido un icono en su turno y la mostrará al seleccionarlo de nuevo"
}, },
"rightClickAction": {
"name": "Acción del botón derecho",
"hint": "Qué acción se llevará a cabo cuando se haga clic derecho mientras se arrastra un icono",
"choices": {
"create": "Crear punto de ruta",
"delete": "Borrar punto de ruta",
"cancel": "Cancelar arrastre"
}
},
"showGMRulerToPlayers": { "showGMRulerToPlayers": {
"name": "Mostrar regla del GM a los jugadores", "name": "Mostrar regla del GM a los jugadores",
"hint": "Si se deshabilita, no se mostrará la regla de medición de los GMs al resto de usuarios" "hint": "Si se deshabilita, no se mostrará la regla de medición de los GMs al resto de usuarios"
+2 -2
View File
@@ -2,7 +2,7 @@
"name": "drag-ruler", "name": "drag-ruler",
"title": "Drag Ruler", "title": "Drag Ruler",
"description": "When dragging a token displays a ruler showing how far you've moved that token.", "description": "When dragging a token displays a ruler showing how far you've moved that token.",
"version": "1.10.0", "version": "1.10.2",
"minimumCoreVersion" : "9.238", "minimumCoreVersion" : "9.238",
"compatibleCoreVersion" : "9", "compatibleCoreVersion" : "9",
"authors": [ "authors": [
@@ -65,7 +65,7 @@
], ],
"socket": true, "socket": true,
"url": "https://github.com/manuelVo/foundryvtt-drag-ruler", "url": "https://github.com/manuelVo/foundryvtt-drag-ruler",
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.10.0.zip", "download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.10.2.zip",
"manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/master/module.json", "manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/master/module.json",
"readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md", "readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md",
"changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md", "changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md",
+15 -10
View File
@@ -4,7 +4,7 @@ import {Line} from "./geometry.js";
import {disableSnap, moveWithoutAnimation} from "./keybindings.js"; import {disableSnap, moveWithoutAnimation} from "./keybindings.js";
import {trackRays} from "./movement_tracking.js" import {trackRays} from "./movement_tracking.js"
import {recalculate} from "./socket.js"; import {recalculate} from "./socket.js";
import {applyTokenSizeOffset, getSnapPointForEntity, getSnapPointForToken, getTokenShape, highlightTokenShape, zip} from "./util.js"; import {applyTokenSizeOffset, enumeratedZip, getSnapPointForEntity, getSnapPointForToken, getTokenShape, highlightTokenShape, sum} from "./util.js";
// This is a modified version of Ruler.moveToken from foundry 0.7.9 // This is a modified version of Ruler.moveToken from foundry 0.7.9
export async function moveEntities(draggedEntity, selectedEntities) { export async function moveEntities(draggedEntity, selectedEntities) {
@@ -237,7 +237,7 @@ export function measure(destination, options={}) {
rulerColor = this.dragRulerGetColorForDistance(totalDistance); rulerColor = this.dragRulerGetColorForDistance(totalDistance);
else else
rulerColor = this.color rulerColor = this.color
for (const [s, cs] of zip(segments.reverse(), centeredSegments.reverse())) { for (const [i, s, cs] of enumeratedZip([...segments].reverse(), [...centeredSegments].reverse())) {
const { label, text, last } = cs; const { label, text, last } = cs;
// Draw line segment // Draw line segment
@@ -270,10 +270,13 @@ export function measure(destination, options={}) {
// Highlight grid positions // Highlight grid positions
if (isToken && canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS && options.gridSpaces) { if (isToken && canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS && options.gridSpaces) {
if (options.enableTerrainRuler) if (options.enableTerrainRuler) {
highlightMeasurementTerrainRuler.call(this, cs.ray, cs.startDistance, shape, opacityMultiplier) highlightMeasurementTerrainRuler.call(this, cs.ray, cs.startDistance, shape, opacityMultiplier)
else }
highlightMeasurementNative.call(this, cs.ray, cs.startDistance, shape, opacityMultiplier); else {
const previousSegments = centeredSegments.slice(0, segments.length - 1 - i);
highlightMeasurementNative.call(this, cs.ray, previousSegments, shape, opacityMultiplier);
}
} }
} }
@@ -286,7 +289,7 @@ export function measure(destination, options={}) {
return segments; return segments;
} }
export function highlightMeasurementNative(ray, startDistance, tokenShape=[{x: 0, y: 0}], alpha=1) { export function highlightMeasurementNative(ray, previousSegments, tokenShape=[{x: 0, y: 0}], alpha=1) {
const spacer = canvas.scene.data.gridType === CONST.GRID_TYPES.SQUARE ? 1.41 : 1; const spacer = canvas.scene.data.gridType === 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); const nMax = Math.max(Math.floor(ray.distance / (spacer * Math.min(canvas.grid.w, canvas.grid.h))), 1);
const tMax = Array.fromRange(nMax+1).map(t => t / nMax); const tMax = Array.fromRange(nMax+1).map(t => t / nMax);
@@ -305,8 +308,9 @@ export function highlightMeasurementNative(ray, startDistance, tokenShape=[{x: 0
// Highlight the grid position // Highlight the grid position
let [xg, yg] = canvas.grid.grid.getPixelsFromGridPosition(x1, y1); let [xg, yg] = canvas.grid.grid.getPixelsFromGridPosition(x1, y1);
const subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xg, y: yg})}], {gridSpaces: true})[0] const pathUntilSpace = previousSegments.concat([{ray: new Ray(ray.A, {x: xg, y: yg})}]);
const color = this.dragRulerGetColorForDistance(startDistance + subDistance); const distance = sum(canvas.grid.measureDistances(pathUntilSpace, {gridSpaces: true}));
const color = this.dragRulerGetColorForDistance(distance);
const snapPoint = getSnapPointForToken(...canvas.grid.getTopLeft(x, y), this.draggedEntity); const snapPoint = getSnapPointForToken(...canvas.grid.getTopLeft(x, y), this.draggedEntity);
const [snapX, snapY] = getGridPositionFromPixels(snapPoint.x + 1, snapPoint.y + 1); const [snapX, snapY] = getGridPositionFromPixels(snapPoint.x + 1, snapPoint.y + 1);
@@ -318,8 +322,9 @@ export function highlightMeasurementNative(ray, startDistance, tokenShape=[{x: 0
let {x, y} = ray.project(th); let {x, y} = ray.project(th);
let [x1h, y1h] = canvas.grid.grid.getGridPositionFromPixels(x, y); let [x1h, y1h] = canvas.grid.grid.getGridPositionFromPixels(x, y);
let [xgh, ygh] = canvas.grid.grid.getPixelsFromGridPosition(x1h, y1h); let [xgh, ygh] = canvas.grid.grid.getPixelsFromGridPosition(x1h, y1h);
const subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xgh, y: ygh})}], {gridSpaces: true})[0] const pathUntilSpace = previousSegments.concat([{ray: new Ray(ray.A, {x: xgh, y: ygh})}]);
const color = this.dragRulerGetColorForDistance(startDistance + subDistance); const distance = sum(canvas.grid.measureDistances(pathUntilSpace, {gridSpaces: true}));
const color = this.dragRulerGetColorForDistance(distance);
const snapPoint = getSnapPointForToken(...canvas.grid.getTopLeft(x, y), this.draggedEntity); const snapPoint = getSnapPointForToken(...canvas.grid.getTopLeft(x, y), this.draggedEntity);
const [snapX, snapY] = getGridPositionFromPixels(snapPoint.x + 1, snapPoint.y + 1); const [snapX, snapY] = getGridPositionFromPixels(snapPoint.x + 1, snapPoint.y + 1);
highlightTokenShape.call(this, {x: snapX, y: snapY}, tokenShape, color, alpha); highlightTokenShape.call(this, {x: snapX, y: snapY}, tokenShape, color, alpha);
+3 -3
View File
@@ -54,7 +54,7 @@ export function registerKeybindings() {
function handleDeleteWaypoint() { function handleDeleteWaypoint() {
const ruler = canvas.controls.ruler; const ruler = canvas.controls.ruler;
if (!ruler.draggedEntity) if (!ruler?.draggedEntity)
return false; return false;
ruler.dragRulerDeleteWaypoint(); ruler.dragRulerDeleteWaypoint();
return true; return true;
@@ -81,7 +81,7 @@ function handleCreateWaypoint() {
function cancelDrag() { function cancelDrag() {
const ruler = canvas.controls.ruler; const ruler = canvas.controls.ruler;
if (!ruler.draggedEntity) if (!ruler?.draggedEntity)
return false; return false;
ruler.dragRulerAbortDrag(); ruler.dragRulerAbortDrag();
return true; return true;
@@ -91,7 +91,7 @@ function handleDisableSnap(event) {
disableSnap = !event.up; disableSnap = !event.up;
const ruler = canvas.controls.ruler; const ruler = canvas.controls.ruler;
if (!ruler.isDragRuler) if (!ruler?.isDragRuler)
return false; return false;
if (ruler._state !== Ruler.STATES.MEASURING) if (ruler._state !== Ruler.STATES.MEASURING)
return false; return false;
+3
View File
@@ -133,6 +133,9 @@ function onEntityDragLeftDrop(event) {
if (selectedTokens.length === 0) if (selectedTokens.length === 0)
selectedTokens.push(ruler.draggedEntity); selectedTokens.push(ruler.draggedEntity);
ruler._state = Ruler.STATES.MOVING ruler._state = Ruler.STATES.MOVING
if (ruler.draggedEntity instanceof Token && game.settings.get("core", "tokenDragPreview")) {
event.data.clones.forEach(c => c._original.updateSource({skipUpdateFog: true, defer: true}));
}
moveEntities.call(ruler, ruler.draggedEntity, selectedTokens); moveEntities.call(ruler, ruler.draggedEntity, selectedTokens);
return true return true
} }
+12
View File
@@ -7,6 +7,18 @@ export function* zip(it1, it2) {
} }
} }
export function* enumeratedZip(it1, it2) {
let i = 0;
for (const [v1, v2] of zip(it1, it2)) {
yield [i, v1, v2];
i++;
}
}
export function sum(arr) {
return arr.reduce((a, b) => a + b, 0);
}
export function getSnapPointForToken(x, y, token) { export function getSnapPointForToken(x, y, token) {
if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS) { if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS) {
return new PIXI.Point(x, y); return new PIXI.Point(x, y);