From 49adeed8c52cc23ccc60b754ffef16d849ba912c Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 21 Sep 2025 22:21:08 +0200 Subject: [PATCH] Added coloured pips to UI cooldowns to signify player visibility if not every player has it --- module/applications/ui/countdowns.mjs | 23 ++++++-- styles/less/ui/countdown/countdown.less | 74 ++++++++++++++++--------- templates/ui/countdowns.hbs | 25 ++++++--- 3 files changed, 83 insertions(+), 39 deletions(-) diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index f95b9688..906e0e55 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -81,6 +81,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application /** @override */ async _prepareContext(options) { const context = await super._prepareContext(options); + context.isGM = game.user.isGM; context.sidebarCollapsed = this.sidebarCollapsed; context.iconOnly = game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) === @@ -89,16 +90,21 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); context.countdowns = Object.keys(setting.countdowns).reduce((acc, key) => { const countdown = setting.countdowns[key]; - const playerOwnership = countdown.ownership[game.user.id]; - const ownership = - playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT - ? setting.defaultOwnership - : playerOwnership; + const ownership = DhCountdowns.#getPlayerOwnership(game.user, setting, countdown); if (ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) return acc; + const playersWithAccess = game.users.reduce((acc, user) => { + const ownership = DhCountdowns.#getPlayerOwnership(user, setting, countdown); + if (!user.isGM && ownership && ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) { + acc.push(user); + } + return acc; + }, []); acc[key] = { ...countdown, - editable: game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER + editable: game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER, + playerAccess: + playersWithAccess.length !== game.users.filter(x => !x.isGM).length ? playersWithAccess : [] }; return acc; }, {}); @@ -106,6 +112,11 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application return context; } + static #getPlayerOwnership(user, setting, countdown) { + const playerOwnership = countdown.ownership[user.id]; + return playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT ? setting.defaultOwnership : playerOwnership; + } + toggleCollapsedPosition = async (_, collapsed) => { this.sidebarCollapsed = collapsed; if (!collapsed) this.element.classList.add('expanded'); diff --git a/styles/less/ui/countdown/countdown.less b/styles/less/ui/countdown/countdown.less index 38a065a2..dc058536 100644 --- a/styles/less/ui/countdown/countdown.less +++ b/styles/less/ui/countdown/countdown.less @@ -53,43 +53,67 @@ .countdown-container { display: flex; - gap: 16px; + justify-content: space-between; &.icon-only { gap: 8px; - .countdown-content { - justify-content: center; + .countdown-main-container { + .countdown-content { + justify-content: center; - .countdown-tools { - gap: 8px; + .countdown-tools { + gap: 8px; + } } } } - img { - width: 44px; - height: 44px; - border-radius: 6px; + .countdown-main-container { + display: flex; + align-items: center; + gap: 16px; + + img { + width: 44px; + height: 44px; + border-radius: 6px; + } + + .countdown-content { + height: 44px; + display: flex; + flex-direction: column; + justify-content: space-between; + + .countdown-tools { + display: flex; + align-items: center; + gap: 16px; + + .progress-tag { + border: 1px solid; + border-radius: 4px; + padding: 2px 4px; + background-color: light-dark(@beige, @dark-blue); + } + } + } } - .countdown-content { - height: 44px; - display: flex; - flex-direction: column; - justify-content: space-between; + .countdown-access-container { + display: grid; + grid-template-columns: 1fr 1fr 1fr; + grid-auto-rows: min-content; + width: 38px; + gap: 4px; - .countdown-tools { - display: flex; - align-items: center; - gap: 16px; - - .progress-tag { - border: 1px solid; - border-radius: 4px; - padding: 2px 4px; - background-color: light-dark(@beige, @dark-blue); - } + .countdown-access { + height: 10px; + width: 10px; + border-radius: 50%; + border: 1px solid light-dark(@dark-blue, @beige-80); + content: ''; } } } diff --git a/templates/ui/countdowns.hbs b/templates/ui/countdowns.hbs index b2a80a04..cd9a740f 100644 --- a/templates/ui/countdowns.hbs +++ b/templates/ui/countdowns.hbs @@ -2,17 +2,26 @@
{{#each countdowns as | countdown id |}}
- -
- {{#unless ../iconOnly}}{{/unless}} -
- {{#if countdown.editable}}{{/if}} -
- {{countdown.progress.current}}/{{countdown.progress.max}} +
+ +
+ {{#unless ../iconOnly}}{{/unless}} +
+ {{#if countdown.editable}}{{/if}} +
+ {{countdown.progress.current}}/{{countdown.progress.max}} +
+ {{#if countdown.editable}}{{/if}}
- {{#if countdown.editable}}{{/if}}
+ {{#if (and @root.isGM (and (not ../iconOnly) (gt countdown.playerAccess.length 0)))}} +
+ {{#each countdown.playerAccess as |player|}} +
+ {{/each}} +
+ {{/if}}
{{/each}}