Compare commits

...

8 Commits

7 changed files with 31 additions and 7 deletions
+11
View File
@@ -1,3 +1,14 @@
## 1.6.2
### Bugfixes
- The reset movement history button now resets the movement history for all players, not just for the GM
## 1.6.1
### API
- Added `onMovementHistoryUpdate` callback to Speed Providers, that allows them to perform game systems specific improvements to the movement history
- Added `dragRuler.resetMovementHistory` that clears the stored movement history for a token.
## 1.6.0 ## 1.6.0
### Performance ### Performance
- Greatly increased the performance when playing on huge maps and when moving many tokens at once. - Greatly increased the performance when playing on huge maps and when moving many tokens at once.
+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.6.0", "version": "1.6.2",
"minimumCoreVersion" : "0.7.9", "minimumCoreVersion" : "0.7.9",
"compatibleCoreVersion" : "0.7.9", "compatibleCoreVersion" : "0.7.9",
"authors": [ "authors": [
@@ -49,7 +49,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.6.0.zip", "download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.6.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",
+1 -1
View File
@@ -64,7 +64,6 @@ async function animateTokens(tokens, draggedToken, draggedRays, wasPaused) {
return {token, rays: offsetRays, dx, dy}; return {token, rays: offsetRays, dx, dy};
}); });
trackRays(tokenAnimationData.map(({token}) => token), tokenAnimationData.map(({rays}) => rays));
for (const {token, rays} of tokenAnimationData) { for (const {token, rays} of tokenAnimationData) {
token._noAnimate = true; token._noAnimate = true;
} }
@@ -88,6 +87,7 @@ async function animateTokens(tokens, draggedToken, draggedRays, wasPaused) {
for (const {token} of tokenAnimationData) { for (const {token} of tokenAnimationData) {
token._noAnimate = false; token._noAnimate = false;
} }
trackRays(tokenAnimationData.map(({token}) => token), tokenAnimationData.map(({rays}) => rays));
} }
function calculateTokenOffset(tokenA, tokenB) { function calculateTokenOffset(tokenA, tokenB) {
+1
View File
@@ -22,6 +22,7 @@ Hooks.once("init", () => {
getMovedDistanceFromToken, getMovedDistanceFromToken,
registerModule, registerModule,
registerSystem, registerSystem,
resetMovementHistory,
} }
}) })
+3 -3
View File
@@ -86,8 +86,8 @@ export async function resetMovementHistory(combat, combatantId) {
const dragRulerFlags = combatant.flags.dragRuler; const dragRulerFlags = combatant.flags.dragRuler;
if (!dragRulerFlags) if (!dragRulerFlags)
return; return;
dragRulerFlags.passedWaypoints = undefined; dragRulerFlags.passedWaypoints = null;
dragRulerFlags.trackedRound = undefined; dragRulerFlags.trackedRound = null;
dragRulerFlags.rulerState = undefined; dragRulerFlags.rulerState = null;
await updateCombatantDragRulerFlags(combat, [{_id: combatantId, dragRulerFlags}]); await updateCombatantDragRulerFlags(combat, [{_id: combatantId, dragRulerFlags}]);
} }
+5 -1
View File
@@ -1,3 +1,5 @@
import {currentSpeedProvider} from "./api.js";
let socket; let socket;
Hooks.once("socketlib.ready", () => { Hooks.once("socketlib.ready", () => {
@@ -7,7 +9,9 @@ Hooks.once("socketlib.ready", () => {
export function updateCombatantDragRulerFlags(combat, updates) { export function updateCombatantDragRulerFlags(combat, updates) {
const combatId = combat.id; const combatId = combat.id;
return socket.executeAsGM(_socketUpdateCombatantDragRulerFlags, combatId, updates); // TODO Check if canvas.tokens.get is still neccessary in future foundry versions
return socket.executeAsGM(_socketUpdateCombatantDragRulerFlags, combatId, updates)
.then(() => currentSpeedProvider.onMovementHistoryUpdate(updates.map(update => canvas.tokens.get(combat.getCombatant(update._id).token._id))));
} }
async function _socketUpdateCombatantDragRulerFlags(combatId, updates) { async function _socketUpdateCombatantDragRulerFlags(combatId, updates) {
+8
View File
@@ -84,6 +84,14 @@ export class SpeedProvider {
return true return true
} }
/**
* This hook is being called after Drag Ruler has updated the movement history for one or more tokens.
* It'll receive an array of tokens that have been updated.
* If your speed provider is storing any additional values that are relevant for the movement history, this function should
* await until those updates have completed inside foundry.
*/
async onMovementHistoryUpdate(tokens) {}
/** /**
* Returns the value that is currently set for the setting registered with the provided settingId. * Returns the value that is currently set for the setting registered with the provided settingId.
* *