From 3a2e6bddb01dbd641e5dcac7b6b47f081a105405 Mon Sep 17 00:00:00 2001 From: CPTN Cosmo Date: Fri, 19 Dec 2025 18:02:51 +0100 Subject: [PATCH] remove unused setting and fix css gradient custom themes, 1.1.1 --- module.json | 4 ++-- scripts/module.js | 54 ++++++++++++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/module.json b/module.json index 195a568..aeac8e4 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "id": "dh-feartrackerplus", "title": "Daggerheart Fear Tracker Plus", - "version": "1.1.0", + "version": "1.1.1", "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.1.0/dh-feartrackerplus.zip", + "download": "https://github.com/cptn-cosmo/dh-feartrackerplus/releases/download/1.1.1/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 cadcf39..8868203 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -91,7 +91,7 @@ Hooks.once('init', () => { game.settings.register(MODULE_ID, 'fullColor', { name: 'Full Icon Color', - hint: 'CSS color string or gradient (Used if Theme is Custom).', + hint: 'CSS color string or gradient (e.g., "linear-gradient(90deg, red, blue)"). Used if Theme is Custom.', scope: 'client', config: true, type: String, @@ -99,16 +99,6 @@ Hooks.once('init', () => { onChange: refreshFearTracker }); - game.settings.register(MODULE_ID, 'emptyColor', { - name: 'Empty Icon Color', - hint: 'CSS color string for inactive icons (Used if Theme is Custom).', - scope: 'client', - config: true, - type: String, - default: '#444444', - onChange: refreshFearTracker - }); - game.settings.register(MODULE_ID, 'trackerScale', { name: 'Tracker Scale', hint: 'Resize the fear tracker (0.25x to 2.0x).', @@ -186,15 +176,12 @@ Hooks.on('renderSettingsConfig', (app, html, data) => { // Color Inputs const fullColorGroup = findGroup('fullColor'); - const emptyColorGroup = findGroup('emptyColor'); - if (fullColorGroup && emptyColorGroup) { + if (fullColorGroup) { if (theme === 'custom') { fullColorGroup.show(); - emptyColorGroup.show(); } else { fullColorGroup.hide(); - emptyColorGroup.hide(); } } @@ -349,7 +336,7 @@ function injectFearCustomization(html) { const customIcon = game.settings.get(MODULE_ID, 'customIcon'); const colorTheme = game.settings.get(MODULE_ID, 'colorTheme'); let fullColor = game.settings.get(MODULE_ID, 'fullColor'); - let emptyColor = game.settings.get(MODULE_ID, 'emptyColor'); + let emptyColor = '#444444'; // Default for custom // Theme Data for Interpolation let themeStart = null; @@ -446,16 +433,42 @@ function injectFearCustomization(html) { if (colorTheme !== 'foundryborne') { if (isInactive) { icon.style.background = emptyColor; + icon.style.backgroundSize = 'cover'; // Reset size for empty + icon.style.backgroundPosition = 'center'; // Reset pos for empty } else { // Active if (themeStart && themeEnd && totalIcons > 1) { - // Interpolate + // Interpolate (Preset Themes) const factor = index / (totalIcons - 1); const color = interpolateColor(themeStart, themeEnd, factor); icon.style.background = color; + icon.style.backgroundSize = 'cover'; + icon.style.backgroundPosition = 'center'; } else { - // Custom or Single Color - icon.style.background = fullColor; + // Custom Theme + // Check if fullColor appears to be a gradient + const isGradient = fullColor.includes('gradient'); + + if (isGradient && totalIcons > 0) { + icon.style.background = fullColor; + icon.style.backgroundSize = `${totalIcons * 100}% 100%`; + + // Calculate position + // Leftmost (index 0) = 0% + // Rightmost (index total-1) = 100% + let pos = 0; + if (totalIcons > 1) { + pos = (index / (totalIcons - 1)) * 100; + } + + icon.style.backgroundPosition = `${pos}% 0%`; + icon.style.backgroundAttachment = 'local'; // Ensure it sticks to the specific element config if needed, though default is usually fine. + } else { + // Solid Color + icon.style.background = fullColor; + icon.style.backgroundSize = 'cover'; + icon.style.backgroundPosition = 'center'; + } } } } @@ -469,9 +482,6 @@ function injectFearCustomization(html) { 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