From 70929ef693c0cd3ce2e24d5c30ff5035d4ec2be5 Mon Sep 17 00:00:00 2001 From: CPTN Cosmo Date: Fri, 19 Dec 2025 03:52:43 +0100 Subject: [PATCH] feat: Add a setting and animation for the fear tracker when it reaches maximum value. --- module.json | 4 ++-- scripts/module.js | 33 +++++++++++++++++++++++++++++++++ styles/module.css | 29 ++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/module.json b/module.json index 6235f86..195a568 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "id": "dh-feartrackerplus", "title": "Daggerheart Fear Tracker Plus", - "version": "1.0.0", + "version": "1.1.0", "compatibility": { "minimum": "13", "verified": "13" @@ -32,6 +32,6 @@ ], "url": "https://github.com/cptn-cosmo/dh-feartrackerplus", "manifest": "https://github.com/cptn-cosmo/dh-feartrackerplus/releases/latest/download/module.json", - "download": "https://github.com/cptn-cosmo/dh-feartrackerplus/releases/download/1.0.0/dh-feartrackerplus.zip", + "download": "https://github.com/cptn-cosmo/dh-feartrackerplus/releases/download/1.1.0/dh-feartrackerplus.zip", "description": "Customizes the Fear Tracker for Daggerheart." } \ No newline at end of file diff --git a/scripts/module.js b/scripts/module.js index 4fc1e7f..cadcf39 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -123,6 +123,16 @@ Hooks.once('init', () => { default: 1.0, onChange: refreshFearTracker }); + + game.settings.register(MODULE_ID, 'maxFearAnimation', { + name: 'Max Fear Animation', + hint: 'animate the fear tracker when it reaches maximum value.', + scope: 'client', + config: true, + type: Boolean, + default: true, + onChange: refreshFearTracker + }); }); /** @@ -454,4 +464,27 @@ function injectFearCustomization(html) { // Remove legacy container class if present fearContainer.classList.remove('fear-tracker-plus-container-gradient'); fearContainer.style.background = 'none'; + + // Max Fear Animation + const animateMax = game.settings.get(MODULE_ID, 'maxFearAnimation'); + if (animateMax) { + // Check if all available icons are active + // Icons are "active" if they don't have the 'inactive' class. + // Wait, looking at the code above, 'inactive' class checks are used. + // Let's count totals. + const activeIcons = Array.from(icons).filter(icon => !icon.classList.contains('inactive')).length; + + // If totalIcons > 0 and activeIcons === totalIcons, apply animation + if (totalIcons > 0 && activeIcons === totalIcons) { + icons.forEach(icon => { + icon.classList.add('fear-tracker-plus-animate'); + }); + } else { + icons.forEach(icon => { + icon.classList.remove('fear-tracker-plus-animate'); + }); + } + } else { + icons.forEach(icon => icon.classList.remove('fear-tracker-plus-animate')); + } } diff --git a/styles/module.css b/styles/module.css index 1022412..b1ee8b7 100644 --- a/styles/module.css +++ b/styles/module.css @@ -2,10 +2,37 @@ -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; - display: inline-block; /* Required for gradient text */ + display: inline-block; + /* Required for gradient text */ } /* Ensure the icon keeps its size and doesn't collapse */ #resource-fear i.fear-tracker-plus-custom { transition: all 0.5s ease; } + +@keyframes fearPulse { + 0% { + transform: scale(1); + filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)); + } + + 50% { + transform: scale(1.1); + filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.5)); + } + + 100% { + transform: scale(1); + filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)); + } +} + +#resource-fear i.fear-tracker-plus-animate { + display: inline-flex; + justify-content: center; + align-items: center; + vertical-align: middle; + transform-origin: center center; + animation: fearPulse 2s infinite ease-in-out; +} \ No newline at end of file