Просмотр исходного кода

Preserve the world height when changing units, thus matching other inputs

tags/v0.1.0
Fen Dweller 6 лет назад
Родитель
Сommit
aad8c4e7f2
1 измененных файлов: 19 добавлений и 13 удалений
  1. +19
    -13
      macrovision.js

+ 19
- 13
macrovision.js Просмотреть файл

@@ -1434,6 +1434,14 @@ document.addEventListener("DOMContentLoaded", () => {
document.querySelector("#help").classList.remove("visible");
});

document.querySelector("#options-height-value").addEventListener("change", e => {
updateWorldHeight();
})

document.querySelector("#options-height-value").addEventListener("keydown", e => {
e.stopPropagation();
})

const unitSelector = document.querySelector("#options-height-unit");

unitChoices.length.forEach(lengthOption => {
@@ -1449,6 +1457,17 @@ document.addEventListener("DOMContentLoaded", () => {
unitSelector.appendChild(option);
});

unitSelector.setAttribute("oldUnit", "meters");

unitSelector.addEventListener("input", e => {
checkFitWorld();
const scaleInput = document.querySelector("#options-height-value");
const newVal = math.unit(scaleInput.value, unitSelector.getAttribute("oldUnit")).toNumber(e.target.value);
setNumericInput(scaleInput, newVal);
updateWorldHeight();
unitSelector.setAttribute("oldUnit", unitSelector.value);
});

param = new URL(window.location.href).searchParams.get("scene");

if (param === null) {
@@ -1503,19 +1522,6 @@ document.addEventListener("DOMContentLoaded", () => {

updateSizes();

document.querySelector("#options-height-value").addEventListener("change", e => {
updateWorldHeight();
})

document.querySelector("#options-height-value").addEventListener("keydown", e => {
e.stopPropagation();
})

unitSelector.addEventListener("input", e => {
checkFitWorld();
updateWorldHeight();
})

world.addEventListener("mousedown", e => deselect());
document.querySelector("#entities").addEventListener("mousedown", deselect);
document.querySelector("#display").addEventListener("mousedown", deselect);


Загрузка…
Отмена
Сохранить