Skip to content

Commit

Permalink
Merge branch 'feature/movement-color' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
caewok committed Jan 8, 2024
2 parents 92653f5 + 668b077 commit 7f5b18f
Show file tree
Hide file tree
Showing 7 changed files with 437 additions and 32 deletions.
7 changes: 7 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@
"elevationruler.settings.enable-token-ruler.name": "Use Token Ruler",
"elevationruler.settings.enable-token-ruler.hint": "Display the ruler when dragging tokens.",

"elevationruler.settings.token-ruler-highlighting.name": "Use Token Speed Highlighting",
"elevationruler.settings.token-ruler-highlighting.hint": "When using the ruler, use different colors for token walk/dash/max distance.",

"elevationruler.settings.token-speed-property.name": "Token Speed Property",
"elevationruler.settings.token-speed-property.hint": "For token speed highlighting, this is the property representing token speed.",


"elevationruler.controls.prefer-token-elevation.name": "Prefer Token Elevation"
}
7 changes: 7 additions & 0 deletions scripts/Token.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ async function _onDragLeftDrop(wrapped, event) {
// End the ruler measurement
const ruler = canvas.controls.ruler;
if ( !ruler.active ) return wrapped(event);
const destination = event.interactionData.destination;

// Ensure the cursor destination is within bounds
if ( !canvas.dimensions.rect.contains(destination.x, destination.y) ) {
ruler._onMouseUp(event);
return false;
}
await ruler.moveToken();
ruler._onMouseUp(event);
}
Expand Down
95 changes: 95 additions & 0 deletions scripts/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,98 @@ Hooks.once("init", function() {
MODULES_ACTIVE.LEVELS = game.modules.get("levels")?.active;
MODULES_ACTIVE.ELEVATED_VISION = game.modules.get("elevatedvision")?.active;
});

/**
* Below Taken from Drag Ruler
*/
/*
MIT License
Copyright (c) 2021 Manuel Vögele
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

export const SPEED = {
ATTRIBUTE: "",
MULTIPLIER: 0
};

// Avoid testing for the system id each time.
Hooks.once("init", function() {
SPEED.ATTRIBUTE = defaultSpeedAttribute();
SPEED.MULTIPLIER = defaultDashMultiplier();
});

function defaultSpeedAttribute() {
switch (game.system.id) {
case "CoC7":
return "actor.system.attribs.mov.value";
case "dcc":
case "sfrpg":
return "actor.system.attributes.speed.value";
case "dnd4e":
return "actor.system.movement.walk.value";
case "dnd5e":
return "actor.system.attributes.movement.walk";
case "lancer":
return "actor.system.derived.speed";
case "pf1":
case "D35E":
return "actor.system.attributes.speed.land.total";
case "shadowrun5e":
return "actor.system.movement.walk.value";
case "swade":
return "actor.system.stats.speed.adjusted";
case "ds4":
return "actor.system.combatValues.movement.total";
case "splittermond":
return "actor.derivedValues.speed.value";
case "wfrp4e":
return "actor.system.details.move.walk";
case "crucible":
return "actor.system.movement.stride";
}
return "";
}

function defaultDashMultiplier() {
switch (game.system.id) {
case "dcc":
case "dnd4e":
case "dnd5e":
case "lancer":
case "pf1":
case "D35E":
case "sfrpg":
case "shadowrun5e":
case "ds4":
return 2;
case "CoC7":
return 5;
case "splittermond":
return 3;
case "wfrp4e":
return 2;
case "crucible":
case "swade":
return 0;
}
return 0;
}
14 changes: 7 additions & 7 deletions scripts/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ ui
import { Settings } from "./settings.js";
import { initializePatching, PATCHER, registerDragRuler } from "./patching.js";
import { MODULE_ID } from "./const.js";
import { iterateGridUnderLine } from "./ruler.js";

import { registerGeometry } from "./geometry/registration.js";

Hooks.once("init", function() {
// Cannot access localization until init.
PREFER_TOKEN_CONTROL.title = game.i18n.localize(PREFER_TOKEN_CONTROL.title);
registerGeometry();
game.modules.get(MODULE_ID).api = {
iterateGridUnderLine,
PATCHER
};
});

// Setup is after init; before ready.
Expand All @@ -38,13 +45,6 @@ const PREFER_TOKEN_CONTROL = {
toggle: true
};

Hooks.once("init", function() {
// Cannot access localization until init.
PREFER_TOKEN_CONTROL.title = game.i18n.localize(PREFER_TOKEN_CONTROL.title);
game.modules.get(MODULE_ID).api = {
PATCHER
};
});

// Render the prefer token control if that setting is enabled
Hooks.on("getSceneControlButtons", controls => {
Expand Down
Loading

0 comments on commit 7f5b18f

Please sign in to comment.