Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 605f4371e6 | |||
| 0ad03ad5f7 | |||
| 035cfb8969 | |||
| 90a25f467b | |||
| ab85b98a5c | |||
| 1669edf757 | |||
| d1b5f7c39b | |||
| 24f1e78092 | |||
| 854903a314 | |||
| 232eca74de |
@@ -1,3 +1,9 @@
|
|||||||
|
## 1.8.2
|
||||||
|
### Compatibility
|
||||||
|
- The generic speed provider defaults have been updated for lance 1.0 (thanks to BoltsJ!)
|
||||||
|
- Eliminated a deprecation warning when both Drag Ruler and Hex Size Support are enabled (thanks Argonius-Angelus!)
|
||||||
|
|
||||||
|
|
||||||
## 1.8.1
|
## 1.8.1
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- Fixed a bug where the function that was bound to the spacebar key wouldn't work correctly when the "Toggle Snap To Grid" module was enabled
|
- Fixed a bug where the function that was bound to the spacebar key wouldn't work correctly when the "Toggle Snap To Grid" module was enabled
|
||||||
|
|||||||
@@ -37,10 +37,16 @@ Drag Ruler will work with all Foundry VTT game systems. However some game system
|
|||||||
|
|
||||||
The game systems that offer Drag Ruler integration are:
|
The game systems that offer Drag Ruler integration are:
|
||||||
- Cypher System (starting with version 1.13.0)
|
- Cypher System (starting with version 1.13.0)
|
||||||
|
- GURPS 4th Edition Game Aid (Unofficial) (starting with version 0.9.1)
|
||||||
- Ironclaw Second Edition (starting with version 0.2.2)
|
- Ironclaw Second Edition (starting with version 0.2.2)
|
||||||
|
- Lancer (via the module [Lancer Speed Provider](https://foundryvtt.com/packages/lancer-speed-provider))
|
||||||
- Pathfinder 1 (starting with version 0.77.3)
|
- Pathfinder 1 (starting with version 0.77.3)
|
||||||
- Pathfinder 2e (via the module [PF2E Drag Ruler Integration](https://foundryvtt.com/packages/pf2e-dragruler/))
|
- Pathfinder 2e (via the module [PF2E Drag Ruler Integration](https://foundryvtt.com/packages/pf2e-dragruler/))
|
||||||
|
- Shadowrun 5th Edition (via the module [Drag Ruler Integration for Shadowrun 5E](https://foundryvtt.com/packages/drag-ruler-integration-for-shadowrun-5e))
|
||||||
|
- Starfinder (via the module [Starfinder Drag Ruler Integration](https://foundryvtt.com/packages/starfinder-drag-ruler))
|
||||||
|
- Stargate RPG (starting with version 1.6.0)
|
||||||
- Tagmar RPG (starting with version 1.1.4)
|
- Tagmar RPG (starting with version 1.1.4)
|
||||||
|
- TheWitcherTRPG (starting with version 0.0.62)
|
||||||
- Tormenta20 (starting with version 1.1.37)
|
- Tormenta20 (starting with version 1.1.37)
|
||||||
- Shadow of the Demon Lord (starting with version 1.7.15)
|
- Shadow of the Demon Lord (starting with version 1.7.15)
|
||||||
- Wasteland Ventures (starting with version 0.1.0)
|
- Wasteland Ventures (starting with version 0.1.0)
|
||||||
|
|||||||
+9
-9
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "drag-ruler",
|
"name": "drag-ruler-alpha",
|
||||||
"title": "Drag Ruler",
|
"title": "Drag Ruler (Alpha Branch)",
|
||||||
"description": "When dragging a token displays a ruler showing how far you've moved that token.",
|
"description": "When dragging a token displays a ruler showing how far you've moved that token.",
|
||||||
"version": "1.8.1",
|
"version": "1.8.3-alpha1",
|
||||||
"minimumCoreVersion" : "0.8.5",
|
"minimumCoreVersion" : "0.8.5",
|
||||||
"compatibleCoreVersion" : "0.8.8",
|
"compatibleCoreVersion" : "0.8.9",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Manuel Vögele",
|
"name": "Manuel Vögele",
|
||||||
@@ -59,10 +59,10 @@
|
|||||||
],
|
],
|
||||||
"socket": true,
|
"socket": true,
|
||||||
"url": "https://github.com/manuelVo/foundryvtt-drag-ruler",
|
"url": "https://github.com/manuelVo/foundryvtt-drag-ruler",
|
||||||
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/v1.8.1.zip",
|
"download": "https://github.com/manuelVo/foundryvtt-drag-ruler/archive/alpha.zip",
|
||||||
"manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/master/module.json",
|
"manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-drag-ruler/alpha/module.json",
|
||||||
"readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/README.md",
|
"readme": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/alpha/README.md",
|
||||||
"changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/master/CHANGELOG.md",
|
"changelog": "https://github.com/manuelVo/foundryvtt-drag-ruler/blob/alpha/CHANGELOG.md",
|
||||||
"bugs": "https://github.com/manuelVo/foundryvtt-drag-ruler/issues",
|
"bugs": "https://github.com/manuelVo/foundryvtt-drag-ruler/issues",
|
||||||
"allowBugReporter": true
|
"allowBugReporter": false
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -116,6 +116,20 @@ export function getCostFromSpeedProvider(token, area, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getColorForDistanceAndToken(distance, token, ranges=null) {
|
||||||
|
if (!ranges) {
|
||||||
|
ranges = getRangesFromSpeedProvider(token);
|
||||||
|
}
|
||||||
|
if (ranges.length === 0)
|
||||||
|
return this.color;
|
||||||
|
const currentRange = ranges.reduce((minRange, currentRange) => {
|
||||||
|
if (distance <= currentRange.range && currentRange.range < minRange.range)
|
||||||
|
return currentRange;
|
||||||
|
return minRange;
|
||||||
|
}, {range: Infinity, color: getUnreachableColorFromSpeedProvider()});
|
||||||
|
return currentRange.color;
|
||||||
|
}
|
||||||
|
|
||||||
export function getMovedDistanceFromToken(token) {
|
export function getMovedDistanceFromToken(token) {
|
||||||
const history = getMovementHistory(token);
|
const history = getMovementHistory(token);
|
||||||
const segments = Ruler.dragRulerGetRaysFromWaypoints(history, {x: token.x, y: token.y}).map(ray => {return {ray}});
|
const segments = Ruler.dragRulerGetRaysFromWaypoints(history, {x: token.x, y: token.y}).map(ray => {return {ray}});
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {getCostFromSpeedProvider} from "./api.js";
|
import {getCostFromSpeedProvider} from "./api.js";
|
||||||
import {getColorForDistance} from "./main.js"
|
|
||||||
import {settingsKey} from "./settings.js";
|
import {settingsKey} from "./settings.js";
|
||||||
import {getAreaFromPositionAndShape, highlightTokenShape} from "./util.js";
|
import {getAreaFromPositionAndShape, highlightTokenShape} from "./util.js";
|
||||||
|
|
||||||
@@ -10,7 +9,7 @@ export function getHexSizeSupportTokenGridCenter(token) {
|
|||||||
|
|
||||||
export function highlightMeasurementTerrainRuler(ray, startDistance, tokenShape=[{x: 0, y: 0}], alpha=1) {
|
export function highlightMeasurementTerrainRuler(ray, startDistance, tokenShape=[{x: 0, y: 0}], alpha=1) {
|
||||||
for (const space of ray.terrainRulerVisitedSpaces.reverse()) {
|
for (const space of ray.terrainRulerVisitedSpaces.reverse()) {
|
||||||
const color = getColorForDistance.call(this, startDistance, space.distance)
|
const color = this.dragRulerGetColorForDistance(startDistance + space.distance);
|
||||||
highlightTokenShape.call(this, space, tokenShape, color, alpha)
|
highlightTokenShape.call(this, space, tokenShape, color, alpha)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {highlightMeasurementTerrainRuler, measureDistances} from "./compatibility.js";
|
import {highlightMeasurementTerrainRuler, measureDistances} from "./compatibility.js";
|
||||||
import {getGridPositionFromPixels} from "./foundry_fixes.js";
|
import {getGridPositionFromPixels} from "./foundry_fixes.js";
|
||||||
import {Line} from "./geometry.js";
|
import {Line} from "./geometry.js";
|
||||||
import {getColorForDistance} from "./main.js"
|
|
||||||
import {trackRays} from "./movement_tracking.js"
|
import {trackRays} from "./movement_tracking.js"
|
||||||
import {recalculate} from "./socket.js";
|
import {recalculate} from "./socket.js";
|
||||||
import {applyTokenSizeOffset, getSnapPointForEntity, getSnapPointForToken, getTokenShape, highlightTokenShape, zip} from "./util.js";
|
import {applyTokenSizeOffset, getSnapPointForEntity, getSnapPointForToken, getTokenShape, highlightTokenShape, zip} from "./util.js";
|
||||||
@@ -229,7 +228,7 @@ export function measure(destination, options={}) {
|
|||||||
r.clear();
|
r.clear();
|
||||||
let rulerColor
|
let rulerColor
|
||||||
if (!options.gridSpaces || canvas.grid.type === CONST.GRID_TYPES.GRIDLESS)
|
if (!options.gridSpaces || canvas.grid.type === CONST.GRID_TYPES.GRIDLESS)
|
||||||
rulerColor = getColorForDistance.call(this, totalDistance)
|
rulerColor = this.dragRulerGetColorForDistance(totalDistance);
|
||||||
else
|
else
|
||||||
rulerColor = this.color
|
rulerColor = this.color
|
||||||
for (const [s, cs] of zip(segments.reverse(), centeredSegments.reverse())) {
|
for (const [s, cs] of zip(segments.reverse(), centeredSegments.reverse())) {
|
||||||
@@ -301,7 +300,7 @@ export function highlightMeasurementNative(ray, startDistance, tokenShape=[{x: 0
|
|||||||
// Highlight the grid position
|
// Highlight the grid position
|
||||||
let [xg, yg] = canvas.grid.grid.getPixelsFromGridPosition(x1, y1);
|
let [xg, yg] = canvas.grid.grid.getPixelsFromGridPosition(x1, y1);
|
||||||
const subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xg, y: yg})}], {gridSpaces: true})[0]
|
const subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xg, y: yg})}], {gridSpaces: true})[0]
|
||||||
const color = dragRuler.getColorForDistance.call(this, startDistance, subDistance)
|
const color = this.dragRulerGetColorForDistance(startDistance + subDistance);
|
||||||
const snapPoint = getSnapPointForToken(...canvas.grid.getTopLeft(x, y), this.draggedEntity);
|
const snapPoint = getSnapPointForToken(...canvas.grid.getTopLeft(x, y), this.draggedEntity);
|
||||||
const [snapX, snapY] = getGridPositionFromPixels(snapPoint.x + 1, snapPoint.y + 1);
|
const [snapX, snapY] = getGridPositionFromPixels(snapPoint.x + 1, snapPoint.y + 1);
|
||||||
|
|
||||||
@@ -314,7 +313,7 @@ export function highlightMeasurementNative(ray, startDistance, tokenShape=[{x: 0
|
|||||||
let [x1h, y1h] = canvas.grid.grid.getGridPositionFromPixels(x, y);
|
let [x1h, y1h] = canvas.grid.grid.getGridPositionFromPixels(x, y);
|
||||||
let [xgh, ygh] = canvas.grid.grid.getPixelsFromGridPosition(x1h, y1h);
|
let [xgh, ygh] = canvas.grid.grid.getPixelsFromGridPosition(x1h, y1h);
|
||||||
const subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xgh, y: ygh})}], {gridSpaces: true})[0]
|
const subDistance = canvas.grid.measureDistances([{ray: new Ray(ray.A, {x: xgh, y: ygh})}], {gridSpaces: true})[0]
|
||||||
const color = dragRuler.getColorForDistance.call(this, startDistance, subDistance)
|
const color = this.dragRulerGetColorForDistance(startDistance + subDistance);
|
||||||
const snapPoint = getSnapPointForToken(...canvas.grid.getTopLeft(x, y), this.draggedEntity);
|
const snapPoint = getSnapPointForToken(...canvas.grid.getTopLeft(x, y), this.draggedEntity);
|
||||||
const [snapX, snapY] = getGridPositionFromPixels(snapPoint.x + 1, snapPoint.y + 1);
|
const [snapX, snapY] = getGridPositionFromPixels(snapPoint.x + 1, snapPoint.y + 1);
|
||||||
highlightTokenShape.call(this, {x: snapX, y: snapY}, tokenShape, color, alpha);
|
highlightTokenShape.call(this, {x: snapX, y: snapY}, tokenShape, color, alpha);
|
||||||
|
|||||||
+10
-28
@@ -1,6 +1,6 @@
|
|||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
import {currentSpeedProvider, getMovedDistanceFromToken, getRangesFromSpeedProvider, getUnreachableColorFromSpeedProvider, initApi, registerModule, registerSystem} from "./api.js"
|
import {currentSpeedProvider, getColorForDistanceAndToken, getMovedDistanceFromToken, initApi, registerModule, registerSystem} from "./api.js";
|
||||||
import {checkDependencies, getHexSizeSupportTokenGridCenter} from "./compatibility.js";
|
import {checkDependencies, getHexSizeSupportTokenGridCenter} from "./compatibility.js";
|
||||||
import {moveEntities, onMouseMove} from "./foundry_imports.js"
|
import {moveEntities, onMouseMove} from "./foundry_imports.js"
|
||||||
import {performMigrations} from "./migration.js"
|
import {performMigrations} from "./migration.js"
|
||||||
@@ -22,7 +22,7 @@ Hooks.once("init", () => {
|
|||||||
Ruler = DragRulerRuler;
|
Ruler = DragRulerRuler;
|
||||||
|
|
||||||
window.dragRuler = {
|
window.dragRuler = {
|
||||||
getColorForDistance,
|
getColorForDistanceAndToken,
|
||||||
getMovedDistanceFromToken,
|
getMovedDistanceFromToken,
|
||||||
registerModule,
|
registerModule,
|
||||||
registerSystem,
|
registerSystem,
|
||||||
@@ -32,6 +32,14 @@ Hooks.once("init", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Hooks.once("ready", () => {
|
Hooks.once("ready", () => {
|
||||||
|
{
|
||||||
|
const alphaWarning = "You are using the alpha branch of Drag Ruler. DO NOT USE IT IN PRODUCTION ENVIRONMENTS. This branch is used for pre-release testing. As a result this branch will only be updated sporadically and may be siginificantly newer (or even older) than the main Drag Ruler release branch. In addition this branch is likely to be likely to contain more bugs.";
|
||||||
|
console.warn(alphaWarning)
|
||||||
|
ui.notifications.warn(alphaWarning)
|
||||||
|
if (game.modules.get("drag-ruler")?.active) {
|
||||||
|
ui.notification.error("You have both the release version and the alpha version of Drag Ruler enabled. Doing so prevents the module from working properly. Please disable either the release or the alpha version of Drag Ruler.", {permanent: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
performMigrations()
|
performMigrations()
|
||||||
checkDependencies();
|
checkDependencies();
|
||||||
Hooks.callAll("dragRuler.ready", SpeedProvider)
|
Hooks.callAll("dragRuler.ready", SpeedProvider)
|
||||||
@@ -265,29 +273,3 @@ function onEntityDragLeftCancel(event) {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getColorForDistance(startDistance, subDistance=0) {
|
|
||||||
if (!this.isDragRuler)
|
|
||||||
return this.color
|
|
||||||
if (!this.draggedEntity.actor) {
|
|
||||||
return this.color;
|
|
||||||
}
|
|
||||||
// Don't apply colors if the current user doesn't have at least observer permissions
|
|
||||||
if (this.draggedEntity.actor.permission < 2) {
|
|
||||||
// If this is a pc and alwaysShowSpeedForPCs is enabled we show the color anyway
|
|
||||||
if (!(this.draggedEntity.actor.data.type === "character" && game.settings.get(settingsKey, "alwaysShowSpeedForPCs")))
|
|
||||||
return this.color
|
|
||||||
}
|
|
||||||
const distance = startDistance + subDistance
|
|
||||||
if (!this.dragRulerRanges)
|
|
||||||
this.dragRulerRanges = getRangesFromSpeedProvider(this.draggedEntity);
|
|
||||||
const ranges = this.dragRulerRanges;
|
|
||||||
if (ranges.length === 0)
|
|
||||||
return this.color
|
|
||||||
const currentRange = ranges.reduce((minRange, currentRange) => {
|
|
||||||
if (distance <= currentRange.range && currentRange.range < minRange.range)
|
|
||||||
return currentRange
|
|
||||||
return minRange
|
|
||||||
}, {range: Infinity, color: getUnreachableColorFromSpeedProvider()})
|
|
||||||
return currentRange.color
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import {getColorForDistanceAndToken, getRangesFromSpeedProvider} from "./api.js";
|
||||||
import {cancelScheduledMeasurement, measure} from "./foundry_imports.js"
|
import {cancelScheduledMeasurement, measure} from "./foundry_imports.js"
|
||||||
import {getMovementHistory} from "./movement_tracking.js";
|
import {getMovementHistory} from "./movement_tracking.js";
|
||||||
import {settingsKey} from "./settings.js";
|
import {settingsKey} from "./settings.js";
|
||||||
@@ -152,4 +153,21 @@ export class DragRulerRuler extends Ruler {
|
|||||||
return ray;
|
return ray;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dragRulerGetColorForDistance(distance) {
|
||||||
|
if (!this.isDragRuler)
|
||||||
|
return this.color;
|
||||||
|
if (!this.draggedEntity.actor) {
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
// Don't apply colors if the current user doesn't have at least observer permissions
|
||||||
|
if (this.draggedEntity.actor.permission < 2) {
|
||||||
|
// If this is a pc and alwaysShowSpeedForPCs is enabled we show the color anyway
|
||||||
|
if (!(this.draggedEntity.actor.data.type === "character" && game.settings.get(settingsKey, "alwaysShowSpeedForPCs")))
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
if (!this.dragRulerRanges)
|
||||||
|
this.dragRulerRanges = getRangesFromSpeedProvider(this.draggedEntity);
|
||||||
|
return getColorForDistanceAndToken(distance, this.draggedEntity, this.dragRulerRanges);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ import {currentSpeedProvider} from "./api.js";
|
|||||||
let socket;
|
let socket;
|
||||||
|
|
||||||
Hooks.once("socketlib.ready", () => {
|
Hooks.once("socketlib.ready", () => {
|
||||||
socket = socketlib.registerModule("drag-ruler");
|
socket = socketlib.registerModule("drag-ruler-alpha");
|
||||||
socket.register("updateCombatantDragRulerFlags", _socketUpdateCombatantDragRulerFlags);
|
socket.register("updateCombatantDragRulerFlags", _socketUpdateCombatantDragRulerFlags);
|
||||||
socket.register("recalculate", _socketRecalculate);
|
socket.register("recalculate", _socketRecalculate);
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ export function getDefaultSpeedAttribute() {
|
|||||||
case "dnd5e":
|
case "dnd5e":
|
||||||
return "actor.data.data.attributes.movement.walk"
|
return "actor.data.data.attributes.movement.walk"
|
||||||
case "lancer":
|
case "lancer":
|
||||||
return "actor.data.data.mech.speed"
|
return "actor.data.data.derived.speed"
|
||||||
case "pf1":
|
case "pf1":
|
||||||
case "D35E":
|
case "D35E":
|
||||||
return "actor.data.data.attributes.speed.land.total"
|
return "actor.data.data.attributes.speed.land.total"
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ export function getSnapPointForToken(x, y, token) {
|
|||||||
return new PIXI.Point(x, y);
|
return new PIXI.Point(x, y);
|
||||||
}
|
}
|
||||||
if (canvas.grid.isHex && game.modules.get("hex-size-support")?.active && CONFIG.hexSizeSupport.getAltSnappingFlag(token)) {
|
if (canvas.grid.isHex && game.modules.get("hex-size-support")?.active && CONFIG.hexSizeSupport.getAltSnappingFlag(token)) {
|
||||||
if (token.getFlag("hex-size-support", "borderSize") % 2 === 0) {
|
if (token.document.getFlag("hex-size-support", "borderSize") % 2 === 0) {
|
||||||
const snapPoint = CONFIG.hexSizeSupport.findVertexSnapPoint(x, y, token, canvas.grid.grid)
|
const snapPoint = CONFIG.hexSizeSupport.findVertexSnapPoint(x, y, token, canvas.grid.grid)
|
||||||
return new PIXI.Point(snapPoint.x, snapPoint.y)
|
return new PIXI.Point(snapPoint.x, snapPoint.y)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user