diff --git a/module.json b/module.json index 2d5dc89..3edd831 100644 --- a/module.json +++ b/module.json @@ -8,7 +8,7 @@ "email": "dev7355608@gmail.com" } ], - "version": "2.3.2", + "version": "2.3.3", "compatibility": { "minimum": "12", "verified": "12" @@ -60,8 +60,8 @@ }, "url": "https://github.com/dev7355608/vision-5e", "manifest": "https://github.com/dev7355608/vision-5e/releases/latest/download/module.json", - "download": "https://github.com/dev7355608/vision-5e/releases/download/v2.3.2/module.zip", - "changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v2.3.2", + "download": "https://github.com/dev7355608/vision-5e/releases/download/v2.3.3/module.zip", + "changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v2.3.3", "bugs": "https://github.com/dev7355608/vision-5e/issues", "readme": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/README.md", "license": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/LICENSE" diff --git a/scripts/combat-tracker.mjs b/scripts/combat-tracker.mjs new file mode 100644 index 0000000..66152b2 --- /dev/null +++ b/scripts/combat-tracker.mjs @@ -0,0 +1,54 @@ +import { DETECTION_LEVELS } from "./const.mjs"; + +export default (CombatTracker) => class extends CombatTracker { + + /** @override */ + _onCombatantHoverIn(event) { + event.preventDefault(); + + if (!canvas.ready) { + return; + } + + const li = event.currentTarget; + const combatant = this.viewed.combatants.get(li.dataset.combatantId); + const token = combatant.token?.object; + + if (token?.detectionLevel === DETECTION_LEVELS.PRECISE) { + if (!token.controlled) { + token._onHoverIn(event, { hoverOutOthers: true }); + } + + this._highlighted = token; + } + } + + /** @override */ + hoverCombatant(combatant, hover) { + const token = combatant.token.object; + + if (token.detectionLevel !== DETECTION_LEVELS.PRECISE) { + hover = false; + } + + const trackers = [this.element[0]]; + + if (this._popout) { + trackers.push(this._popout.element[0]); + } + + for (const tracker of trackers) { + const li = tracker.querySelector(`.combatant[data-combatant-id="${combatant.id}"]`); + + if (!li) { + continue; + } + + if (hover) { + li.classList.add("hover"); + } else { + li.classList.remove("hover"); + } + } + } +}; diff --git a/scripts/main.mjs b/scripts/main.mjs index 0e9e28d..a78a8f1 100644 --- a/scripts/main.mjs +++ b/scripts/main.mjs @@ -4,6 +4,7 @@ import TokenConfigMixin from "./token-config.mjs"; import TokenDocumentMixin from "./token-document.mjs"; import TokenHUDMixin from "./token-hud.mjs"; import VisionSourceMixin from "./vision-source.mjs"; +import CombatTrackerMixin from "./combat-tracker.mjs"; import DetectionModeBlindsense from "./detection-modes/blindsense.mjs"; import DetectionModeBlindsight from "./detection-modes/blindsight.mjs"; import DetectionModeBloodSense from "./detection-modes/blood-sense.mjs"; @@ -39,6 +40,9 @@ Hooks.once("init", () => { // Extend PointVisionSource CONFIG.Canvas.visionSourceClass = VisionSourceMixin(CONFIG.Canvas.visionSourceClass); + // Extend CombatTracker + CONFIG.ui.combat = CombatTrackerMixin(CONFIG.ui.combat); + // Register the Inaudible status effect CONFIG.statusEffects.push({ id: "inaudible",