mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
v1.5.87 - lakes editor rework
This commit is contained in:
parent
5f5a67d436
commit
124c7f3448
7 changed files with 118 additions and 36 deletions
|
|
@ -1100,7 +1100,7 @@ function parseLoadedData(data) {
|
|||
});
|
||||
}
|
||||
|
||||
if (version < 1.59) {
|
||||
if (version < 1.6) {
|
||||
// v 1.6 changed rivers data
|
||||
for (const river of pack.rivers) {
|
||||
const el = document.getElementById("river"+river.i);
|
||||
|
|
@ -1115,8 +1115,22 @@ function parseLoadedData(data) {
|
|||
Rivers.remove(river.i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// v 1.6 changed lakes data
|
||||
for (const f of pack.features) {
|
||||
if (f.type !== "lake") continue;
|
||||
if (f.evaporation) continue;
|
||||
|
||||
f.flux = f.flux || f.cells * 3;
|
||||
f.temp = grid.cells.temp[pack.cells.g[f.firstCell]];
|
||||
f.height = f.height || d3.min(pack.cells.c[f.firstCell].map(c => pack.cells.h[c]).filter(h => h >= 20));
|
||||
const height = (f.height - 18) ** heightExponentInput.value;
|
||||
const evaporation = (700 * (f.temp + .006 * height) / 50 + 75) / (80 - f.temp);
|
||||
f.evaporation = rn(evaporation * f.cells);
|
||||
f.name = f.name || Lakes.getName(f);
|
||||
delete f.river;
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
void function checkDataIntegrity() {
|
||||
|
|
|
|||
|
|
@ -351,7 +351,6 @@ function editHeightmap() {
|
|||
if (!b.i || b.removed) continue;
|
||||
b.cell = findBurgCell(b.x, b.y);
|
||||
b.feature = pack.cells.f[b.cell];
|
||||
//if (b.port) b.port = pack.cells.f[pack.cells.haven[b.cell]]; // water body id
|
||||
|
||||
pack.cells.burg[b.cell] = b.i;
|
||||
if (!b.capital && pack.cells.h[b.cell] < 20) removeBurg(b.i);
|
||||
|
|
@ -383,7 +382,10 @@ function editHeightmap() {
|
|||
drawStates();
|
||||
drawBorders();
|
||||
|
||||
if (changeHeights.checked) Rivers.specify();
|
||||
if (changeHeights.checked) {
|
||||
Rivers.specify();
|
||||
Lakes.generateName();
|
||||
}
|
||||
|
||||
// restore zones from grid
|
||||
zones.selectAll("g").each(function() {
|
||||
|
|
|
|||
|
|
@ -40,12 +40,32 @@ function editLake() {
|
|||
}
|
||||
|
||||
function updateLakeValues() {
|
||||
const cells = pack.cells;
|
||||
|
||||
const l = getLake();
|
||||
document.getElementById("lakeName").value = l.name;
|
||||
document.getElementById("lakeGroup").value = l.type;
|
||||
|
||||
const unit = areaUnit.value === "square" ? " " + distanceUnitInput.value + "²" : " " + areaUnit.value;
|
||||
document.getElementById("lakeArea").value = si(l.area * distanceScaleInput.value ** 2) + unit;
|
||||
|
||||
const length = d3.polygonLength(l.vertices.map(v => pack.vertices.p[v]));
|
||||
document.getElementById("lakeShoreLength").value = si(length * distanceScaleInput.value) + " " + distanceUnitInput.value;
|
||||
|
||||
const lakeCells = Array.from(cells.i.filter(i => cells.f[i] === l.i));
|
||||
const heights = lakeCells.map(i => cells.h[i]);
|
||||
|
||||
document.getElementById("lakeElevation").value = getHeight(l.height);
|
||||
document.getElementById("lakeAvarageDepth").value = getHeight(d3.mean(heights), "abs");
|
||||
document.getElementById("lakeMaxDepth").value = getHeight(d3.min(heights), "abs");
|
||||
|
||||
document.getElementById("lakeFlux").value = l.flux;
|
||||
document.getElementById("lakeEvaporation").value = l.evaporation;
|
||||
|
||||
const inlets = l.inlets && l.inlets.map(inlet => pack.rivers.find(river => river.i === inlet)?.name);
|
||||
const outlet = l.outlet ? pack.rivers.find(river => river.i === l.outlet)?.name : "no";
|
||||
document.getElementById("lakeInlets").value = inlets ? inlets.length : "no";
|
||||
document.getElementById("lakeInlets").title = inlets ? inlets.join(", ") : "";
|
||||
document.getElementById("lakeOutlet").value = outlet;
|
||||
}
|
||||
|
||||
function drawLakeVertices() {
|
||||
|
|
@ -110,6 +130,7 @@ function editLake() {
|
|||
|
||||
function changeLakeGroup() {
|
||||
document.getElementById(this.value).appendChild(elSelected.node());
|
||||
getLake().group = this.value;
|
||||
}
|
||||
|
||||
function toggleNewGroupInput() {
|
||||
|
|
@ -195,7 +216,7 @@ function editLake() {
|
|||
|
||||
function editLakeLegend() {
|
||||
const id = elSelected.attr("id");
|
||||
editNotes(id, id);
|
||||
editNotes(id, getLake().name + " " + lakeGroup.value + " lake");
|
||||
}
|
||||
|
||||
function closeLakesEditor() {
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ function editRiver(id) {
|
|||
|
||||
function editRiverLegend() {
|
||||
const id = elSelected.attr("id");
|
||||
editNotes(id, id);
|
||||
const river = getRiver();
|
||||
editNotes(id, river.name + " " + river.type);
|
||||
}
|
||||
|
||||
function toggleRiverCreationMode() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue