Add v6 biomes flags

This commit is contained in:
Wuzzy 2023-10-27 19:41:21 +02:00
parent 5fcc3f3e5d
commit 8531bc6c3a
2 changed files with 177 additions and 63 deletions

View File

@ -89,6 +89,25 @@ A Voronoi diagram is supposed to be here but for some reason it cannot be displa
</div> </div>
</div> </div>
<div id="biomeV6ConfigContainerOuter" hidden>
<h2 class="configHeader"><span class="collapser" id="biomeV6ConfigHeaderLink"></span> v6 Biome configuration</h2>
<div id="biomeV6ConfigContainer" class="configFrame">
<form id="biomeV6Form">
<div>Flags:
<input id="inputCheckboxV6Snowbiomes" type="checkbox" checked>
<label for="inputCheckboxV6Snowbiomes">snowbiomes</label>
<input id="inputCheckboxV6Jungles" type="checkbox" checked>
<label for="inputCheckboxV6Jungles">jungles</label>
</div>
<div>
<label for="inputV6FreqDesert">Desert noise threshold:&nbsp;</label>
<input id="inputV6FreqDesert" type="number" value="0.45" step="0.01" size="10" disabled>
</div>
</form>
</div>
</div>
<div id="viewConfigContainerOuter"> <div id="viewConfigContainerOuter">
<h2 class="configHeader"><span class="collapser" id="viewConfigHeaderLink"></span> Diagram view settings</h2> <h2 class="configHeader"><span class="collapser" id="viewConfigHeaderLink"></span> Diagram view settings</h2>
<div id="viewConfigContainer" class="configFrame"> <div id="viewConfigContainer" class="configFrame">

115
mibpov.js
View File

