feat: Implement Daggerheart Token Spotlight module, adding a HUD button to toggle combatant spotlight with associated logic and styling.
This commit is contained in:
commit
a4f74efa60
4 changed files with 114 additions and 0 deletions
14
README.md
Normal file
14
README.md
Normal file
|
|
@ -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**.
|
||||
39
module.json
Normal file
39
module.json
Normal file
|
|
@ -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": ""
|
||||
}
|
||||
51
scripts/main.js
Normal file
51
scripts/main.js
Normal file
|
|
@ -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 = `
|
||||
<div class="control-icon ${hasSpotlight ? 'active' : ''}" data-action="toggle-spotlight" title="Toggle Spotlight">
|
||||
<i class="${iconClass}"></i>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// 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.");
|
||||
}
|
||||
});
|
||||
});
|
||||
10
styles/styles.css
Normal file
10
styles/styles.css
Normal file
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue