diff --git a/CHANGELOG.md b/CHANGELOG.md index f7c970d..add1184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## 1.11.4 +### Bugfixes +- When changing the measurement mode via a keybinding (toggle snaping or toggle pathfinding) the updated ruler will now be sent to other players immediately +- Fixed a bug that incorrectly showed a ruler to be snapped to other players despite the ruler not being snapped +- Fixed a bug that could cause a token to move to an incorrect location if the token was being dragged and dropped very rapidly +- Drag Ruler's token movement animations can now be properly waited for (this improves the interaction with modules like sequencer) + +### Translation +- Updated Spanish translation (thanks to Viriato139ac#342) + + ## 1.11.3 ### Bugfixes - The setting to automatically start pathfinding is now visible to players again (this was a regression introduced in 1.11.2) diff --git a/js/foundry_imports.js b/js/foundry_imports.js index 80ab9ad..fa709c2 100644 --- a/js/foundry_imports.js +++ b/js/foundry_imports.js @@ -91,7 +91,7 @@ async function animateEntities(entities, draggedEntity, draggedRays, wasPaused) }); await draggedEntity.scene.updateEmbeddedDocuments(draggedEntity.constructor.embeddedName, updates, {animate}); if (animate) - await Promise.all(entityPaths.map(({entity, path}) => entity.animateMovement(path))); + await Promise.all(entityPaths.map(({entity}) => CanvasAnimation.getAnimation(entity.movementAnimationName)?.promise)); // This is a flag of the "Monk's Active Tile Triggers" module that signals that the movement should be cancelled early if (this.cancelMovement) { diff --git a/js/keybindings.js b/js/keybindings.js index c2747e2..b3ef09d 100644 --- a/js/keybindings.js +++ b/js/keybindings.js @@ -107,6 +107,7 @@ function handleDisableSnap(event) { return false; ruler.measure(getMeasurePosition(), {snap: !disableSnap}); + ruler.dragRulerSendState(); return false; } @@ -124,5 +125,6 @@ function handleTogglePathfinding(event) { return false; ruler.measure(getMeasurePosition(), {snap: !disableSnap}); + ruler.dragRulerSendState(); return false; } diff --git a/js/main.js b/js/main.js index 924afc1..2e69e5c 100644 --- a/js/main.js +++ b/js/main.js @@ -101,6 +101,7 @@ async function tokenLayerUndoHistory(wrapped) { function onEntityLeftDragStart(wrapped, event) { wrapped(event); + console.warn("start", Date.now()); const isToken = this instanceof Token; const ruler = canvas.controls.ruler ruler.draggedEntity = this; @@ -131,6 +132,7 @@ function onEntityLeftDragMove(wrapped, event) { function onEntityDragLeftDrop(event) { const ruler = canvas.controls.ruler + console.warn("stop", ruler._state, Date.now()); if (!ruler.isDragRuler) { ruler.draggedEntity = undefined; return false @@ -141,6 +143,9 @@ function onEntityDragLeftDrop(event) { // This can happen if the user presses ESC during drag (maybe there are other ways too) if (selectedTokens.length === 0) selectedTokens.push(ruler.draggedEntity); + // This can happen if the ruler is being dragged so rapidly that the drag move handler hasn't been called before dropping + if (ruler._state === Ruler.STATES.STARTING) + onMouseMove.call(ruler, event); ruler._state = Ruler.STATES.MOVING moveEntities.call(ruler, ruler.draggedEntity, selectedTokens); return true diff --git a/js/ruler.js b/js/ruler.js index 139fb7b..770914b 100644 --- a/js/ruler.js +++ b/js/ruler.js @@ -61,6 +61,9 @@ export function extendRuler() { measure(destination, options={}) { if (this.isDragRuler) { + // If this is the ruler of a remote user take the waypoints as they were transmitted and don't apply any additional snapping to them + if (this.user !== game.user) + options.snap = false; return measure.call(this, destination, options); } else { @@ -199,6 +202,12 @@ export function extendRuler() { if (measureImmediately) ruler.measure(destination, options); } + + dragRulerSendState() { + game.user.broadcastActivity({ + ruler: this.toJSON() + }); + } } Ruler = DragRulerRuler; diff --git a/lang/es.json b/lang/es.json index 308aced..c834583 100644 --- a/lang/es.json +++ b/lang/es.json @@ -44,9 +44,17 @@ "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" + }, + "togglePathfinding": { + "name": "Conmutar búsqueda de camino", + "hint": "Cuando se presione al arrastrar un icono, la funcionalidad de búsqueda de camino será temporalmente habilitada/deshabilitada" } }, "settings": { + "allowPathfinding": { + "name": "Permitir búsqueda de camino a los jugadores", + "hint": "Permite a los jugadores usar en este mundo la funcionalidad de búsqueda de camino. Tenga cuidado porque la ruta puede transcurrir por lugares con niebla de guerra o muros invisibles, lo que podrá revelar algunos secretos a los jugadores antes de tiempo" + }, "alwaysShowSpeedForPCs": { "name": "Mostrar velocidad de los PJs a todo el mundo", "hint": "Si se habilita, se mostrará a todo el mundo los códigos de colores de las rutas de los PJs, incluso si no tienen permisos de observador para ese personaje" @@ -55,6 +63,10 @@ "name": "Comenzar a medir automáticamente", "hint": "Si se habilita, Drag Ruler comenzará a medir en cuanto se comience a arrastrar un icono. Si se deshabilita, Drag Ruler permanecerá inactivo y comenzará a medir únicamente cuando se presione el botón configurado para añadir un nuevo punto de ruta" }, + "autoPathfinding": { + "name": "Búsqueda de camino por defecto", + "hint": "Si se habilita, al arrastrar un icono se usará automáticamente la regla de búsqueda de camino" + }, "enableMovementHistory": { "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" diff --git a/module.json b/module.json index 51cbd84..8c879d9 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "name": "drag-ruler", "title": "Drag Ruler", "description": "When dragging a token displays a ruler showing how far you've moved that token.", - "version": "1.11.3", + "version": "1.11.4", "minimumCoreVersion" : "9.245", "compatibleCoreVersion" : "9", "authors": [ @@ -65,7 +65,7 @@ ], "socket": true, "url": "https://github.com/manuelVo/foundryvtt-drag-ruler", - "download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.11.3.zip", + "download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.11.4.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",