diff --git a/module.json b/module.json index 3d6bcf0..b0f4f5e 100644 --- a/module.json +++ b/module.json @@ -4,8 +4,8 @@ "description": "Adds a button to the token hover HUD to toggle the spotlight for Daggerheart.", "url": "https://git.geeks.gay/cosmo/dh-token-spotlight", "manifest": "https://git.geeks.gay/cosmo/dh-token-spotlight/raw/branch/main/module.json", - "download": "https://git.geeks.gay/cosmo/dh-token-spotlight/releases/download/1.1.1/dh-token-spotlight.zip", - "version": "1.1.1", + "download": "https://git.geeks.gay/cosmo/dh-token-spotlight/releases/download/1.0.2/dh-token-spotlight.zip", + "version": "1.0.2", "compatibility": { "minimum": "13", "verified": "13" diff --git a/scripts/main.js b/scripts/main.js index 64e6b71..78e49e6 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -7,28 +7,14 @@ Hooks.on('renderTokenHUD', (app, html, data) => { // In Daggerheart, the combatant with the spotlight is the one whose turn it currently is. const hasSpotlight = viewedCombat.combatant?.id === token.combatant.id; - const isRequesting = token.combatant.system?.spotlight?.requesting; // Determine icon and classes based on spotlight state - let iconClass = "fa-regular fa-hand-sparkles"; - let activeClass = ""; - if (hasSpotlight) { - iconClass = "fa-solid fa-hand-sparkles dh-spotlight-glow"; - activeClass = "active"; - } else if (isRequesting) { - iconClass = "fa-solid fa-hand-sparkles dh-spotlight-request"; - activeClass = "active"; - } + const iconClass = hasSpotlight + ? "fa-solid fa-hand-sparkles dh-spotlight-glow" + : "fa-regular fa-hand-sparkles"; - let tooltipText = ""; - if (game.user.isGM) { - tooltipText = hasSpotlight ? "Take Spotlight" : "Grant Spotlight"; - } else { - tooltipText = hasSpotlight ? "Remove Spotlight" : (isRequesting ? "Cancel Spotlight Request" : "Request Spotlight"); - } - const buttonHtml = ` -
+
`; @@ -42,56 +28,22 @@ Hooks.on('renderTokenHUD', (app, html, data) => { event.preventDefault(); event.stopPropagation(); - if (ui.combat) { + if (ui.combat && typeof ui.combat.setCombatantSpotlight === "function") { const btn = $(event.currentTarget); const icon = btn.find('i'); const wasActive = btn.hasClass('active'); - const isRequestingMsg = icon.hasClass('dh-spotlight-request'); - if (game.user.isGM) { - if (typeof ui.combat.setCombatantSpotlight === "function") { - // Optimistic UI update for GM - if (wasActive && !isRequestingMsg) { - btn.removeClass('active'); - icon.removeClass('fa-solid dh-spotlight-glow').addClass('fa-regular'); - btn.attr('title', 'Grant Spotlight'); - } else { - btn.addClass('active'); - icon.removeClass('fa-regular dh-spotlight-request').addClass('fa-solid dh-spotlight-glow'); - btn.attr('title', 'Take Spotlight'); - } - await ui.combat.setCombatantSpotlight(token.combatant.id); - } + // Optimistic UI update + if (wasActive) { + btn.removeClass('active'); + icon.removeClass('fa-solid dh-spotlight-glow').addClass('fa-regular'); } else { - // Players request the spotlight - const combat = ui.combat.viewed; - if (!combat) return; - - const characters = combat.turns?.filter(x => !x.isNPC) ?? []; - // Fallback to maxRequestIndex = 0 if necessary - const orderValues = characters.map(c => c.system?.spotlight?.requestOrderIndex || 0); - const maxRequestIndex = orderValues.length > 0 ? Math.max(...orderValues) : 0; - - const currentlyRequesting = !!token.combatant.system?.spotlight?.requesting; - - // Optimistic UI update for Player - if (currentlyRequesting) { - btn.removeClass('active'); - icon.removeClass('fa-solid dh-spotlight-request').addClass('fa-regular'); - btn.attr('title', 'Request Spotlight'); - } else { - btn.addClass('active'); - icon.removeClass('fa-regular').addClass('fa-solid dh-spotlight-request'); - btn.attr('title', 'Cancel Spotlight Request'); - } - - await token.combatant.update({ - 'system.spotlight': { - requesting: !currentlyRequesting, - requestOrderIndex: !currentlyRequesting ? maxRequestIndex + 1 : 0 - } - }); + btn.addClass('active'); + icon.removeClass('fa-regular').addClass('fa-solid dh-spotlight-glow'); } + + // Call the system's spotlight toggle function + await ui.combat.setCombatantSpotlight(token.combatant.id); } else { ui.notifications.warn("System does not support spotlight or combat is not initialized."); } diff --git a/styles/styles.css b/styles/styles.css index f4f02d3..82ab797 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -15,9 +15,3 @@ justify-content: center; align-items: center; } - -/* Player spotlight request effect */ -#token-hud .control-icon.active i.dh-spotlight-request { - color: #4da6ff; - text-shadow: 0 0 5px #007bff, 0 0 10px #007bff; -}