From 7c4200b4318e621a76467a525ae65697094765c8 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:13:24 +0100 Subject: [PATCH 1/6] [Fix] Countdown UI Initial Position (#1267) * . * Fixed so countdown ui respects foundry UiScale * Raised system version --- module/applications/ui/countdowns.mjs | 16 ++++++++++++++-- styles/less/ui/countdown/countdown.less | 4 ++-- system.json | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index 3d0b32ae..b7d19ede 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -81,6 +81,13 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application return frame; } + /**@inheritdoc */ + async _onFirstRender(context, options) { + await super._onFirstRender(context, options); + + this.toggleCollapsedPosition(undefined, !ui.sidebar.expanded); + } + /** @override */ async _prepareContext(options) { const context = await super._prepareContext(options); @@ -124,6 +131,8 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application } toggleCollapsedPosition = async (_, collapsed) => { + if (!this.element) return; + this.sidebarCollapsed = collapsed; if (!collapsed) this.element.classList.add('expanded'); else this.element.classList.remove('expanded'); @@ -188,10 +197,13 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application Hooks.on(socketEvent.Refresh, this.cooldownRefresh.bind()); } - close(options) { + async close(options) { + /* Opt out of Foundry's standard behavior of closing all application windows marked as UI when Escape is pressed */ + if (options.closeKey) return; + Hooks.off('collapseSidebar', this.toggleCollapsedPosition); Hooks.off(socketEvent.Refresh, this.cooldownRefresh); - super.close(options); + return super.close(options); } static async updateCountdowns(progressType) { diff --git a/styles/less/ui/countdown/countdown.less b/styles/less/ui/countdown/countdown.less index 9fa42ec7..0f91bad4 100644 --- a/styles/less/ui/countdown/countdown.less +++ b/styles/less/ui/countdown/countdown.less @@ -18,7 +18,7 @@ box-shadow: none; width: 300px; top: 16px; - right: 64px; + right: calc(64px * var(--ui-scale)); transition: right ease 250ms, opacity var(--ui-fade-duration) ease, @@ -29,7 +29,7 @@ } &.expanded { - right: 364px; + right: calc(364px * var(--ui-scale)); } &.icon-only { diff --git a/system.json b/system.json index a16b3562..a7c79226 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "daggerheart", "title": "Daggerheart", "description": "An unofficial implementation of the Daggerheart system", - "version": "1.2.0", + "version": "1.2.1", "compatibility": { "minimum": "13", "verified": "13.350", From 64085283193ffd6185a4bee78dc90158b3ac0ba0 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:13:37 +0100 Subject: [PATCH 2/6] The delete button wasn't working for them with broken links (#1266) --- module/applications/sheets/items/class.mjs | 4 ++-- templates/sheets/items/class/features.hbs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module/applications/sheets/items/class.mjs b/module/applications/sheets/items/class.mjs index b88e6ca3..e7e00c42 100644 --- a/module/applications/sheets/items/class.mjs +++ b/module/applications/sheets/items/class.mjs @@ -203,10 +203,10 @@ export default class ClassSheet extends DHBaseItemSheet { if (target === 'subclasses') { const subclass = await foundry.utils.fromUuid(uuid); - await subclass.update({ 'system.linkedClass': null }); + await subclass?.update({ 'system.linkedClass': null }); } - await this.document.update({ [`system.${target}`]: prop.filter(i => i.uuid !== uuid).map(x => x.uuid) }); + await this.document.update({ [`system.${target}`]: prop.filter(i => i && i.uuid !== uuid).map(x => x.uuid) }); } /** diff --git a/templates/sheets/items/class/features.hbs b/templates/sheets/items/class/features.hbs index 6ed449dc..ef940730 100644 --- a/templates/sheets/items/class/features.hbs +++ b/templates/sheets/items/class/features.hbs @@ -50,7 +50,7 @@ class='effect-control' data-action='removeItemFromCollection' data-target="subclasses" - data-uuid={{subclass.uuid}} + data-uuid="{{subclass.uuid}}" data-tooltip='{{localize "CONTROLS.CommonDelete"}}' > From c4b227de41e3a2f5e86823119fab619fb39a6745 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:13:53 +0100 Subject: [PATCH 3/6] Added a system setting (appearance) to remove the Countdown UI (#1265) --- daggerheart.mjs | 10 ++++++---- lang/en.json | 3 +++ module/data/settings/Appearance.mjs | 1 + templates/settings/appearance-settings/main.hbs | 4 ++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/daggerheart.mjs b/daggerheart.mjs index 651736a4..f497b766 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -167,12 +167,14 @@ Hooks.on('setup', () => { }); Hooks.on('ready', async () => { + const appearanceSettings = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance); ui.resources = new CONFIG.ui.resources(); - if (game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).displayFear !== 'hide') - ui.resources.render({ force: true }); + if (appearanceSettings.displayFear !== 'hide') ui.resources.render({ force: true }); - ui.countdowns = new CONFIG.ui.countdowns(); - ui.countdowns.render({ force: true }); + if (appearanceSettings.displayCountdownUI) { + ui.countdowns = new CONFIG.ui.countdowns(); + ui.countdowns.render({ force: true }); + } if (!(ui.compendiumBrowser instanceof applications.ui.ItemBrowser)) ui.compendiumBrowser = new applications.ui.ItemBrowser(); diff --git a/lang/en.json b/lang/en.json index b63a3aac..c3a20472 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2219,6 +2219,9 @@ "displayFear": { "label": "Display Fear" }, + "displayCountdownUI": { + "label": "Display Countdown UI" + }, "showGenericStatusEffects": { "label": "Show Foundry Status Effects" }, diff --git a/module/data/settings/Appearance.mjs b/module/data/settings/Appearance.mjs index 47909b2c..7a5c730a 100644 --- a/module/data/settings/Appearance.mjs +++ b/module/data/settings/Appearance.mjs @@ -24,6 +24,7 @@ export default class DhAppearance extends foundry.abstract.DataModel { choices: CONFIG.DH.GENERAL.fearDisplay, initial: CONFIG.DH.GENERAL.fearDisplay.token.value }), + displayCountdownUI: new BooleanField({ initial: true }), diceSoNice: new SchemaField({ hope: diceStyle({ fg: '#ffffff', bg: '#ffe760', outline: '#000000', edge: '#ffffff' }), fear: diceStyle({ fg: '#000000', bg: '#0032b1', outline: '#ffffff', edge: '#000000' }), diff --git a/templates/settings/appearance-settings/main.hbs b/templates/settings/appearance-settings/main.hbs index fda6243b..75a7e634 100644 --- a/templates/settings/appearance-settings/main.hbs +++ b/templates/settings/appearance-settings/main.hbs @@ -8,6 +8,10 @@ value=setting.displayFear localize=true}} {{formGroup + fields.displayCountdownUI + value=setting.displayCountdownUI + localize=true}} + {{formGroup fields.showGenericStatusEffects value=setting.showGenericStatusEffects localize=true}} From 54109bf655e14253956314fb8d432d34587782e3 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:14:06 +0100 Subject: [PATCH 4/6] Fixed so countdown migration doesn't get stuck because of countdowns set to 'Limited' ownership (#1264) --- module/systemRegistration/migrations.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/module/systemRegistration/migrations.mjs b/module/systemRegistration/migrations.mjs index 98a9a7e6..e3777a94 100644 --- a/module/systemRegistration/migrations.mjs +++ b/module/systemRegistration/migrations.mjs @@ -1,3 +1,5 @@ +import { RefreshType, socketEvent } from './socket.mjs'; + export async function runMigrations() { let lastMigrationVersion = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion); if (!lastMigrationVersion) lastMigrationVersion = game.system.version; @@ -158,7 +160,8 @@ export async function runMigrations() { ...countdown, type: type, ownership: Object.keys(countdown.ownership.players).reduce((acc, key) => { - acc[key] = countdown.ownership.players[key].type; + acc[key] = + countdown.ownership.players[key].type === 1 ? 2 : countdown.ownership.players[key].type; return acc; }, {}), progress: { @@ -179,6 +182,12 @@ export async function runMigrations() { }); await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns, countdownSettings); + game.socket.emit(`system.${CONFIG.DH.id}`, { + action: socketEvent.Refresh, + data: { refreshType: RefreshType.Countdown } + }); + Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown }); + lastMigrationVersion = '1.2.0'; } From d1caded970636505ca74c86d286d1625670ca18b Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:14:17 +0100 Subject: [PATCH 5/6] Fixed so that the Homebrew settings screen for homebrew weapon/armor features gets a correct title instead of 'Downtime Moves' (#1263) --- lang/en.json | 3 +++ module/applications/settings/homebrewSettings.mjs | 7 +++++++ .../sheets-configs/setting-feature-config.mjs | 9 +++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lang/en.json b/lang/en.json index c3a20472..14faa9d8 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2347,6 +2347,9 @@ }, "Homebrew": { "newDowntimeMove": "Downtime Move", + "downtimeMove": "Downtime Move", + "armorFeature": "Armor Feature", + "weaponFeature": "Weapon Feaure", "newFeature": "New ItemFeature", "downtimeMoves": "Downtime Moves", "itemFeatures": "Item Features", diff --git a/module/applications/settings/homebrewSettings.mjs b/module/applications/settings/homebrewSettings.mjs index e880f7ee..8e566106 100644 --- a/module/applications/settings/homebrewSettings.mjs +++ b/module/applications/settings/homebrewSettings.mjs @@ -147,7 +147,14 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli const path = isDowntime ? `restMoves.${type}.moves.${id}` : `itemFeatures.${type}.${id}`; const featureBase = isDowntime ? this.settings.restMoves[type].moves[id] : this.settings.itemFeatures[type][id]; + const configTitle = isDowntime + ? game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.downtimeMove') + : type === 'armorFeatures' + ? game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.armorFeature') + : game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.weaponFeature'); + const editedBase = await game.system.api.applications.sheetConfigs.SettingFeatureConfig.configure( + configTitle, featureBase, path, this.settings, diff --git a/module/applications/sheets-configs/setting-feature-config.mjs b/module/applications/sheets-configs/setting-feature-config.mjs index e775f93d..832954ad 100644 --- a/module/applications/sheets-configs/setting-feature-config.mjs +++ b/module/applications/sheets-configs/setting-feature-config.mjs @@ -4,9 +4,10 @@ import DHActionConfig from './action-config.mjs'; const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api; export default class SettingFeatureConfig extends HandlebarsApplicationMixin(ApplicationV2) { - constructor(move, movePath, settings, optionalParts, options) { + constructor(configTitle, move, movePath, settings, optionalParts, options) { super(options); + this.configTitle = configTitle; this.move = move; this.movePath = movePath; @@ -19,7 +20,7 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App } get title() { - return game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.downtimeMoves'); + return this.configTitle; } static DEFAULT_OPTIONS = { @@ -200,9 +201,9 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App if (!options.submitted) this.move = null; } - static async configure(move, movePath, settings, optionalParts, options = {}) { + static async configure(configTitle, move, movePath, settings, optionalParts, options = {}) { return new Promise(resolve => { - const app = new this(move, movePath, settings, optionalParts, options); + const app = new this(configTitle, move, movePath, settings, optionalParts, options); app.addEventListener('close', () => resolve(app.move), { once: true }); app.render({ force: true }); }); From 72bf0171b341eddaca7820b61e4287a16161245b Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:14:56 +0100 Subject: [PATCH 6/6] Fixed so it uses the currently viewed scene instead of the active one (#1261) --- module/applications/hud/tokenHUD.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/applications/hud/tokenHUD.mjs b/module/applications/hud/tokenHUD.mjs index bd846da5..a5fd719f 100644 --- a/module/applications/hud/tokenHUD.mjs +++ b/module/applications/hud/tokenHUD.mjs @@ -89,7 +89,7 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD { setTimeout(() => token.document.delete(), animationDuration); } } else { - const activeScene = game.scenes.find(x => x.active); + const activeScene = game.scenes.find(x => x.id === game.user.viewedScene); const partyTokenData = []; for (let member of this.actor.system.partyMembers) { const data = await member.getTokenDocument();