From 5c43651925afcd089743818e7855069268b36085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 2 Feb 2021 14:37:07 +0100 Subject: [PATCH] Add option to show colors of PCs to anyone, regardless of permissions --- lang/en.json | 4 ++++ src/main.js | 4 +++- src/settings.js | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lang/en.json b/lang/en.json index 5f0f6fc..f36bc72 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,6 +1,10 @@ { "drag-ruler": { "settings": { + "alwaysShowSpeedForPCs": { + "name": "Show PC speed to everyone", + "hint": "If enabled the coloring based on actor speed for player characters will shown to everyone, even if they don't have observer permission for the character sheet." + }, "dashMultiplier": { "name": "Dash Multiplier", "hint": "This can be used to give tokens a secondary speed during coloring of the measured path. Set it to 0 to disable the secondary speed." diff --git a/src/main.js b/src/main.js index f5775f0..bf8b462 100644 --- a/src/main.js +++ b/src/main.js @@ -174,7 +174,9 @@ function getColorForDistance(startDistance, subDistance) { return this.color // Don't apply colors if the current user doesn't have at least observer permissions if (this.draggedToken.actor.permission < 2) { - return this.color + // If this is a pc and alwaysShowSpeedForPCs is enabled we show the color anyway + if (!(this.draggedToken.actor.data.type === "character" && game.settings.get(settingsKey, "alwaysShowSpeedForPCs"))) + return this.color } const distance = startDistance + subDistance const ranges = currentSpeedProvider(this.draggedToken, this.color) diff --git a/src/settings.js b/src/settings.js index 8ef52f9..cfa1fbe 100644 --- a/src/settings.js +++ b/src/settings.js @@ -4,6 +4,15 @@ import {getDefaultDashMultiplier, getDefaultSpeedAttribute} from "./systems.js" export const settingsKey = "drag-ruler"; export function registerSettings() { + game.settings.register(settingsKey, "alwaysShowSpeedForPCs", { + name: "drag-ruler.settings.alwaysShowSpeedForPCs.name", + hint: "drag-ruler.settings.alwaysShowSpeedForPCs.hint", + scope: "world", + config: true, + type: Boolean, + default: true, + }) + // This setting will be modified by the api if modules register to it game.settings.register(settingsKey, "speedProvider", { name: "drag-ruler.settings.speedProvider.name",