commit a4f74efa6067818548f5343ba2be76aabab3c043 Author: cosmo Date: Tue Mar 24 02:25:38 2026 +0100 feat: Implement Daggerheart Token Spotlight module, adding a HUD button to toggle combatant spotlight with associated logic and styling. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b598ff7 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Daggerheart Token Spotlight + +Adds a button to the token hover HUD to toggle the spotlight for Daggerheart. + +## Compatibility +- **Foundry VTT**: v13+ +- **System**: Daggerheart + +## Installation +To install this module, follow these instructions: +1. Start Foundry VTT and navigate to the **Add-on Modules** tab in the Setup Menu. +2. Click **Install Module**. +3. Paste the Manifest URL (`https://git.geeks.gay/cosmo/dh-token-spotlight/raw/branch/main/module.json`) into the **Manifest URL** field at the bottom. +4. Click **Install**. diff --git a/module.json b/module.json new file mode 100644 index 0000000..fd7e8d6 --- /dev/null +++ b/module.json @@ -0,0 +1,39 @@ +{ + "id": "dh-token-spotlight", + "title": "Daggerheart Token Spotlight", + "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.0.0/dh-token-spotlight.zip", + "version": "1.0.0", + "compatibility": { + "minimum": "13", + "verified": "13" + }, + "relationships": { + "systems": [ + { + "id": "daggerheart", + "type": "system", + "compatibility": {} + } + ] + }, + "authors": [ + { + "name": "Cosmo", + "email": "cptncosmo@gmail.com", + "url": "https://git.geeks.gay/cosmo", + "discord": "cptn_cosmo", + "flags": {} + } + ], + "scripts": [ + "scripts/main.js" + ], + "styles": [ + "styles/styles.css" + ], + "manifest": "", + "download": "" +} \ No newline at end of file diff --git a/scripts/main.js b/scripts/main.js new file mode 100644 index 0000000..8b2ee9d --- /dev/null +++ b/scripts/main.js @@ -0,0 +1,51 @@ +Hooks.on('renderTokenHUD', (app, html, data) => { + const token = app.object; + if (!token?.combatant) return; + + const viewedCombat = ui.combat?.viewed; + if (!viewedCombat) return; + + // In Daggerheart, the combatant with the spotlight is the one whose turn it currently is. + const hasSpotlight = viewedCombat.combatant?.id === token.combatant.id; + + // Determine icon and classes based on spotlight state + const iconClass = hasSpotlight + ? "fa-solid fa-hand-sparkles dh-spotlight-glow" + : "fa-regular fa-hand-sparkles"; + + const buttonHtml = ` +
+ +
+ `; + + // Append to the right column of the Token HUD + const colRight = html.find('.col.right'); + colRight.append(buttonHtml); + + // Add click listener + html.find('[data-action="toggle-spotlight"]').click(async event => { + event.preventDefault(); + event.stopPropagation(); + + if (ui.combat && typeof ui.combat.setCombatantSpotlight === "function") { + const btn = $(event.currentTarget); + const icon = btn.find('i'); + const wasActive = btn.hasClass('active'); + + // Optimistic UI update + if (wasActive) { + btn.removeClass('active'); + icon.removeClass('fa-solid dh-spotlight-glow').addClass('fa-regular'); + } else { + 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 new file mode 100644 index 0000000..4e9e11d --- /dev/null +++ b/styles/styles.css @@ -0,0 +1,10 @@ +/* Daggerheart Token Spotlight Glow Effect */ +.dh-spotlight-glow { + color: #ffd700 !important; /* Gold */ + text-shadow: 0 0 5px #ffb300, 0 0 10px #ffb300, 0 0 15px #ff8c00; +} + +/* Ensure the control icon container doesn't obscure the glow and has adequate spacing */ +#token-hud .control-icon.active i.dh-spotlight-glow { + color: #ffd700; +}