From dfc84d0626c6aebbfde9246cb70bbb9d7e37bcc9 Mon Sep 17 00:00:00 2001 From: CPTN Cosmo Date: Mon, 22 Dec 2025 00:53:52 +0100 Subject: [PATCH] feat: Add new border style options, including single-edge borders, to countdown trackers. --- module.json | 4 +-- scripts/countdown-app.js | 4 +++ scripts/module.js | 45 ++++++++++++++++++++++++++++ templates/countdown-tracker.hbs | 52 +++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 2 deletions(-) diff --git a/module.json b/module.json index 5a340f5..a61311a 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "id": "dh-improved-countdowns", "title": "Improved Countdowns", - "version": "1.1.0", + "version": "1.2.0", "compatibility": { "minimum": "13", "verified": "13" @@ -40,5 +40,5 @@ "description": "A modern, draggable countdown tracker for the Daggerheart system.", "url": "https://github.com/cptn-cosmo/dh-improved-countdowns", "manifest": "https://github.com/cptn-cosmo/dh-improved-countdowns/releases/latest/download/module.json", - "download": "https://github.com/cptn-cosmo/dh-improved-countdowns/releases/download/1.1.0/dh-improved-countdowns.zip" + "download": "https://github.com/cptn-cosmo/dh-improved-countdowns/releases/download/1.2.0/dh-improved-countdowns.zip" } \ No newline at end of file diff --git a/scripts/countdown-app.js b/scripts/countdown-app.js index 5357482..39d90d0 100644 --- a/scripts/countdown-app.js +++ b/scripts/countdown-app.js @@ -62,6 +62,8 @@ export class CountdownTrackerApp extends HandlebarsApplicationMixin(ApplicationV const enableVisualBorder = game.settings.get("dh-improved-countdowns", "enableVisualBorder"); const invertBorder = game.settings.get("dh-improved-countdowns", "invertBorder"); const borderColor = game.settings.get("dh-improved-countdowns", "borderColor"); + const borderStyle = game.settings.get("dh-improved-countdowns", "borderStyle"); + const borderEdge = game.settings.get("dh-improved-countdowns", "borderEdge"); const gmAlwaysShowNumbers = game.settings.get("dh-improved-countdowns", "gmAlwaysShowNumbers"); const showNumbers = (isGM && gmAlwaysShowNumbers) || displayMode === "number" || displayMode === "both"; @@ -112,6 +114,8 @@ export class CountdownTrackerApp extends HandlebarsApplicationMixin(ApplicationV enableVisualBorder, invertBorder, borderColor, + borderStyle, + borderEdge, invertProgress, numberColor }; diff --git a/scripts/module.js b/scripts/module.js index 50bb41f..5f542b5 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -146,6 +146,36 @@ Hooks.once('init', () => { onChange: () => CountdownTrackerApp.instance?.render() }); + game.settings.register("dh-improved-countdowns", "borderStyle", { + name: "Border Style", + hint: "Choose the style of the progress border (for square icons).", + scope: "client", + config: true, + type: String, + choices: { + "full": "Full Border", + "edge": "Single Edge" + }, + default: "full", + onChange: () => CountdownTrackerApp.instance?.render() + }); + + game.settings.register("dh-improved-countdowns", "borderEdge", { + name: "Border Edge", + hint: "Choose which edge to display the border on.", + scope: "client", + config: true, + type: String, + choices: { + "bottom": "Bottom", + "top": "Top", + "left": "Left", + "right": "Right" + }, + default: "bottom", + onChange: () => CountdownTrackerApp.instance?.render() + }); + game.settings.register("dh-improved-countdowns", "borderColor", { name: "Border Color", hint: "Color for the progress border.", @@ -195,6 +225,8 @@ Hooks.on('renderSettingsConfig', (app, html, data) => { const fillColorGroup = getGroup("fillColor"); const invertBorderGroup = getGroup("invertBorder"); const borderColorGroup = getGroup("borderColor"); + const borderStyleGroup = getGroup("borderStyle"); + const borderEdgeGroup = getGroup("borderEdge"); const barOrientationGroup = getGroup("barOrientation"); // Number specific groups @@ -245,9 +277,19 @@ Hooks.on('renderSettingsConfig', (app, html, data) => { if (borderEnabled) { invertBorderGroup.show(); borderColorGroup.show(); + borderStyleGroup.show(); + + const borderStyle = html.find(`[name="${moduleId}.borderStyle"]`).val(); + if (borderStyle === "edge") { + borderEdgeGroup.show(); + } else { + borderEdgeGroup.hide(); + } } else { invertBorderGroup.hide(); borderColorGroup.hide(); + borderStyleGroup.hide(); + borderEdgeGroup.hide(); } } else { // Hide all visual settings @@ -259,6 +301,8 @@ Hooks.on('renderSettingsConfig', (app, html, data) => { barOrientationGroup.hide(); invertBorderGroup.hide(); borderColorGroup.hide(); + borderStyleGroup.hide(); + borderEdgeGroup.hide(); } }; @@ -266,6 +310,7 @@ Hooks.on('renderSettingsConfig', (app, html, data) => { displayModeInput.on("change", updateVisibility); if (enableOverlayInput.length && enableBorderInput.length) { html.find(`[name="${moduleId}.fillType"]`).on("change", updateVisibility); + html.find(`[name="${moduleId}.borderStyle"]`).on("change", updateVisibility); enableOverlayInput.on("change", updateVisibility); enableBorderInput.on("change", updateVisibility); updateVisibility(); // Initial check diff --git a/templates/countdown-tracker.hbs b/templates/countdown-tracker.hbs index 88a8f1d..dffa10e 100644 --- a/templates/countdown-tracker.hbs +++ b/templates/countdown-tracker.hbs @@ -105,6 +105,57 @@ style="transition: stroke-dasharray 0.3s ease; opacity: 1;"> {{/if}} {{else}} + {{#if (eq ../borderStyle "edge")}} + {{#if ../invertBorder}} + {{#if (eq ../borderEdge "bottom")}} + + + {{else if (eq ../borderEdge "top")}} + + + {{else if (eq ../borderEdge "left")}} + + + {{else if (eq ../borderEdge "right")}} + + + {{/if}} + {{else}} + {{#if (eq ../borderEdge "bottom")}} + + + {{else if (eq ../borderEdge "top")}} + + + {{else if (eq ../borderEdge "left")}} + + + {{else if (eq ../borderEdge "right")}} + + + {{/if}} + {{/if}} + {{else}} {{#if ../invertBorder}} {{/if}} {{/if}} + {{/if}} {{/if}}