fix window size on <100% scale

This commit is contained in:
CPTN Cosmo 2026-07-12 19:27:07 +02:00
parent 737690f42a
commit 0eb8ed5430

View file

@ -242,30 +242,31 @@ Hooks.once("init", () => {
const display = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).displayFear;
const maxFear = this.maxFear;
// Subtract the fixed border buffer from targetWidth before unscaling to get exact content size
const targetWUnscaled = targetWidth ? Math.max(0, (targetWidth - 8) / scale) : 222;
if (display === 'bar') {
const barElement = this.element.querySelector('#resource-fear');
const barH = barElement ? (barElement.getBoundingClientRect().height / scale) : 30;
const perfectH = barH + padY + headerH;
const minW = 200;
const targetWUnscaled = targetWidth ? (targetWidth / scale) : 222;
const perfectW = Math.max(minW, targetWUnscaled);
return {
width: perfectW * scale,
height: perfectH * scale
width: Math.ceil(perfectW * scale) + 8,
height: Math.ceil(perfectH * scale) + 6
};
} else {
const targetWUnscaled = targetWidth ? (targetWidth / scale) : 222;
let cols = Math.round((targetWUnscaled - padX + gapX) / (skullW + gapX));
cols = Math.max(1, Math.min(maxFear, cols));
const perfectW = cols * skullW + (cols - 1) * gapX + padX + 2;
const perfectW = cols * skullW + (cols - 1) * gapX + padX;
const rows = Math.ceil(maxFear / cols);
const perfectH = rows * skullH + (rows - 1) * gapY + padY + headerH + 2;
const perfectH = rows * skullH + (rows - 1) * gapY + padY + headerH;
return {
width: perfectW * scale,
height: perfectH * scale
width: Math.ceil(perfectW * scale) + 8,
height: Math.ceil(perfectH * scale) + 6
};
}
}