This commit is contained in:
WBHarry 2025-11-18 22:25:26 +01:00
parent 615b7eb4a5
commit a6931b5b89
6 changed files with 62 additions and 20 deletions

View file

@ -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",

View file

@ -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;

View file

@ -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;
}, {});

View file

@ -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;
}
}
}
}

View file

@ -35,12 +35,14 @@
<div class="countdown-edit-sub-tag">{{countdown.progress.typeName}}</div>
{{#unless (eq countdown.progress.looping "noLooping")}}
<i class="fa-solid fa-repeat"></i>
{{#if (eq countdown.progress.looping "increasing")}}
<i class="fa-solid fa-angles-up"></i>
{{else if (eq countdown.progress.looping "decreasing")}}
<i class="fa-solid fa-angles-down"></i>
{{/if}}
<div class="countdown-edit-loop" data-tooltip="{{countdown.loopTooltip}}">
<i class="fa-solid fa-repeat"></i>
{{#if (eq countdown.progress.looping "increasing")}}
<i class="loop-marker fa-solid fa-angles-up"></i>
{{else if (eq countdown.progress.looping "decreasing")}}
<i class="loop-marker fa-solid fa-angles-down"></i>
{{/if}}
</div>
{{/unless}}
</div>
</div>

View file

@ -15,19 +15,21 @@
{{#if countdown.editable}}<a data-action="increaseCountdown" id="{{id}}"><i class="fa-solid fa-plus"></i></a>{{/if}}
</div>
<div class="countdown-tool-icons">
{{#if (and @root.isGM (not ../iconOnly))}}
{{#if countdown.noPlayerAccess}}
{{#if (not ../iconOnly)}}
{{#if (and countdown.noPlayerAccess @root.isGM)}}
<i class="fa-solid fa-eye-slash" data-tooltip="{{localize "DAGGERHEART.UI.Countdowns.noPlayerAccess"}}"></i>
{{/if}}
{{#unless (eq countdown.progress.looping "noLooping")}}
<a class="looping-container {{#if (eq countdown.progress.current 0)}}should-loop{{/if}}" {{#if (gt countdown.progress.current 0)}}disabled{{/if}} data-action="loopCountdown" id="{{id}}">
<i class="loop-marker fa-solid fa-repeat"></i>
{{#if (eq countdown.progress.looping "increasing")}}
<i class="direction-marker fa-solid fa-angles-up"></i>
{{else if (eq countdown.progress.looping "decreasing")}}
<i class="direction-marker fa-solid fa-angles-down"></i>
{{/if}}
</a>
<span data-tooltip="{{countdown.loopTooltip}}">
<a class="looping-container {{#if countdown.shouldLoop}}should-loop{{/if}}" {{#if countdown.loopDisabled}}disabled{{/if}} data-action="loopCountdown" id="{{id}}">
<i class="loop-marker fa-solid fa-repeat"></i>
{{#if (eq countdown.progress.looping "increasing")}}
<i class="direction-marker fa-solid fa-angles-up" data-tooltip="{{localize "DAGGERHEART.UI.Countdowns.increasingLoop"}}"></i>
{{else if (eq countdown.progress.looping "decreasing")}}
<i class="direction-marker fa-solid fa-angles-down" data-tooltip="{{localize "DAGGERHEART.UI.Countdowns.decreasingLoop"}}"></i>
{{/if}}
</a>
</span>
{{/unless}}
{{/if}}
</div>