Compare commits

..

3 Commits

Author SHA1 Message Date
Manuel Vögele 94a8e6f147 Release v1.14.1 2024-07-28 09:29:39 +02:00
Manuel Vögele ab1f5b4c9b Restore rulerOffset for all uses except hex grids (fixes #332)
This restores the functinality of gridless, but it is not a proper fix. Most likely all the functionality in foundry_imports.js has to be re-imported at this point
2024-07-28 09:28:13 +02:00
Manuel Vögele 1974e6e4a3 Revert to pre-v12 maeasureDistances to restore gridless functionality 2024-07-28 09:04:41 +02:00
6 changed files with 30 additions and 11 deletions
+5
View File
@@ -1,3 +1,8 @@
## 1.14.1
### Bug fixes
- The functionality Drag Ruler on gridless has been restored
## 1.14.0 ## 1.14.0
### New features ### New features
- Drag Ruler now supports hex tokens of size 5 (thanks KitCat!) - Drag Ruler now supports hex tokens of size 5 (thanks KitCat!)
+2 -2
View File
@@ -2,7 +2,7 @@
"id": "drag-ruler", "id": "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.14.0", "version": "1.14.1",
"compatibility": { "compatibility": {
"minimum": "12", "minimum": "12",
"verified": "12", "verified": "12",
@@ -81,7 +81,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.14.0.zip", "download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.14.1.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",
+4
View File
@@ -140,6 +140,10 @@ export function onMouseMove(event) {
x: event.interactionData.destination.x, x: event.interactionData.destination.x,
y: event.interactionData.destination.y, y: event.interactionData.destination.y,
}; };
if (!canvas.grid.isHex) {
destination.x += this.rulerOffset.x;
destination.y += this.rulerOffset.y;
}
// Hide any existing Token HUD // Hide any existing Token HUD
canvas.hud.token.clear(); canvas.hud.token.clear();
+10 -5
View File
@@ -137,6 +137,11 @@ function onEntityLeftDragStart(wrapped, event) {
const ruler = canvas.controls.ruler; const ruler = canvas.controls.ruler;
ruler.draggedEntity = this; ruler.draggedEntity = this;
const entityCenter = getEntityCenter(this); const entityCenter = getEntityCenter(this);
const isV11 = game.release.generation === 11;
ruler.rulerOffset = {
x: isV11 ? entityCenter.x - event.interactionData.origin.x : 0,
y: isV11 ? entityCenter.y - event.interactionData.origin.y : 0,
};
if (game.settings.get(settingsKey, "autoStartMeasurement")) { if (game.settings.get(settingsKey, "autoStartMeasurement")) {
let options = {}; let options = {};
setSnapParameterOnOptions(ruler, options); setSnapParameterOnOptions(ruler, options);
@@ -213,7 +218,7 @@ function applyGridlessSnapping(event) {
const rasterWidth = 35 / canvas.stage.scale.x; const rasterWidth = 35 / canvas.stage.scale.x;
const tokenX = event.interactionData.destination.x; const tokenX = event.interactionData.destination.x;
const tokenY = event.interactionData.destination.y; const tokenY = event.interactionData.destination.y;
const destination = {x: tokenX, y: tokenY}; const destination = {x: tokenX + ruler.rulerOffset.x, y: tokenY + ruler.rulerOffset.y};
const ranges = getRangesFromSpeedProvider(ruler.draggedEntity); const ranges = getRangesFromSpeedProvider(ruler.draggedEntity);
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active; const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active;
@@ -237,8 +242,8 @@ 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.interactionData.destination.x = rasterLocation.x; event.interactionData.destination.x = rasterLocation.x - ruler.rulerOffset.x;
event.interactionData.destination.y = rasterLocation.y; event.interactionData.destination.y = rasterLocation.y - ruler.rulerOffset.y;
} }
} }
} else { } else {
@@ -251,8 +256,8 @@ function applyGridlessSnapping(event) {
return {ray}; return {ray};
}); });
origin = segments.pop().ray.A; origin = segments.pop().ray.A;
waypointDistance = canvas.grid.measurePath(segments).reduce((a, b) => a + b); waypointDistance = canvas.grid.measureDistances(segments).reduce((a, b) => a + b);
origin = {x: origin.x, y: origin.y}; origin = {x: origin.x - ruler.rulerOffset.x, y: origin.y - ruler.rulerOffset.y};
} }
const deltaX = tokenX - origin.x; const deltaX = tokenX - origin.x;
+7 -3
View File
@@ -391,10 +391,14 @@ export function extendRuler() {
if (this.waypoints.filter(w => !w.isPrevious).length > 1) { if (this.waypoints.filter(w => !w.isPrevious).length > 1) {
event.preventDefault(); event.preventDefault();
const mousePosition = getPointer().getLocalPosition(canvas.tokens); const mousePosition = getPointer().getLocalPosition(canvas.tokens);
const rulerOffset = this.rulerOffset;
// Options are not passed to _removeWaypoint in vanilla Foundry. // Options are not passed to _removeWaypoint in vanilla Foundry.
// Send them in case other modules have overriden that behavior and accept an options parameter (Toggle Snap to Grid) // Send them in case other modules have overriden that behavior and accept an options parameter (Toggle Snap to Grid)
this._removeWaypoint({x: mousePosition.x, y: mousePosition.y}, options); this._removeWaypoint(
{x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y},
options,
);
this.performPostPathfindingActions(options); this.performPostPathfindingActions(options);
} else { } else {
this.dragRulerAbortDrag(event); this.dragRulerAbortDrag(event);
@@ -490,8 +494,8 @@ export function extendRuler() {
ruler.dragRulerAddWaypoint(entityCenter, {snap: false}); ruler.dragRulerAddWaypoint(entityCenter, {snap: false});
const mousePosition = getPointer().getLocalPosition(canvas.tokens); const mousePosition = getPointer().getLocalPosition(canvas.tokens);
const destination = { const destination = {
x: mousePosition.x, x: mousePosition.x + ruler.rulerOffset.x,
y: mousePosition.y, y: mousePosition.y + ruler.rulerOffset.y,
}; };
if (measureImmediately) ruler.measure(destination, options); if (measureImmediately) ruler.measure(destination, options);
} }
+2 -1
View File
@@ -301,7 +301,8 @@ export function getPointer() {
export function getMeasurePosition() { export function getMeasurePosition() {
const mousePosition = getPointer().getLocalPosition(canvas.tokens); const mousePosition = getPointer().getLocalPosition(canvas.tokens);
const measurePosition = {x: mousePosition.x, y: mousePosition.y}; const rulerOffset = canvas.controls.ruler.rulerOffset;
const measurePosition = {x: mousePosition.x + rulerOffset.x, y: mousePosition.y + rulerOffset.y};
return measurePosition; return measurePosition;
} }