From 8e29d61535c83abc3e914f583979b7c1fbf6f89a Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 20 Nov 2025 10:47:54 +0100 Subject: [PATCH] Removed hooks and just placing the Ui Countdowns in the UI-Right-column-1 placement --- module/applications/ui/countdowns.mjs | 40 ++------------------ styles/less/ui/countdown/countdown-edit.less | 2 +- styles/less/ui/countdown/countdown.less | 26 ++----------- 3 files changed, 7 insertions(+), 61 deletions(-) diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index 5a19418b..55df92b9 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -81,14 +81,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application return frame; } - /**@inheritdoc */ - async _onFirstRender(context, options) { - await super._onFirstRender(context, options); - - if (ui.webrtc.rendered) this.toggleRctPosition(); - this.toggleCollapsedPosition(undefined, !ui.sidebar.expanded); - } - /** Returns countdown data filtered by ownership */ #getCountdowns() { const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); @@ -138,31 +130,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application : playerOwnership; } - toggleCollapsedPosition = async (_, collapsed) => { - if (!this.element) return; - - const webrtcPresent = ui.webrtc.rendered && ui.webrtc.classList.contains('right'); - if (webrtcPresent) this.element.classList.add('rctRight'); - - this.sidebarCollapsed = collapsed; - if (!collapsed) this.element.classList.add('expanded'); - else this.element.classList.remove('expanded'); - }; - - toggleRctPosition = async data => { - if (!this.element) return; - - const webrtcData = data ?? ui.webrtc; - const onTop = webrtcData.classList.contains('horizontal') && webrtcData.classList.contains('top'); - const onRight = webrtcData.classList.contains('vertical') && webrtcData.classList.contains('right'); - if (!onTop && !onRight) return; - - if (onTop) this.element.classList.add('rctTop'); - else this.element.classList.remove('rctTop'); - if (onRight) this.element.classList.add('rctRight'); - else this.element.classList.remove('rctRight'); - }; - cooldownRefresh = ({ refreshType }) => { if (refreshType === RefreshType.Countdown) this.render(); }; @@ -218,8 +185,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application } setupHooks() { - Hooks.on('collapseSidebar', this.toggleCollapsedPosition.bind()); - Hooks.on('renderCameraViews', this.toggleRctPosition.bind()); Hooks.on(socketEvent.Refresh, this.cooldownRefresh.bind()); } @@ -227,8 +192,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application /* 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('renderCameraViews', this.toggleRctPosition); Hooks.off(socketEvent.Refresh, this.cooldownRefresh); return super.close(options); } @@ -269,5 +232,8 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application async _onRender(context, options) { await super._onRender(context, options); this.element.hidden = !game.user.isGM && this.#getCountdowns().length === 0; + if (options?.force) { + document.getElementById('ui-right-column-1')?.appendChild(this.element); + } } } diff --git a/styles/less/ui/countdown/countdown-edit.less b/styles/less/ui/countdown/countdown-edit.less index 9051cccb..c8092403 100644 --- a/styles/less/ui/countdown/countdown-edit.less +++ b/styles/less/ui/countdown/countdown-edit.less @@ -65,7 +65,7 @@ .countdown-edit-container { display: grid; - grid-template-columns: 48px 1fr 64px; + grid-template-columns: 48px 1fr 68px; align-items: center; gap: 8px; diff --git a/styles/less/ui/countdown/countdown.less b/styles/less/ui/countdown/countdown.less index 15b498ea..4adeff87 100644 --- a/styles/less/ui/countdown/countdown.less +++ b/styles/less/ui/countdown/countdown.less @@ -12,38 +12,18 @@ } .daggerheart.dh-style.countdowns { - z-index: var(--z-index-ui) !important; + position: initial; border: 0; border-radius: 4px; box-shadow: none; width: 300px; - top: 16px; - right: calc(64px * var(--ui-scale)); - transition: - right ease 250ms, - opacity var(--ui-fade-duration) ease, - opacity var(--ui-fade-duration); + pointer-events: all; + align-self: flex-end; .window-title { font-family: @font-body; } - &.expanded { - right: calc(364px * var(--ui-scale)); - - &.rctRight { - right: calc(664px * var(--ui-scale)); - } - } - - &.rctTop { - top: calc(240px * var(--ui-scale)); - } - - &.rctRight { - right: calc(364px * var(--ui-scale)); - } - &.icon-only { width: 180px; min-width: 180px;