Add keybinding for the pathfinding feature
This commit is contained in:
@@ -40,6 +40,10 @@
|
||||
"moveWithoutAnimation": {
|
||||
"name": "Token animation deaktivieren",
|
||||
"hint": "Wenn diese Taste gedrückt wird, während ein Token fallen gelassen wird, bewegt es sich ohne Animation zum Zielort."
|
||||
},
|
||||
"togglePathfinding": {
|
||||
"name": "Wegfindung umschalten",
|
||||
"hint": "Wenn diese Taste gedrückt gehalten wird, während ein Token gezogen wird, wird die Wegfindung vorübergehend aktiviert/deaktiviert"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
"moveWithoutAnimation": {
|
||||
"name": "Disable token animation",
|
||||
"hint": "When being held while dropping a token, the token will move to the target location without animating"
|
||||
},
|
||||
"togglePathfinding": {
|
||||
"name": "Toggle pathfinding",
|
||||
"hint": "When being held while dragging a token, the pathfinding functionality will be temporarily enabled/disabled"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
|
||||
@@ -3,6 +3,7 @@ import {getMeasurePosition, setSnapParameterOnOptions} from "./util.js";
|
||||
|
||||
export let disableSnap = false;
|
||||
export let moveWithoutAnimation = false;
|
||||
export let togglePathfinding = false;
|
||||
|
||||
export function registerKeybindings() {
|
||||
game.keybindings.register(settingsKey, "cancelDrag", {
|
||||
@@ -50,6 +51,16 @@ export function registerKeybindings() {
|
||||
}],
|
||||
precedence: -1,
|
||||
});
|
||||
|
||||
if (game.settings.get(settingsKey, "allowPathfinding")) {
|
||||
game.keybindings.register(settingsKey, "togglePathfinding", {
|
||||
name: "drag-ruler.keybindings.togglePathfinding.name",
|
||||
hint: "drag-ruler.keybindings.togglePathfinding.hint",
|
||||
onDown: handleTogglePathfinding,
|
||||
onUp: handleTogglePathfinding,
|
||||
precedence: -1,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function handleDeleteWaypoint() {
|
||||
@@ -103,3 +114,7 @@ function handleDisableSnap(event) {
|
||||
function handleMoveWithoutAnimation(event) {
|
||||
moveWithoutAnimation = !event.up;
|
||||
}
|
||||
|
||||
function handleTogglePathfinding(event) {
|
||||
togglePathfinding = !event.up;
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
import {getCenterFromGridPositionObj} from "./foundry_fixes.js";
|
||||
import { togglePathfinding } from "./keybindings.js";
|
||||
import {settingsKey} from "./settings.js";
|
||||
|
||||
// TODO Wipe cache if walls layer is being modified
|
||||
@@ -7,7 +8,7 @@ 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")
|
||||
return game.settings.get(settingsKey, "autoPathfinding") != togglePathfinding;
|
||||
}
|
||||
|
||||
function get_node(pos, initialize=true) {
|
||||
|
||||
@@ -89,6 +89,7 @@ export function registerSettings() {
|
||||
config: true,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
onChange: () => location.reload(),
|
||||
});
|
||||
|
||||
game.settings.register(settingsKey, "autoPathfinding", {
|
||||
|
||||
Reference in New Issue
Block a user