Allow difficult terrain measurements on girdless maps
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
## In development
|
## In development
|
||||||
|
**BREAKING** This update is incompatible with previous Terrain Ruler versions. If you're using Terrain Ruler, make sure you update Terrain Ruler to at least version 1.3.0.
|
||||||
|
|
||||||
|
### New features
|
||||||
|
- Drag Ruler can now measure difficult terrain on gridless maps (if the Terrain Ruler module is installed and enabled)
|
||||||
|
|
||||||
### Translation
|
### Translation
|
||||||
- Corrected typos in the german translation (thanks to CarnVanBeck!)
|
- Corrected typos in the german translation (thanks to CarnVanBeck!)
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export function highlightMeasurementTerrainRuler(ray, startDistance, tokenShape=
|
|||||||
export function measureDistances(segments, token, shape, gridSpaces=true, options={}) {
|
export function measureDistances(segments, token, shape, gridSpaces=true, options={}) {
|
||||||
const opts = duplicate(options)
|
const opts = duplicate(options)
|
||||||
opts.gridSpaces = gridSpaces;
|
opts.gridSpaces = gridSpaces;
|
||||||
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active && canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS;
|
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active && (!game.modules.get("TerrainLayer")?.active || canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS);
|
||||||
if (terrainRulerAvailable) {
|
if (terrainRulerAvailable) {
|
||||||
const firstNewSegmentIndex = segments.findIndex(segment => !segment.ray.dragRulerVisitedSpaces);
|
const firstNewSegmentIndex = segments.findIndex(segment => !segment.ray.dragRulerVisitedSpaces);
|
||||||
const previousSegments = segments.slice(0, firstNewSegmentIndex);
|
const previousSegments = segments.slice(0, firstNewSegmentIndex);
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ export function measure(destination, {gridSpaces=true, snap=false} = {}) {
|
|||||||
if (snap)
|
if (snap)
|
||||||
destination = getSnapPointForToken(destination.x, destination.y, this.draggedToken)
|
destination = getSnapPointForToken(destination.x, destination.y, this.draggedToken)
|
||||||
|
|
||||||
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active && canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS;
|
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active && (!game.modules.get("TerrainLayer")?.active || canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS);
|
||||||
|
|
||||||
const waypoints = this.waypoints.concat([destination]);
|
const waypoints = this.waypoints.concat([destination]);
|
||||||
// Move the waypoints to the center of the grid if a size is used that measures from edge to edge
|
// Move the waypoints to the center of the grid if a size is used that measures from edge to edge
|
||||||
@@ -209,10 +209,12 @@ export function measure(destination, {gridSpaces=true, snap=false} = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Highlight grid positions
|
// Highlight grid positions
|
||||||
if (terrainRulerAvailable)
|
if (canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS) {
|
||||||
highlightMeasurementTerrainRuler.call(this, cs.ray, cs.startDistance, shape, opacityMultiplier)
|
if (terrainRulerAvailable)
|
||||||
else
|
highlightMeasurementTerrainRuler.call(this, cs.ray, cs.startDistance, shape, opacityMultiplier)
|
||||||
highlightMeasurementNative.call(this, cs.ray, cs.startDistance, shape, opacityMultiplier);
|
else
|
||||||
|
highlightMeasurementNative.call(this, cs.ray, cs.startDistance, shape, opacityMultiplier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw endpoints
|
// Draw endpoints
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function calculateUpdate(combat, token, rays) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the passed waypoints to the combatant
|
// Add the passed waypoints to the combatant
|
||||||
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active && canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS;
|
const terrainRulerAvailable = game.modules.get("terrain-ruler")?.active && (!game.modules.get("TerrainLayer")?.active || canvas.grid.type !== CONST.GRID_TYPES.GRIDLESS);
|
||||||
const dragRulerFlags = combatant.flags.dragRuler;
|
const dragRulerFlags = combatant.flags.dragRuler;
|
||||||
const waypoints = dragRulerFlags.passedWaypoints;
|
const waypoints = dragRulerFlags.passedWaypoints;
|
||||||
for (const ray of rays) {
|
for (const ray of rays) {
|
||||||
|
|||||||
Reference in New Issue
Block a user