mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-23 19:09:55 +02:00
Fix top center and top right positioning in some situations (#2108)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
This commit is contained in:
parent
0471164456
commit
8d94d5f2ea
7 changed files with 53 additions and 19 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import { enrichedDualityRoll } from '../../enrichers/DualityRollEnricher.mjs';
|
||||
import { enrichedFateRoll, getFateTypeData } from '../../enrichers/FateRollEnricher.mjs';
|
||||
import { getCommandTarget, rollCommandToJSON } from '../../helpers/utils.mjs';
|
||||
import FearTracker from './fearTracker.mjs';
|
||||
|
||||
export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLog {
|
||||
constructor(options) {
|
||||
|
|
@ -284,7 +283,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
|
||||
_toggleNotifications({ closing = false } = {}) {
|
||||
super._toggleNotifications(closing)
|
||||
FearTracker.handleOffSet();
|
||||
ui.resources.handleOffset();
|
||||
}
|
||||
|
||||
async onRollReloadCheck(_event, messageData) {
|
||||
|
|
|
|||
|
|
@ -130,5 +130,7 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
|
|||
if (options?.force) {
|
||||
document.getElementById('ui-right-column-1')?.appendChild(this.element);
|
||||
}
|
||||
|
||||
ui.resources.handleOffset();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ export default class FearTracker extends HandlebarsApplicationMixin(ApplicationV
|
|||
|
||||
const fearPosition = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).fearPosition;
|
||||
|
||||
if (options.isFirstRender) FearTracker.handleOffSet();
|
||||
if (options.isFirstRender) this.handleOffset();
|
||||
if (!options.force) return;
|
||||
|
||||
this.handleStyleElement(fearPosition);
|
||||
|
|
@ -134,17 +134,37 @@ export default class FearTracker extends HandlebarsApplicationMixin(ApplicationV
|
|||
this.element.classList.add(fearPosition);
|
||||
}
|
||||
|
||||
static handleOffSet() {
|
||||
handleOffset() {
|
||||
const fearTracker = document.getElementById('resources');
|
||||
const hotbar = document.getElementById('hotbar');
|
||||
|
||||
const countdowns = document.getElementById('countdowns');
|
||||
if (!fearTracker) return;
|
||||
|
||||
const offset = Number(hotbar.style.getPropertyValue('--offset').replace(/px$/, '')) || 0;
|
||||
let offset = Math.max(0, Number(hotbar.style.getPropertyValue('--offset').replace(/px$/, '')) || 0);
|
||||
offset -= 13;
|
||||
|
||||
if (offset > 0) return;
|
||||
// If the countdowns overlaps the fear, offset some more. Countdown based offsets only need to be halved (due to centering)
|
||||
if (this.fearPosition === 'topCenter') {
|
||||
const effectsDisplay = document.getElementById('effects-display');
|
||||
const top = document.getElementById('ui-top');
|
||||
|
||||
fearTracker.style.setProperty('--offset', `${offset - 13}px`);
|
||||
// Logic derived from the internal code's ChatLog#offsetHotbar(). Since the sidebar might be mid animation, we can't really check directly.
|
||||
const { uiScale } = game.settings.get('core', 'uiConfig');
|
||||
const sidebarWidth = (348 * ui.sidebar.expanded) / uiScale;
|
||||
const countdownsWidth = countdowns.getBoundingClientRect().width;
|
||||
const effectsWidth = effectsDisplay.getBoundingClientRect().width;
|
||||
const rightWidth = sidebarWidth + countdownsWidth + 16 + (effectsWidth ? 62 : 0);
|
||||
const countdownLeftEdge = window.innerWidth - rightWidth - 16; // w/ extra padding
|
||||
|
||||
const topBounds = top.getBoundingClientRect();
|
||||
const fearTrackerWidth = fearTracker.clientWidth;
|
||||
const currentRightEdge = topBounds.right - (topBounds.width - fearTrackerWidth) / 2;
|
||||
const countdownShift = countdownLeftEdge < currentRightEdge ? countdownLeftEdge - currentRightEdge : null
|
||||
|
||||
offset = Math.min(offset, countdownShift ?? Infinity);
|
||||
}
|
||||
|
||||
fearTracker.style.setProperty('--offset', `${offset}px`);
|
||||
}
|
||||
|
||||
_onPosition(position) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue