Removed hooks and just placing the Ui Countdowns in the UI-Right-column-1 placement

This commit is contained in:
WBHarry 2025-11-20 10:47:54 +01:00
parent 6973d22db6
commit 8e29d61535
3 changed files with 7 additions and 61 deletions

View file

@ -81,14 +81,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
return frame; 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 */ /** Returns countdown data filtered by ownership */
#getCountdowns() { #getCountdowns() {
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); 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; : 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 }) => { cooldownRefresh = ({ refreshType }) => {
if (refreshType === RefreshType.Countdown) this.render(); if (refreshType === RefreshType.Countdown) this.render();
}; };
@ -218,8 +185,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
} }
setupHooks() { setupHooks() {
Hooks.on('collapseSidebar', this.toggleCollapsedPosition.bind());
Hooks.on('renderCameraViews', this.toggleRctPosition.bind());
Hooks.on(socketEvent.Refresh, this.cooldownRefresh.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 */ /* Opt out of Foundry's standard behavior of closing all application windows marked as UI when Escape is pressed */
if (options.closeKey) return; if (options.closeKey) return;
Hooks.off('collapseSidebar', this.toggleCollapsedPosition);
Hooks.off('renderCameraViews', this.toggleRctPosition);
Hooks.off(socketEvent.Refresh, this.cooldownRefresh); Hooks.off(socketEvent.Refresh, this.cooldownRefresh);
return super.close(options); return super.close(options);
} }
@ -269,5 +232,8 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
async _onRender(context, options) { async _onRender(context, options) {
await super._onRender(context, options); await super._onRender(context, options);
this.element.hidden = !game.user.isGM && this.#getCountdowns().length === 0; this.element.hidden = !game.user.isGM && this.#getCountdowns().length === 0;
if (options?.force) {
document.getElementById('ui-right-column-1')?.appendChild(this.element);
}
} }
} }

View file

@ -65,7 +65,7 @@
.countdown-edit-container { .countdown-edit-container {
display: grid; display: grid;
grid-template-columns: 48px 1fr 64px; grid-template-columns: 48px 1fr 68px;
align-items: center; align-items: center;
gap: 8px; gap: 8px;

View file

@ -12,38 +12,18 @@
} }
.daggerheart.dh-style.countdowns { .daggerheart.dh-style.countdowns {
z-index: var(--z-index-ui) !important; position: initial;
border: 0; border: 0;
border-radius: 4px; border-radius: 4px;
box-shadow: none; box-shadow: none;
width: 300px; width: 300px;
top: 16px; pointer-events: all;
right: calc(64px * var(--ui-scale)); align-self: flex-end;
transition:
right ease 250ms,
opacity var(--ui-fade-duration) ease,
opacity var(--ui-fade-duration);
.window-title { .window-title {
font-family: @font-body; 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 { &.icon-only {
width: 180px; width: 180px;
min-width: 180px; min-width: 180px;