Change ruler color on gridless maps to indecate different speeds (resolves #15)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
### New features
|
||||
- Right click and spacebar can now be swapped, allowing to place waypoints with right click and removing them with spacebar
|
||||
- The module can now be configured use a fixed color instead of the player color for the first speed range
|
||||
- On gridless maps the ruler will now change it's color to indicate the different speed ranges
|
||||
|
||||
### Bugfixes
|
||||
- Disabling snap to grid with shift now works as expected
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[](https://ko-fi.com/staebchenfisch)
|
||||
|
||||
# Drag Ruler
|
||||
This module shows a ruler when you drag a token to infrom you how far you've dragged the token from it's start point. Additionally, if you're using a grid, the spaces the token will travel though will be colored depending on your tokens speed.
|
||||
This module shows a ruler when you drag a token to infrom you how far you've dragged the token from it's start point. Additionally, if you're using a grid, the spaces the token will travel though will be colored depending on your tokens speed. If you're using a gridless map the ruler color will change to convey this information.
|
||||
|
||||
|
||||
## Path color
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import {getColorForDistance} from "./main.js"
|
||||
|
||||
// This is a modified version of Ruler.moveToken from foundry 0.7.9
|
||||
export async function moveTokens(draggedToken, selectedTokens) {
|
||||
let wasPaused = game.paused;
|
||||
@@ -142,12 +144,17 @@ export function measure(destination, {gridSpaces=true, snap=false} = {}) {
|
||||
|
||||
// Draw measured path
|
||||
r.clear();
|
||||
let rulerColor
|
||||
if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS)
|
||||
rulerColor = getColorForDistance.call(this, totalDistance)
|
||||
else
|
||||
rulerColor = this.color
|
||||
for (let s of segments) {
|
||||
const { ray, label, text, last } = s;
|
||||
|
||||
// Draw line segment
|
||||
r.lineStyle(6, 0x000000, 0.5).moveTo(ray.A.x, ray.A.y).lineTo(ray.B.x, ray.B.y)
|
||||
.lineStyle(4, this.color, 0.25).moveTo(ray.A.x, ray.A.y).lineTo(ray.B.x, ray.B.y);
|
||||
.lineStyle(4, rulerColor, 0.25).moveTo(ray.A.x, ray.A.y).lineTo(ray.B.x, ray.B.y);
|
||||
|
||||
// Draw the distance label just after the endpoint of the segment
|
||||
if (label) {
|
||||
@@ -164,7 +171,7 @@ export function measure(destination, {gridSpaces=true, snap=false} = {}) {
|
||||
|
||||
// Draw endpoints
|
||||
for (let p of waypoints) {
|
||||
r.lineStyle(2, 0x000000, 0.5).beginFill(this.color, 0.25).drawCircle(p.x, p.y, 8);
|
||||
r.lineStyle(2, 0x000000, 0.5).beginFill(rulerColor, 0.25).drawCircle(p.x, p.y, 8);
|
||||
}
|
||||
|
||||
// Return the measured segments
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ function nativeSpeedProvider(token, playercolor) {
|
||||
return [{range: tokenSpeed, color: playercolor}, {range: tokenSpeed * dashMultiplier, color: 0xFFFF00}]
|
||||
}
|
||||
|
||||
function getColorForDistance(startDistance, subDistance) {
|
||||
export function getColorForDistance(startDistance, subDistance=0) {
|
||||
if (!this.isDragRuler)
|
||||
return this.color
|
||||
// Don't apply colors if the current user doesn't have at least observer permissions
|
||||
|
||||
Reference in New Issue
Block a user