mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 05:31:07 +01:00
Fixed so that the countdown Ui positions itself well when RCT video is enabled
This commit is contained in:
parent
a146132171
commit
6973d22db6
2 changed files with 37 additions and 5 deletions
|
|
@ -85,18 +85,19 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
async _onFirstRender(context, options) {
|
async _onFirstRender(context, options) {
|
||||||
await super._onFirstRender(context, options);
|
await super._onFirstRender(context, options);
|
||||||
|
|
||||||
|
if (ui.webrtc.rendered) this.toggleRctPosition();
|
||||||
this.toggleCollapsedPosition(undefined, !ui.sidebar.expanded);
|
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);
|
||||||
const values = Object.entries(setting.countdowns).map(([key, countdown]) => ({
|
const values = Object.entries(setting.countdowns).map(([key, countdown]) => ({
|
||||||
key,
|
key,
|
||||||
countdown,
|
countdown,
|
||||||
ownership: DhCountdowns.#getPlayerOwnership(game.user, setting, countdown)
|
ownership: DhCountdowns.#getPlayerOwnership(game.user, setting, countdown)
|
||||||
}));
|
}));
|
||||||
return values.filter((v) => v.ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE);
|
return values.filter(v => v.ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
|
|
@ -140,11 +141,28 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
toggleCollapsedPosition = async (_, collapsed) => {
|
toggleCollapsedPosition = async (_, collapsed) => {
|
||||||
if (!this.element) return;
|
if (!this.element) return;
|
||||||
|
|
||||||
|
const webrtcPresent = ui.webrtc.rendered && ui.webrtc.classList.contains('right');
|
||||||
|
if (webrtcPresent) this.element.classList.add('rctRight');
|
||||||
|
|
||||||
this.sidebarCollapsed = collapsed;
|
this.sidebarCollapsed = collapsed;
|
||||||
if (!collapsed) this.element.classList.add('expanded');
|
if (!collapsed) this.element.classList.add('expanded');
|
||||||
else this.element.classList.remove('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();
|
||||||
};
|
};
|
||||||
|
|
@ -201,6 +219,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
|
|
||||||
setupHooks() {
|
setupHooks() {
|
||||||
Hooks.on('collapseSidebar', this.toggleCollapsedPosition.bind());
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,6 +228,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
if (options.closeKey) return;
|
if (options.closeKey) return;
|
||||||
|
|
||||||
Hooks.off('collapseSidebar', this.toggleCollapsedPosition);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,18 @@
|
||||||
|
|
||||||
&.expanded {
|
&.expanded {
|
||||||
right: calc(364px * var(--ui-scale));
|
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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue