diff --git a/lang/en.json b/lang/en.json index b39dfd2..b75960f 100644 --- a/lang/en.json +++ b/lang/en.json @@ -51,6 +51,10 @@ "name": "Automatically start measuring", "hint": "If enabled, Drag Ruler will start measuring as soon as the token is being dragged. If disabled, Drag Ruler will remain inactive and will only start measuring once the button to add a waypoint is being pressed." }, + "autoPathfinding": { + "name": "Pathfinding by default", + "hint": "If enabled, dragging a token will automatically use a pathfinding ruler" + }, "enableMovementHistory": { "name": "Enable movement history during combat", "hint": "If enabled, Drag Ruler will remember the path a token took during it's turn in combat and will display it when you pick the token back up." diff --git a/src/foundry_imports.js b/src/foundry_imports.js index 9452ea8..4fef1ec 100644 --- a/src/foundry_imports.js +++ b/src/foundry_imports.js @@ -4,6 +4,7 @@ import {Line} from "./geometry.js"; import {disableSnap, moveWithoutAnimation} from "./keybindings.js"; import {trackRays} from "./movement_tracking.js" import {find_path} from "./pathfinding.js"; +import {settingsKey} from "./settings.js"; import {recalculate} from "./socket.js"; import {applyTokenSizeOffset, enumeratedZip, getSnapPointForEntity, getSnapPointForToken, getTokenShape, highlightTokenShape, sum} from "./util.js"; @@ -132,7 +133,7 @@ function scheduleMeasurement(destination, event) { const mt = event._measureTime || 0; const originalEvent = event.data.originalEvent; if (Date.now() - mt > measurementInterval) { - this.measure(destination, {snap: !disableSnap, pathfinding: game.keyboard.isDown("y")}); + this.measure(destination, {snap: !disableSnap, pathfinding: game.settings.get(settingsKey, "autoPathfinding") != game.keyboard.isDown("y")}); event._measureTime = Date.now(); this._state = Ruler.STATES.MEASURING; cancelScheduledMeasurement.call(this); diff --git a/src/settings.js b/src/settings.js index 5155f5d..6ac17f8 100644 --- a/src/settings.js +++ b/src/settings.js @@ -82,6 +82,15 @@ export function registerSettings() { default: true, }); + game.settings.register(settingsKey, "autoPathfinding", { + name: "drag-ruler.settings.autoPathfinding.name", + hint: "drag-ruler.settings.autoPathfinding.hint", + scpoe: "client", + config: true, + type: Boolean, + defualt: true, + }); + game.settings.register(settingsKey, "lastTerrainRulerHintTime", { config: false, type: Number,