Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 94a8e6f147 | |||
| ab1f5b4c9b | |||
| 1974e6e4a3 |
@@ -1,3 +1,8 @@
|
||||
## 1.14.1
|
||||
### Bug fixes
|
||||
- The functionality Drag Ruler on gridless has been restored
|
||||
|
||||
|
||||
## 1.14.0
|
||||
### New features
|
||||
- Drag Ruler now supports hex tokens of size 5 (thanks KitCat!)
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
"id": "drag-ruler",
|
||||
"title": "Drag Ruler",
|
||||
"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": {
|
||||
"minimum": "12",
|
||||
"verified": "12",
|
||||
@@ -81,7 +81,7 @@
|
||||
},
|
||||
"socket": true,
|
||||
"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",
|
||||
"readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md",
|
||||
"changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md",
|
||||
|
||||
@@ -140,6 +140,10 @@ export function onMouseMove(event) {
|
||||
x: event.interactionData.destination.x,
|
||||
y: event.interactionData.destination.y,
|
||||
};
|
||||
if (!canvas.grid.isHex) {
|
||||
destination.x += this.rulerOffset.x;
|
||||
destination.y += this.rulerOffset.y;
|
||||
}
|
||||
|
||||
// Hide any existing Token HUD
|
||||
canvas.hud.token.clear();
|
||||
|
||||
+10
-5
@@ -137,6 +137,11 @@ function onEntityLeftDragStart(wrapped, event) {
|
||||
const ruler = canvas.controls.ruler;
|
||||
ruler.draggedEntity = 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")) {
|
||||
let options = {};
|
||||
setSnapParameterOnOptions(ruler, options);
|
||||
@@ -213,7 +218,7 @@ function applyGridlessSnapping(event) {
|
||||
const rasterWidth = 35 / canvas.stage.scale.x;
|
||||
const tokenX = event.interactionData.destination.x;
|
||||
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 terrainRulerAvailable = game.modules.get("terrain-ruler")?.active;
|
||||
@@ -237,8 +242,8 @@ function applyGridlessSnapping(event) {
|
||||
const deltaY = destination.y - rasterLocation.y;
|
||||
const rasterDistance = Math.hypot(deltaX, deltaY);
|
||||
if (rasterDistance < rasterWidth) {
|
||||
event.interactionData.destination.x = rasterLocation.x;
|
||||
event.interactionData.destination.y = rasterLocation.y;
|
||||
event.interactionData.destination.x = rasterLocation.x - ruler.rulerOffset.x;
|
||||
event.interactionData.destination.y = rasterLocation.y - ruler.rulerOffset.y;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -251,8 +256,8 @@ function applyGridlessSnapping(event) {
|
||||
return {ray};
|
||||
});
|
||||
origin = segments.pop().ray.A;
|
||||
waypointDistance = canvas.grid.measurePath(segments).reduce((a, b) => a + b);
|
||||
origin = {x: origin.x, y: origin.y};
|
||||
waypointDistance = canvas.grid.measureDistances(segments).reduce((a, b) => a + b);
|
||||
origin = {x: origin.x - ruler.rulerOffset.x, y: origin.y - ruler.rulerOffset.y};
|
||||
}
|
||||
|
||||
const deltaX = tokenX - origin.x;
|
||||
|
||||
+7
-3
@@ -391,10 +391,14 @@ export function extendRuler() {
|
||||
if (this.waypoints.filter(w => !w.isPrevious).length > 1) {
|
||||
event.preventDefault();
|
||||
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
||||
const rulerOffset = this.rulerOffset;
|
||||
|
||||
// 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)
|
||||
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);
|
||||
} else {
|
||||
this.dragRulerAbortDrag(event);
|
||||
@@ -490,8 +494,8 @@ export function extendRuler() {
|
||||
ruler.dragRulerAddWaypoint(entityCenter, {snap: false});
|
||||
const mousePosition = getPointer().getLocalPosition(canvas.tokens);
|
||||
const destination = {
|
||||
x: mousePosition.x,
|
||||
y: mousePosition.y,
|
||||
x: mousePosition.x + ruler.rulerOffset.x,
|
||||
y: mousePosition.y + ruler.rulerOffset.y,
|
||||
};
|
||||
if (measureImmediately) ruler.measure(destination, options);
|
||||
}
|
||||
|
||||
+2
-1
@@ -301,7 +301,8 @@ export function getPointer() {
|
||||
|
||||
export function getMeasurePosition() {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user