Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Bump version, update changelog (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
stwlam authored Jan 14, 2023
1 parent f5f4012 commit e81d286
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 0.2.1
* Lock down token config only for PCs and NPCs
* Indicate verified compatibility with dnd5e 2.1.2

## Version 0.2.0
* Restrict Blindsight by total cover (movement restriction) instead of line of sight
* Rename Feel Tremor and See All modes to Tremorsense and Truesight
Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": [
"script.js"
],
"version": "0.2.0",
"version": "0.2.1",
"compatibility": {
"minimum": "10",
"verified": "10.291"
Expand All @@ -23,7 +23,7 @@
"type": "system",
"compatibility": {
"minimum": "2.0.3",
"verified": "2.0.3"
"verified": "2.1.2"
}
}
]
Expand Down
54 changes: 28 additions & 26 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Hooks.once("init", () => {
// Register setting
Hooks.once("setup", () => {
game.settings.register("adequate-vision", "linkActorSenses", {
name: "Link Actor Senses (In Testing!)",
name: "Link Actor Senses",
hint: "Automatically manage vision/detection modes according to the senses possessed by each token's corresponding actor.",
scope: "world",
config: true,
Expand Down Expand Up @@ -105,34 +105,36 @@ Hooks.on("updateToken", (token, changes, context, userId) => {
});

Hooks.on("renderTokenConfig", (sheet, html) => {
if (!(game.settings.get("adequate-vision", "linkActorSenses")
&& ["character", "npc"].includes(sheet.object.actor?.type))) return;
const settingEnabled = game.settings.get("adequate-vision", "linkActorSenses");
const actorIsCreature = ["character", "npc"].includes(sheet.object.actor?.type);
if (!(settingEnabled && actorIsCreature)) return;

// Disable input fields that are automatically managed
html[0]
.querySelectorAll(
`
[name="sight.range"],
[name="sight.visionMode"],
[name="sight.brightness"],
[name="sight.saturation"],
[name="sight.contrast"],
[name^="detectionModes."]`
)
.forEach((e) => {
e.disabled = true;

if (e.name.startsWith("sight.")) {
e.dataset.tooltip = "Managed by Adequate Vision";
e.dataset.tooltipDirection = "LEFT";
}
const selectors = [
'[name="sight.range"]',
'[name="sight.visionMode"]',
'[name="sight.brightness"]',
'[name="sight.saturation"]',
'[name="sight.contrast"]',
'[name^="detectionModes."]',
].join(",");

for (const element of html[0].querySelectorAll(selectors).values()) {
element.disabled = true;

if (element.name.startsWith("sight.")) {
element.dataset.tooltip = "Managed by Adequate Vision";
element.dataset.tooltipDirection = "LEFT";
}

if (element.type === "range") {
element.style.filter = "grayscale(1.0) opacity(0.33)";
element.parentNode.querySelector(`.range-value`).style.filter = "opacity(0.67)";
}
}

if (e.type === "range") {
e.style.filter = "grayscale(1.0) opacity(0.33)";
e.parentNode.querySelector(`.range-value`).style.filter = "opacity(0.67)";
}
});
// Remove the buttons to add/remove detection modes
html[0].querySelectorAll(`.detection-mode-controls`).forEach((e) => e.remove());
html[0].querySelectorAll(".detection-mode-controls").forEach((e) => e.remove());
});

function onReady() {
Expand Down

0 comments on commit e81d286

Please sign in to comment.