fix window size on <100% scale
This commit is contained in:
parent
737690f42a
commit
0eb8ed5430
1 changed files with 9 additions and 8 deletions
|
|
@ -242,30 +242,31 @@ Hooks.once("init", () => {
|
||||||
const display = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).displayFear;
|
const display = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).displayFear;
|
||||||
const maxFear = this.maxFear;
|
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') {
|
if (display === 'bar') {
|
||||||
const barElement = this.element.querySelector('#resource-fear');
|
const barElement = this.element.querySelector('#resource-fear');
|
||||||
const barH = barElement ? (barElement.getBoundingClientRect().height / scale) : 30;
|
const barH = barElement ? (barElement.getBoundingClientRect().height / scale) : 30;
|
||||||
const perfectH = barH + padY + headerH;
|
const perfectH = barH + padY + headerH;
|
||||||
const minW = 200;
|
const minW = 200;
|
||||||
const targetWUnscaled = targetWidth ? (targetWidth / scale) : 222;
|
|
||||||
const perfectW = Math.max(minW, targetWUnscaled);
|
const perfectW = Math.max(minW, targetWUnscaled);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
width: perfectW * scale,
|
width: Math.ceil(perfectW * scale) + 8,
|
||||||
height: perfectH * scale
|
height: Math.ceil(perfectH * scale) + 6
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const targetWUnscaled = targetWidth ? (targetWidth / scale) : 222;
|
|
||||||
let cols = Math.round((targetWUnscaled - padX + gapX) / (skullW + gapX));
|
let cols = Math.round((targetWUnscaled - padX + gapX) / (skullW + gapX));
|
||||||
cols = Math.max(1, Math.min(maxFear, cols));
|
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 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 {
|
return {
|
||||||
width: perfectW * scale,
|
width: Math.ceil(perfectW * scale) + 8,
|
||||||
height: perfectH * scale
|
height: Math.ceil(perfectH * scale) + 6
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue