From a6931b5b89d7292cb750f3c1e0d1cdf470b25a40 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Tue, 18 Nov 2025 22:25:26 +0100 Subject: [PATCH] . --- lang/en.json | 5 ++++- module/applications/ui/countdownEdit.mjs | 11 +++++++++- module/applications/ui/countdowns.mjs | 20 ++++++++++++++++-- styles/less/ui/countdown/countdown-edit.less | 10 +++++++++ templates/ui/countdown-edit.hbs | 14 +++++++------ templates/ui/countdowns.hbs | 22 +++++++++++--------- 6 files changed, 62 insertions(+), 20 deletions(-) diff --git a/lang/en.json b/lang/en.json index 30b275a0..520fa20b 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2566,7 +2566,10 @@ "Countdowns": { "title": "Countdowns", "toggleIconMode": "Toggle Icon Only", - "noPlayerAccess": "This countdown isn't visible to any players" + "noPlayerAccess": "This countdown isn't visible to any players", + "loop": "Looping", + "decreasingLoop": "Decreasing Looping", + "increasingLoop": "Increasing Looping" }, "ItemBrowser": { "title": "Daggerheart Compendium Browser", diff --git a/module/applications/ui/countdownEdit.mjs b/module/applications/ui/countdownEdit.mjs index 5a9421d3..1844538c 100644 --- a/module/applications/ui/countdownEdit.mjs +++ b/module/applications/ui/countdownEdit.mjs @@ -49,6 +49,14 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio context.hideNewCountdowns = this.hideNewCountdowns; context.countdowns = Object.keys(this.data.countdowns).reduce((acc, key) => { const countdown = this.data.countdowns[key]; + const isLooping = countdown.progress.looping !== CONFIG.DH.GENERAL.countdownLoopingTypes.noLooping; + const loopTooltip = isLooping + ? countdown.progress.looping === CONFIG.DH.GENERAL.countdownLoopingTypes.increasing.id + ? 'DAGGERHEART.UI.Countdowns.increasingLoop' + : countdown.progress.looping === CONFIG.DH.GENERAL.countdownLoopingTypes.decreasing.id + ? 'DAGGERHEART.UI.Countdowns.decreasingLoop' + : 'DAGGERHEART.UI.Countdowns.loop' + : null; acc[key] = { ...countdown, typeName: game.i18n.localize(CONFIG.DH.GENERAL.countdownBaseTypes[countdown.type].label), @@ -58,7 +66,8 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio CONFIG.DH.GENERAL.countdownProgressionTypes[countdown.progress.type].label ) }, - editing: this.editingCountdowns.has(key) + editing: this.editingCountdowns.has(key), + loopTooltip }; return acc; diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index fe0e2c09..bcc70c7a 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -119,10 +119,26 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application return acc; }, []); const nonGmPlayers = game.users.filter(x => !x.isGM); + + const countdownEditable = game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER; + const isLooping = countdown.progress.looping !== CONFIG.DH.GENERAL.countdownLoopingTypes.noLooping; + const loopTooltip = isLooping + ? countdown.progress.looping === CONFIG.DH.GENERAL.countdownLoopingTypes.increasing.id + ? 'DAGGERHEART.UI.Countdowns.increasingLoop' + : countdown.progress.looping === CONFIG.DH.GENERAL.countdownLoopingTypes.decreasing.id + ? 'DAGGERHEART.UI.Countdowns.decreasingLoop' + : 'DAGGERHEART.UI.Countdowns.loop' + : null; + const loopDisabled = + !countdownEditable || (isLooping && (countdown.progress.current > 0 || countdown.progress.max === '0')); + acc[key] = { ...countdown, - editable: game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER, - noPlayerAccess: nonGmPlayers.length && playersWithAccess.length === 0 + editable: countdownEditable, + noPlayerAccess: nonGmPlayers.length && playersWithAccess.length === 0, + shouldLoop: isLooping && countdown.progress.current === 0 && countdown.progress.max > 0, + loopDisabled: isLooping ? loopDisabled : null, + loopTooltip: isLooping && game.i18n.localize(loopTooltip) }; return acc; }, {}); diff --git a/styles/less/ui/countdown/countdown-edit.less b/styles/less/ui/countdown/countdown-edit.less index 4099728b..2a728a8e 100644 --- a/styles/less/ui/countdown/countdown-edit.less +++ b/styles/less/ui/countdown/countdown-edit.less @@ -102,6 +102,16 @@ border: 1px solid light-dark(@dark, @beige); border-radius: 3px; } + + .countdown-edit-loop { + position: relative; + + .loop-marker { + position: absolute; + top: -4px; + font-size: 10px; + } + } } } diff --git a/templates/ui/countdown-edit.hbs b/templates/ui/countdown-edit.hbs index 71e24e1c..41e3cf67 100644 --- a/templates/ui/countdown-edit.hbs +++ b/templates/ui/countdown-edit.hbs @@ -35,12 +35,14 @@
{{countdown.progress.typeName}}
{{#unless (eq countdown.progress.looping "noLooping")}} - - {{#if (eq countdown.progress.looping "increasing")}} - - {{else if (eq countdown.progress.looping "decreasing")}} - - {{/if}} +
+ + {{#if (eq countdown.progress.looping "increasing")}} + + {{else if (eq countdown.progress.looping "decreasing")}} + + {{/if}} +
{{/unless}} diff --git a/templates/ui/countdowns.hbs b/templates/ui/countdowns.hbs index 24c2f879..2480ccdb 100644 --- a/templates/ui/countdowns.hbs +++ b/templates/ui/countdowns.hbs @@ -15,19 +15,21 @@ {{#if countdown.editable}}{{/if}}
- {{#if (and @root.isGM (not ../iconOnly))}} - {{#if countdown.noPlayerAccess}} + {{#if (not ../iconOnly)}} + {{#if (and countdown.noPlayerAccess @root.isGM)}} {{/if}} {{#unless (eq countdown.progress.looping "noLooping")}} - - - {{#if (eq countdown.progress.looping "increasing")}} - - {{else if (eq countdown.progress.looping "decreasing")}} - - {{/if}} - + + + + {{#if (eq countdown.progress.looping "increasing")}} + + {{else if (eq countdown.progress.looping "decreasing")}} + + {{/if}} + + {{/unless}} {{/if}}