From dcd42656f00f566f9c476b47a1d318e16fdaaf2d Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 14 Sep 2025 23:32:53 +0200 Subject: [PATCH] . --- lang/en.json | 5 +-- module/applications/sidebar/sidebar.mjs | 41 +++++++++++++++++++++++- module/applications/ui/countdownEdit.mjs | 19 +++++++++++ module/applications/ui/countdowns.mjs | 40 +++++++++++++++++++++-- module/config/flagsConfig.mjs | 3 +- module/config/generalConfig.mjs | 5 +++ styles/less/ui/countdown/countdown.less | 17 ++++++++++ templates/ui/countdown-edit.hbs | 14 ++++---- templates/ui/countdowns.hbs | 6 ++-- 9 files changed, 135 insertions(+), 15 deletions(-) diff --git a/lang/en.json b/lang/en.json index 9e48e3c5..bbd494a9 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2472,7 +2472,7 @@ }, "Countdowns": { "title": "Countdowns", - "minimize": "Minimize" + "toggleIconMode": "Toggle Icon Only" }, "ItemBrowser": { "title": "Daggerheart Compendium Browser", @@ -2581,7 +2581,8 @@ "subclassesAlreadyPresent": "You already have a class and multiclass subclass", "noDiceSystem": "Your selected dice {system} does not have a {faces} dice", "gmMenuRefresh": "You refreshed all actions and resources {types}", - "subclassAlreadyLinked": "{name} is already a subclass in the class {class}. Remove it from there if you want it to be a subclass to this class." + "subclassAlreadyLinked": "{name} is already a subclass in the class {class}. Remove it from there if you want it to be a subclass to this class.", + "gmRequired": "This action requires an online GM" }, "Sidebar": { "daggerheartMenu": { diff --git a/module/applications/sidebar/sidebar.mjs b/module/applications/sidebar/sidebar.mjs index fad39ac5..0c695db2 100644 --- a/module/applications/sidebar/sidebar.mjs +++ b/module/applications/sidebar/sidebar.mjs @@ -1,10 +1,49 @@ export default class DhSidebar extends Sidebar { /** @override */ static TABS = { - ...super.TABS, + chat: { + documentName: 'ChatMessage' + }, + combat: { + documentName: 'Combat' + }, + scenes: { + documentName: 'Scene', + gmOnly: true + }, + actors: { + documentName: 'Actor' + }, + items: { + documentName: 'Item' + }, + journal: { + documentName: 'JournalEntry', + tooltip: 'SIDEBAR.TabJournal' + }, + tables: { + documentName: 'RollTable' + }, + cards: { + documentName: 'Cards' + }, + macros: { + documentName: 'Macro' + }, + playlists: { + documentName: 'Playlist' + }, + compendium: { + tooltip: 'SIDEBAR.TabCompendium', + icon: 'fa-solid fa-book-atlas' + }, daggerheartMenu: { tooltip: 'DAGGERHEART.UI.Sidebar.daggerheartMenu.title', img: 'systems/daggerheart/assets/logos/FoundryBorneLogoWhite.svg' + }, + settings: { + tooltip: 'SIDEBAR.TabSettings', + icon: 'fa-solid fa-gears' } }; diff --git a/module/applications/ui/countdownEdit.mjs b/module/applications/ui/countdownEdit.mjs index 754c5071..f5782a2b 100644 --- a/module/applications/ui/countdownEdit.mjs +++ b/module/applications/ui/countdownEdit.mjs @@ -39,6 +39,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio async _prepareContext(_options) { const context = await super._prepareContext(_options); + context.isGM = game.user.isGM; context.ownershipDefaultOptions = CONFIG.DH.GENERAL.basicOwnershiplevels; context.defaultOwnership = this.data.defaultOwnership; context.countdownBaseTypes = CONFIG.DH.GENERAL.countdownBaseTypes; @@ -61,7 +62,25 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio return context; } + canPerformEdit() { + if (game.user.isGM) return true; + + const noGM = !game.users.find(x => x.isGM && x.active); + if (noGM) { + ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.gmRequired')); + return false; + } + + return true; + } + async updateSetting(update) { + const noGM = !game.users.find(x => x.isGM && x.active); + if (noGM) { + ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.gmRequired')); + return; + } + await this.data.updateSource(update); await emitAsGM(GMUpdateEvent.UpdateCountdowns, this.gmSetSetting.bind(this.data), this.data, null, { refreshType: RefreshType.Countdown diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index 7645526f..d30b586e 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -31,6 +31,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application minimizable: false }, actions: { + toggleViewMode: DhCountdowns.#toggleViewMode, decreaseCountdown: (_, target) => this.editCountdown(false, target), increaseCountdown: (_, target) => this.editCountdown(true, target) }, @@ -60,11 +61,18 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application /**@inheritdoc */ async _renderFrame(options) { const frame = await super._renderFrame(options); + + const iconOnly = + game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) === + CONFIG.DH.GENERAL.countdownAppMode.iconOnly; + if (iconOnly) frame.classList.add('icon-only'); + else frame.classList.remove('icon-only'); + const header = frame.querySelector('.window-header'); header.querySelector('button[data-action="close"]').remove(); - const minimizeTooltip = game.i18n.localize('DAGGERHEART.UI.Countdowns.minimize'); - const minimizeButton = ``; + const minimizeTooltip = game.i18n.localize('DAGGERHEART.UI.Countdowns.toggleIconMode'); + const minimizeButton = ``; header.insertAdjacentHTML('beforeEnd', minimizeButton); return frame; @@ -74,6 +82,9 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application async _prepareContext(options) { const context = await super._prepareContext(options); context.sidebarCollapsed = this.sidebarCollapsed; + context.iconOnly = + game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) === + CONFIG.DH.GENERAL.countdownAppMode.iconOnly; const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); context.countdowns = Object.keys(setting.countdowns).reduce((acc, key) => { @@ -105,7 +116,32 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application if (refreshType === RefreshType.Countdown) this.render(); }; + canPerformEdit() { + if (game.user.isGM) return true; + + const noGM = !game.users.find(x => x.isGM && x.active); + if (noGM) { + ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.gmRequired')); + return false; + } + + return true; + } + + static async #toggleViewMode() { + const currentMode = game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode); + const appMode = CONFIG.DH.GENERAL.countdownAppMode; + const newMode = currentMode === appMode.textIcon ? appMode.iconOnly : appMode.textIcon; + await game.user.setFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode, newMode); + + if (newMode === appMode.iconOnly) this.element.classList.add('icon-only'); + else this.element.classList.remove('icon-only'); + this.render(); + } + static async editCountdown(increase, target) { + if (!this.canPerformEdit()) return; + const settings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); const countdown = settings.countdowns[target.id]; const newCurrent = increase diff --git a/module/config/flagsConfig.mjs b/module/config/flagsConfig.mjs index c2a6dff2..067c0f71 100644 --- a/module/config/flagsConfig.mjs +++ b/module/config/flagsConfig.mjs @@ -11,5 +11,6 @@ export const encounterCountdown = { export const itemAttachmentSource = 'attachmentSource'; export const userFlags = { - welcomeMessage: 'welcome-message' + welcomeMessage: 'welcome-message', + countdownMode: 'countdown-mode' }; diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index 12c7d3c0..900dcfbc 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -672,3 +672,8 @@ export const countdownBaseTypes = { name: 'DAGGERHEART.APPLICATIONS.Countdown.types.encounter' } }; + +export const countdownAppMode = { + textIcon: 'text-icon', + iconOnly: 'icon-only' +}; diff --git a/styles/less/ui/countdown/countdown.less b/styles/less/ui/countdown/countdown.less index 6f21a000..e1bb64e8 100644 --- a/styles/less/ui/countdown/countdown.less +++ b/styles/less/ui/countdown/countdown.less @@ -22,6 +22,11 @@ right: 364px; } + &.icon-only { + width: 180px; + min-width: 180px; + } + .window-header { cursor: default; border-bottom: 0; @@ -40,6 +45,18 @@ display: flex; gap: 16px; + &.icon-only { + gap: 8px; + + .countdown-content { + justify-content: center; + + .countdown-tools { + gap: 8px; + } + } + } + img { width: 44px; height: 44px; diff --git a/templates/ui/countdown-edit.hbs b/templates/ui/countdown-edit.hbs index 25791a64..0d034556 100644 --- a/templates/ui/countdown-edit.hbs +++ b/templates/ui/countdown-edit.hbs @@ -4,12 +4,14 @@
-
- - -
+ {{#if isGM}} +
+ + +
+ {{/if}}
diff --git a/templates/ui/countdowns.hbs b/templates/ui/countdowns.hbs index 86c47571..b2a80a04 100644 --- a/templates/ui/countdowns.hbs +++ b/templates/ui/countdowns.hbs @@ -1,10 +1,10 @@
{{#each countdowns as | countdown id |}} -
- +
+
- + {{#unless ../iconOnly}}{{/unless}}
{{#if countdown.editable}}{{/if}}