@ -131,7 +131,7 @@ let viewY = 0;
let v6_flag_snowbiomes = true; let v6_flag_snowbiomes = true;
let v6_flag_jungles = true; let v6_flag_jungles = true;
let v6_freq_desert = 0.5; let v6_freq_desert = 0.45;
// Biome noise settings // Biome noise settings
const NOISE_OFFSET_DEFAULT = 50; const NOISE_OFFSET_DEFAULT = 50;
@ -1148,7 +1148,7 @@ function drawV6() {
return false; return false;
} }
if (v6_flag_snowbiomes) { if (true) {
let cx, cy; let cx, cy;
@ -1157,18 +1157,31 @@ function drawV6() {
let cx_snow, cx_hot, cx_snow2, cy_snow2, cx_hot2, cy_hot2; let cx_snow, cx_hot, cx_snow2, cy_snow2, cx_hot2, cy_hot2;
let _; // unused variable let _; // unused variable
let freq_jungle, freq_hot;
if (v6_flag_snowbiomes) {
freq_jungle = MGV6_FREQ_JUNGLE;
freq_hot = MGV6_FREQ_HOT;
// Temperate <-> Taiga/Tundra // Temperate <-> Taiga/Tundra
[cx_snow, _] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_SNOW, 0); [cx_snow, _] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_SNOW, 0);
// Temperate <-> Desert/Jungle // Temperate <-> Desert/Jungle
[cx_hot, _] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_HOT, 0); [cx_hot, _] = biomeCoordsToCanvasPixelCoords(freq_hot, 0);
} else {
// Temperate <-> Desert/Jungle
freq_hot = v6_freq_desert;
[cx_hot, _] = biomeCoordsToCanvasPixelCoords(freq_hot, 0);
freq_jungle = 0.75;
}
// Taiga <-> Tundra <-> Temperate // Taiga <-> Tundra <-> Temperate
[cx_snow2, cy_snow2] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_SNOW, MGV6_FREQ_TAIGA); [cx_snow2, cy_snow2] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_SNOW, MGV6_FREQ_TAIGA);
// Desert <-> Jungle <-> Temperate // Desert <-> Jungle <-> Temperate
[cx_hot2, cy_hot2] = biomeCoordsToCanvasPixelCoords(MGV6_FREQ_HOT, MGV6_FREQ_JUNGLE); [cx_hot2, cy_hot2] = biomeCoordsToCanvasPixelCoords(freq_hot, freq_jungle);
if (showCellColors) { if (showCellColors) {
// Render biome areas // Render biome areas
context.fillStyle = CELL_COLOR_V6_NORMAL; context.fillStyle = CELL_COLOR_V6_NORMAL;
if (v6_flag_snowbiomes) {
// Temperate // Temperate
context.beginPath(); context.beginPath();
context.moveTo(cx_snow, 0); context.moveTo(cx_snow, 0);
@ -1210,9 +1223,49 @@ function drawV6() {
context.moveTo(cx_hot2, cy_hot2); context.moveTo(cx_hot2, cy_hot2);
context.lineTo(cx_hot2, h); context.lineTo(cx_hot2, h);
context.lineTo(w, h); context.lineTo(w, h);
context.lineTo(w, cy_snow2); context.lineTo(w, cy_hot2);
context.closePath(); context.closePath();
context.fill(); context.fill();
} else {
// Temperate
context.beginPath();
context.moveTo(0, 0);
context.lineTo(0, h);
context.lineTo(cx_hot, h);
context.lineTo(cx_hot, 0);
context.closePath();
context.fill();
if (v6_flag_jungles) {
// Jungle
context.fillStyle = CELL_COLOR_V6_JUNGLE;
context.beginPath();
context.moveTo(0, 0);
context.lineTo(w, 0);
context.lineTo(w, cy_hot2);
context.lineTo(0, cy_hot2);
context.closePath();
context.fill();
// Desert
context.fillStyle = CELL_COLOR_V6_DESERT;
context.beginPath();
context.moveTo(cx_hot2, cy_hot2);
context.lineTo(cx_hot2, h);
context.lineTo(w, h);
context.lineTo(w, cy_hot2);
context.closePath();
context.fill();
} else {
// Desert
context.fillStyle = CELL_COLOR_V6_DESERT;
context.beginPath();
context.moveTo(cx_hot2, 0);
context.lineTo(cx_hot2, h);
context.lineTo(w, h);
context.lineTo(w, 0);
context.closePath();
context.fill();
}
}
} else { } else {
// Use a "neutral" background color for the whole area if cell colors are disabled // Use a "neutral" background color for the whole area if cell colors are disabled
context.fillStyle = CELL_COLOR_NEUTRAL; context.fillStyle = CELL_COLOR_NEUTRAL;
@ -1224,20 +1277,30 @@ function drawV6() {
context.strokeStyle = EDGE_COLOR; context.strokeStyle = EDGE_COLOR;
context.beginPath(); context.beginPath();
if (v6_flag_snowbiomes) {
// Temperate <-> Taiga/Tundra // Temperate <-> Taiga/Tundra
context.moveTo(cx_snow, 0); context.moveTo(cx_snow, 0);
context.lineTo(cx_snow, h); context.lineTo(cx_snow, h);
// Temperate <-> Desert/Jungle
context.moveTo(cx_hot, 0);
context.lineTo(cx_hot, h);
// Taiga <-> Tundra // Taiga <-> Tundra
context.moveTo(cx_snow2, cy_snow2); context.moveTo(cx_snow2, cy_snow2);
context.lineTo(0, cy_snow2); context.lineTo(0, cy_snow2);
}
// Temperate <-> Desert/Jungle
if (v6_flag_snowbiomes || (!v6_flag_jungles)) {
context.moveTo(cx_hot, 0);
context.lineTo(cx_hot, h);
} else {
context.moveTo(cx_hot, cy_hot2);
context.lineTo(cx_hot, h);
}
// Desert <-> Jungle // Desert <-> Jungle
if (v6_flag_snowbiomes) {
context.moveTo(cx_hot2, cy_hot2); context.moveTo(cx_hot2, cy_hot2);
context.lineTo(w, cy_hot2); context.lineTo(w, cy_hot2);
} else if (v6_flag_jungles) {
context.moveTo(0, cy_hot2);
context.lineTo(w, cy_hot2);
}
context.closePath(); context.closePath();
context.stroke(); context.stroke();
@ -1335,6 +1398,14 @@ function updateWidgetStates() {
inputNoiseHumidityScale.value = noises.humidity.scale; inputNoiseHumidityScale.value = noises.humidity.scale;
inputNoiseHumidityOctaves.value = noises.humidity.octaves; inputNoiseHumidityOctaves.value = noises.humidity.octaves;
inputNoiseHumidityPersistence.value = noises.humidity.persistence; inputNoiseHumidityPersistence.value = noises.humidity.persistence;
if (v6_flag_snowbiomes) {
inputV6FreqDesert.disabled = true;
inputCheckboxV6Jungles.disabled = true;
} else {
inputV6FreqDesert.disabled = false;
inputCheckboxV6Jungles.disabled = false;
}
} }
/* To be called when a biome value like heat was changed. /* To be called when a biome value like heat was changed.
@ -1586,6 +1657,8 @@ function checkboxVarsInit() {
showCellColors = inputCheckboxCellColors.checked; showCellColors = inputCheckboxCellColors.checked;
showGrid = inputCheckboxGrid.checked; showGrid = inputCheckboxGrid.checked;
showAxes = inputCheckboxAxes.checked; showAxes = inputCheckboxAxes.checked;
v6_flag_snowbiomes = inputCheckboxV6Snowbiomes.checked;
v6_flag_jungles = inputCheckboxV6Jungles.checked;
} }
/* Collapses/Expands a config section */ /* Collapses/Expands a config section */
@ -1917,6 +1990,23 @@ inputCheckboxAxes.onchange = function() {
showAxes = this.checked; showAxes = this.checked;
draw(false); draw(false);
} }
inputCheckboxV6Snowbiomes.onchange = function() {
v6_flag_snowbiomes = this.checked;
updateWidgetStates();
draw(false);
}
inputCheckboxV6Jungles.onchange = function() {
v6_flag_jungles = this.checked;
draw(false);
}
inputV6FreqDesert.oninput = function() {
let f = +this.value;
if (f === null) {
return;
}
v6_freq_desert = f;
draw(true);
}
/* Noise parameters events */ /* Noise parameters events */
@ -2221,6 +2311,7 @@ inputImportSubmit.onclick = function() {
modernModeButton.onclick = function() { modernModeButton.onclick = function() {
biomeMode = "modern"; biomeMode = "modern";
biomeConfigContainerOuter.hidden = false; biomeConfigContainerOuter.hidden = false;
biomeV6ConfigContainerOuter.hidden = true;
importContainerOuter.hidden = false; importContainerOuter.hidden = false;
exportContainerOuter.hidden = false; exportContainerOuter.hidden = false;
inputCheckboxPoints.disabled = false; inputCheckboxPoints.disabled = false;
@ -2235,6 +2326,7 @@ modernModeButton.onclick = function() {
v6ModeButton.onclick = function() { v6ModeButton.onclick = function() {
biomeMode = "v6"; biomeMode = "v6";
biomeConfigContainerOuter.hidden = true; biomeConfigContainerOuter.hidden = true;
biomeV6ConfigContainerOuter.hidden = false;
importContainerOuter.hidden = true; importContainerOuter.hidden = true;
exportContainerOuter.hidden = true; exportContainerOuter.hidden = true;
inputCheckboxPoints.disabled = true; inputCheckboxPoints.disabled = true;
@ -2252,6 +2344,9 @@ v6ModeButton.onclick = function() {
biomeConfigHeaderLink.onclick = function() { biomeConfigHeaderLink.onclick = function() {
toggleConfigSectionDisplay(this, biomeConfigContainer); toggleConfigSectionDisplay(this, biomeConfigContainer);
} }
biomeV6ConfigHeaderLink.onclick = function() {
toggleConfigSectionDisplay(this, biomeV6ConfigContainer);
}
viewConfigHeaderLink.onclick = function() { viewConfigHeaderLink.onclick = function() {
toggleConfigSectionDisplay(this, viewConfigContainer); toggleConfigSectionDisplay(this, viewConfigContainer);
} }