Number input widgets now update the diagram
This commit is contained in:
parent
b68a81950f
commit
b2cc813885
42
biome-ui.js
42
biome-ui.js
@ -228,18 +228,24 @@ function rewriteBiomeSelector() {
|
||||
}
|
||||
|
||||
function updateWidgetStates() {
|
||||
inputMinY.disabled = "disabled";
|
||||
inputMaxY.disabled = "disabled";
|
||||
if (biomePoints.length === 0 || biomeSelector.selectedIndex === -1) {
|
||||
removeBiomeButton.disabled = "disabled";
|
||||
inputHeat.disabled = "disabled";
|
||||
inputHumidity.disabled = "disabled";
|
||||
inputMinY.disabled = "disabled";
|
||||
inputMaxY.disabled = "disabled";
|
||||
} else {
|
||||
removeBiomeButton.disabled = "";
|
||||
inputHeat.disabled = "";
|
||||
inputHumidity.disabled = "";
|
||||
inputMinY.disabled = "";
|
||||
inputMaxY.disabled = "";
|
||||
if (biomeSelector.selectedIndex !== -1) {
|
||||
let selected = biomeSelector.options[biomeSelector.selectedIndex];
|
||||
let point = biomePoints[biomeSelector.selectedIndex];
|
||||
inputHeat.value = point.heat;
|
||||
inputHumidity.value = point.humidity;
|
||||
inputMinY.value = point.min_y;
|
||||
inputMaxY.value = point.max_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,10 +260,38 @@ biomeSelector.onchange = function() {
|
||||
let point = biomePoints[biomeSelector.selectedIndex];
|
||||
inputHeat.value = point.heat;
|
||||
inputHumidity.value = point.humidity;
|
||||
inputMinY.value = point.min_y;
|
||||
inputMaxY.value = point.max_y;
|
||||
}
|
||||
updateWidgetStates();
|
||||
}
|
||||
|
||||
function onChangeBiomeValueWidget(pointField, value) {
|
||||
if (value === null) {
|
||||
return;
|
||||
}
|
||||
if (biomeSelector.selectedIndex === -1) {
|
||||
return;
|
||||
}
|
||||
let selected = biomeSelector.options[biomeSelector.selectedIndex];
|
||||
if (selected === null) {
|
||||
return;
|
||||
}
|
||||
let point = biomePoints[biomeSelector.selectedIndex];
|
||||
point[pointField] = +value;
|
||||
point.name = generateBiomeName(point.heat, point.humidity);
|
||||
selected.innerText = point.name;
|
||||
draw(true);
|
||||
|
||||
}
|
||||
|
||||
inputHeat.onchange = function() {
|
||||
onChangeBiomeValueWidget("heat", this.value);
|
||||
}
|
||||
inputHumidity.onchange = function() {
|
||||
onChangeBiomeValueWidget("humidity", this.value);
|
||||
}
|
||||
|
||||
addBiomeButton.onclick = function() {
|
||||
let he = Math.round(Math.random()*100);
|
||||
let hu = Math.round(Math.random()*100);
|
||||
|
Loading…
x
Reference in New Issue
Block a user