From 83709e334dfb41a1d3f34d81f68beadb5af5c437 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 21 Sep 2025 23:12:16 +0200 Subject: [PATCH] . --- lang/en.json | 6 ++++-- module/applications/ui/countdownEdit.mjs | 8 ++++++-- module/applications/ui/countdowns.mjs | 9 ++++++--- module/data/countdowns.mjs | 12 +++++++++++- styles/less/ui/countdown/countdown-edit.less | 14 +++++++++++++- styles/less/ui/countdown/countdown.less | 8 +++++++- templates/ui/countdown-edit.hbs | 6 +++++- templates/ui/countdowns.hbs | 17 +++++++++++------ 8 files changed, 63 insertions(+), 17 deletions(-) diff --git a/lang/en.json b/lang/en.json index 16309862..87b8f978 100755 --- a/lang/en.json +++ b/lang/en.json @@ -360,7 +360,8 @@ "currentCountdownMax": "Max: {value}", "category": "Category", "type": "Type", - "defaultOwnershipTooltip": "The default player ownership of countdowns" + "defaultOwnershipTooltip": "The default player ownership of countdowns", + "hideNewCountdowns": "Hide New Countdowns" }, "DaggerheartMenu": { "title": "GM Tools", @@ -2473,7 +2474,8 @@ }, "Countdowns": { "title": "Countdowns", - "toggleIconMode": "Toggle Icon Only" + "toggleIconMode": "Toggle Icon Only", + "noPlayerAccess": "This countdown isn't visible to any players" }, "ItemBrowser": { "title": "Daggerheart Compendium Browser", diff --git a/module/applications/ui/countdownEdit.mjs b/module/applications/ui/countdownEdit.mjs index efac2b47..e292a405 100644 --- a/module/applications/ui/countdownEdit.mjs +++ b/module/applications/ui/countdownEdit.mjs @@ -10,6 +10,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio this.data = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); this.editingCountdowns = new Set(); this.currentEditCountdown = null; + this.hideNewCountdowns = false; } get title() { @@ -45,6 +46,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio context.defaultOwnership = this.data.defaultOwnership; context.countdownBaseTypes = CONFIG.DH.GENERAL.countdownBaseTypes; context.countdownTypes = CONFIG.DH.GENERAL.countdownTypes; + context.hideNewCountdowns = this.hideNewCountdowns; context.countdowns = Object.keys(this.data.countdowns).reduce((acc, key) => { const countdown = this.data.countdowns[key]; acc[key] = { @@ -107,7 +109,9 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio } static async updateData(_event, _, formData) { - this.updateSetting(foundry.utils.expandObject(formData.object)); + const { hideNewCountdowns, ...settingsData } = foundry.utils.expandObject(formData.object); + this.hideNewCountdowns = hideNewCountdowns; + this.updateSetting(settingsData); } async gmSetSetting(data) { @@ -124,7 +128,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio this.editingCountdowns.add(id); this.currentEditCountdown = id; this.updateSetting({ - [`countdowns.${id}`]: DhCountdown.defaultCountdown() + [`countdowns.${id}`]: DhCountdown.defaultCountdown(null, this.hideNewCountdowns) }); } diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index 906e0e55..075944a3 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -100,11 +100,12 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application } return acc; }, []); + const nonGmPlayers = game.users.filter(x => !x.isGM); acc[key] = { ...countdown, editable: game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER, - playerAccess: - playersWithAccess.length !== game.users.filter(x => !x.isGM).length ? playersWithAccess : [] + playerAccess: playersWithAccess.length !== nonGmPlayers.length ? playersWithAccess : [], + noPlayerAccess: nonGmPlayers.length && playersWithAccess.length === 0 }; return acc; }, {}); @@ -114,7 +115,9 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application static #getPlayerOwnership(user, setting, countdown) { const playerOwnership = countdown.ownership[user.id]; - return playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT ? setting.defaultOwnership : playerOwnership; + return playerOwnership === undefined || playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT + ? setting.defaultOwnership + : playerOwnership; } toggleCollapsedPosition = async (_, collapsed) => { diff --git a/module/data/countdowns.mjs b/module/data/countdowns.mjs index 915599ff..6db4cbeb 100644 --- a/module/data/countdowns.mjs +++ b/module/data/countdowns.mjs @@ -181,11 +181,21 @@ export class DhCountdown extends foundry.abstract.DataModel { }; } - static defaultCountdown(type) { + static defaultCountdown(type, playerHidden) { + const ownership = playerHidden + ? game.users.reduce((acc, user) => { + if (!user.isGM) { + acc[user.id] = CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE; + } + return acc; + }, {}) + : undefined; + return { type: type ?? CONFIG.DH.GENERAL.countdownBaseTypes.narrative.id, name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Countdown.newCountdown'), img: 'icons/magic/time/hourglass-yellow-green.webp', + ownership: ownership, progress: { current: 1, max: 1 diff --git a/styles/less/ui/countdown/countdown-edit.less b/styles/less/ui/countdown/countdown-edit.less index 6d7377c8..07ca75ec 100644 --- a/styles/less/ui/countdown/countdown-edit.less +++ b/styles/less/ui/countdown/countdown-edit.less @@ -21,9 +21,21 @@ .header-tools { display: grid; - grid-template-columns: 1fr 144px; + grid-template-columns: 2fr 1fr 144px; gap: 8px; + .hide-tools { + white-space: nowrap; + flex-wrap: nowrap; + display: flex; + align-items: center; + + input { + position: relative; + top: 2px; + } + } + .header-main-button { height: 32px; flex: 1; diff --git a/styles/less/ui/countdown/countdown.less b/styles/less/ui/countdown/countdown.less index dc058536..d4207ba7 100644 --- a/styles/less/ui/countdown/countdown.less +++ b/styles/less/ui/countdown/countdown.less @@ -81,7 +81,6 @@ } .countdown-content { - height: 44px; display: flex; flex-direction: column; justify-content: space-between; @@ -116,6 +115,13 @@ content: ''; } } + + .countdown-no-access-container { + width: 38px; + display: flex; + align-items: center; + justify-content: center; + } } } } diff --git a/templates/ui/countdown-edit.hbs b/templates/ui/countdown-edit.hbs index a1c7deac..6b9e1a32 100644 --- a/templates/ui/countdown-edit.hbs +++ b/templates/ui/countdown-edit.hbs @@ -5,7 +5,11 @@
- + +
+ + +
{{#if isGM}}
diff --git a/templates/ui/countdowns.hbs b/templates/ui/countdowns.hbs index cd9a740f..122b36e6 100644 --- a/templates/ui/countdowns.hbs +++ b/templates/ui/countdowns.hbs @@ -15,12 +15,17 @@
- {{#if (and @root.isGM (and (not ../iconOnly) (gt countdown.playerAccess.length 0)))}} -
- {{#each countdown.playerAccess as |player|}} -
- {{/each}} -
+ {{#if (and @root.isGM (not ../iconOnly))}} + {{#if (gt countdown.playerAccess.length 0)}} +
+ {{#each countdown.playerAccess as |player|}} +
+ {{/each}} +
+ {{/if}} + {{#if countdown.noPlayerAccess}} +
+ {{/if}} {{/if}} {{/each}}