Add setting to forbid the usage of pathfinding
This commit is contained in:
@@ -43,6 +43,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
"allowPathfinding": {
|
||||||
|
"name": "Wegfindung aktivieren",
|
||||||
|
"hint": "Aktiviert Drag Ruler's Wegfindungsfunktion. Bitte beachte, dass die Wegfindung Wege durch unerkundeten Nebel des Kriegs und Ätherische Wände berechnen kann. Dies kann deinen Spielern Geheimnisse lüften, von denen sie noch nicht erfahren sollten."
|
||||||
|
},
|
||||||
"alwaysShowSpeedForPCs": {
|
"alwaysShowSpeedForPCs": {
|
||||||
"name": "Geschwindigkeit von Spielercharakteren für jeden anzeigen",
|
"name": "Geschwindigkeit von Spielercharakteren für jeden anzeigen",
|
||||||
"hint": "Wenn diese Einstellung aktiviert ist wird die Färbung der hervorgehobenen Felder bei Spielercharakteren allen Spielern angezeigt, selbst wenn diese keinen Zugriff auf den Charakterbogen haben."
|
"hint": "Wenn diese Einstellung aktiviert ist wird die Färbung der hervorgehobenen Felder bei Spielercharakteren allen Spielern angezeigt, selbst wenn diese keinen Zugriff auf den Charakterbogen haben."
|
||||||
|
|||||||
@@ -43,6 +43,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
"allowPathfinding": {
|
||||||
|
"name": "Enable pathfinding feature",
|
||||||
|
"hint": "Enables Drag Ruler's pathfinding functionality in this world. Be aware that pathfinding can route through unexplored fog of war and Ethereal Walls, which might reveal secrets to your players ahead of time."
|
||||||
|
},
|
||||||
"alwaysShowSpeedForPCs": {
|
"alwaysShowSpeedForPCs": {
|
||||||
"name": "Show PC speed to everyone",
|
"name": "Show PC speed to everyone",
|
||||||
"hint": "If enabled the coloring based on actor speed for player characters will shown to everyone, even if they don't have observer permission for the character sheet."
|
"hint": "If enabled the coloring based on actor speed for player characters will shown to everyone, even if they don't have observer permission for the character sheet."
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {getCenterFromGridPositionObj, getGridPositionFromPixels, getGridPosition
|
|||||||
import {Line} from "./geometry.js";
|
import {Line} from "./geometry.js";
|
||||||
import {disableSnap, moveWithoutAnimation} from "./keybindings.js";
|
import {disableSnap, moveWithoutAnimation} from "./keybindings.js";
|
||||||
import {trackRays} from "./movement_tracking.js"
|
import {trackRays} from "./movement_tracking.js"
|
||||||
import {find_path} from "./pathfinding.js";
|
import {find_path, is_pathfinding_enabled} from "./pathfinding.js";
|
||||||
import {settingsKey} from "./settings.js";
|
import {settingsKey} from "./settings.js";
|
||||||
import {recalculate} from "./socket.js";
|
import {recalculate} from "./socket.js";
|
||||||
import {applyTokenSizeOffset, enumeratedZip, getSnapPointForEntity, getSnapPointForToken, getTokenShape, highlightTokenShape, sum} from "./util.js";
|
import {applyTokenSizeOffset, enumeratedZip, getSnapPointForEntity, getSnapPointForToken, getTokenShape, highlightTokenShape, sum} from "./util.js";
|
||||||
@@ -133,7 +133,7 @@ function scheduleMeasurement(destination, event) {
|
|||||||
const mt = event._measureTime || 0;
|
const mt = event._measureTime || 0;
|
||||||
const originalEvent = event.data.originalEvent;
|
const originalEvent = event.data.originalEvent;
|
||||||
if (Date.now() - mt > measurementInterval) {
|
if (Date.now() - mt > measurementInterval) {
|
||||||
this.measure(destination, {snap: !disableSnap, pathfinding: game.settings.get(settingsKey, "autoPathfinding") != game.keyboard.isDown("y")});
|
this.measure(destination, {snap: !disableSnap, pathfinding: is_pathfinding_enabled()});
|
||||||
event._measureTime = Date.now();
|
event._measureTime = Date.now();
|
||||||
this._state = Ruler.STATES.MEASURING;
|
this._state = Ruler.STATES.MEASURING;
|
||||||
cancelScheduledMeasurement.call(this);
|
cancelScheduledMeasurement.call(this);
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
import {getCenterFromGridPositionObj} from "./foundry_fixes.js";
|
import {getCenterFromGridPositionObj} from "./foundry_fixes.js";
|
||||||
|
import {settingsKey} from "./settings.js";
|
||||||
|
|
||||||
// TODO Wipe cache if walls layer is being modified
|
// TODO Wipe cache if walls layer is being modified
|
||||||
let cached_nodes = undefined;
|
let cached_nodes = undefined;
|
||||||
|
|
||||||
|
export function is_pathfinding_enabled() {
|
||||||
|
if (!game.settings.get(settingsKey, "allowPathfinding"))
|
||||||
|
return false;
|
||||||
|
return game.settings.get(settingsKey, "autoPathfinding") != game.keyboard.isDown("y")
|
||||||
|
}
|
||||||
|
|
||||||
function get_node(pos, initialize=true) {
|
function get_node(pos, initialize=true) {
|
||||||
if (!cached_nodes)
|
if (!cached_nodes)
|
||||||
// TODO Check if ceil is the right thing to do here
|
// TODO Check if ceil is the right thing to do here
|
||||||
|
|||||||
@@ -82,6 +82,15 @@ export function registerSettings() {
|
|||||||
default: true,
|
default: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
game.settings.register(settingsKey, "allowPathfinding", {
|
||||||
|
name: "drag-ruler.settings.allowPathfinding.name",
|
||||||
|
hint: "drag-ruler.settings.allowPathfinding.hint",
|
||||||
|
scope: "world",
|
||||||
|
config: true,
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
});
|
||||||
|
|
||||||
game.settings.register(settingsKey, "autoPathfinding", {
|
game.settings.register(settingsKey, "autoPathfinding", {
|
||||||
name: "drag-ruler.settings.autoPathfinding.name",
|
name: "drag-ruler.settings.autoPathfinding.name",
|
||||||
hint: "drag-ruler.settings.autoPathfinding.hint",
|
hint: "drag-ruler.settings.autoPathfinding.hint",
|
||||||
|
|||||||
Reference in New Issue
Block a user