v1.5.85 - restrict max UI size to screen size

This commit is contained in:
Azgaar 2021-03-01 21:20:50 +03:00
parent d3cf46e15f
commit cb88ab9229

View file

@ -116,8 +116,6 @@ optionsContent.addEventListener("input", function(event) {
else if (id === "manorsInput") changeBurgsNumberSlider(value);
else if (id === "religionsInput") religionsOutput.value = value;
else if (id === "emblemShape") changeEmblemShape(value);
else if (id === "uiSizeInput") uiSizeOutput.value = value;
else if (id === "uiSizeOutput") changeUIsize(value);
else if (id === "tooltipSizeInput" || id === "tooltipSizeOutput") changeTooltipSize(value);
else if (id === "transparencyInput") changeDialogsTransparency(value);
});
@ -127,7 +125,7 @@ optionsContent.addEventListener("change", function(event) {
const id = event.target.id, value = event.target.value;
if (id === "zoomExtentMin" || id === "zoomExtentMax") changeZoomExtent(value);
else if (id === "optionsSeed") generateMapWithSeed();
else if (id === "uiSizeInput") changeUIsize(value);
else if (id === "uiSizeInput" || id === "uiSizeOutput") changeUIsize(value);
else if (id === "yearInput") changeYear();
else if (id === "eraInput") changeEra();
});
@ -342,12 +340,20 @@ function changeBurgsNumberSlider(value) {
}
function changeUIsize(value) {
if (isNaN(+value) || +value > 4 || +value < .5) return;
if (isNaN(+value) || +value < .5) return;
const max = getUImaxSize();
if (+value > max) value = max;
uiSizeInput.value = uiSizeOutput.value = value;
document.getElementsByTagName("body")[0].style.fontSize = value * 11 + "px";
document.getElementById("options").style.width = value * 300 + "px";
}
function getUImaxSize() {
return rn(Math.min(window.innerHeight / 465, window.innerWidth / 302), 1);
}
function changeTooltipSize(value) {
tooltipSizeInput.value = tooltipSizeOutput.value = value;
tooltip.style.fontSize = `calc(${value}px + 0.5vw)`;
@ -405,6 +411,7 @@ function applyStoredOptions() {
if (localStorage.getItem("tooltipSize")) changeTooltipSize(localStorage.getItem("tooltipSize"));
if (localStorage.getItem("regions")) changeStatesNumber(localStorage.getItem("regions"));
uiSizeInput.max = uiSizeOutput.max = getUImaxSize();
if (localStorage.getItem("uiSize")) changeUIsize(localStorage.getItem("uiSize"));
else changeUIsize(Math.max(Math.min(rn(mapWidthInput.value / 1280, 1), 2.5), 1));