Skip to content

Commit 124c7f3

Browse files
author
Azgaar
committed
v1.5.87 - lakes editor rework
1 parent 5f5a67d commit 124c7f3

File tree

7 files changed

+118
-36
lines changed

7 files changed

+118
-36
lines changed

index.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ i.icon-lock {
266266
}
267267

268268
#routeLength,
269-
#lakeArea,
270269
#coastlineArea {
271270
background-color: #eeeeee;
272271
border: 1px solid #a5a5a5;
@@ -1439,6 +1438,12 @@ div.states > .coaIcon > use {
14391438
width: 6em;
14401439
}
14411440

1441+
#burgBody > div > div,
1442+
#riverBody > div,
1443+
#lakeBody > div {
1444+
padding: .1em;
1445+
}
1446+
14421447
#riverBody div.label,
14431448
#riverBody input,
14441449
#riverBody select,

index.html

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,50 +1566,50 @@
15661566
<div id="riverEditor" class="dialog" style="display: none">
15671567
<div id="riverBody" style="padding-bottom: .3em">
15681568

1569-
<div style="padding: .1em">
1569+
<div>
15701570
<div class="label" style="width: 4.8em">Name:</div>
15711571
<span id="riverNameCulture" data-tip="Generate culture-specific name for the river" class="icon-book pointer"></span>
15721572
<span id="riverNameRandom" data-tip="Generate random name for the river" class="icon-globe pointer"></span>
15731573
<input id="riverName" data-tip="Type to rename the river" autocorrect="off" spellcheck="false">
15741574
<span data-tip="Speak the name. You can change voice and language in options" class="speaker">🔊</span>
15751575
</div>
15761576

1577-
<div style="padding: .1em" data-tip="Type to change river type (e.g. fork, creek, river, brook, stream)">
1577+
<div data-tip="Type to change river type (e.g. fork, creek, river, brook, stream)">
15781578
<div class="label">Type:</div>
15791579
<input id="riverType" autocorrect="off" spellcheck="false">
15801580
</div>
15811581

1582-
<div style="padding: .1em" data-tip="Select parent river">
1582+
<div data-tip="Select parent river">
15831583
<div class="label">Mainstem:</div>
15841584
<select id="riverMainstem"></select>
15851585
</div>
15861586

1587-
<div style="padding: .1em" data-tip="River drainage basin (watershed)">
1587+
<div data-tip="River drainage basin (watershed)">
15881588
<div class="label">Basin:</div>
15891589
<input id="riverBasin" disabled/>
15901590
</div>
15911591

1592-
<div style="padding: .1em" data-tip="River discharge (flux power)">
1592+
<div data-tip="River discharge (flux power)">
15931593
<div class="label">Discharge:</div>
15941594
<input id="riverDischarge" disabled/>
15951595
</div>
15961596

1597-
<div style="padding: .1em" data-tip="River length in selected units">
1597+
<div data-tip="River length in selected units">
15981598
<div class="label">Length:</div>
15991599
<input id="riverLength" disabled/>
16001600
</div>
16011601

1602-
<div style="padding: .1em" data-tip="River mouth width in selected units">
1602+
<div data-tip="River mouth width in selected units">
16031603
<div class="label">Mouse width:</div>
16041604
<input id="riverWidth" disabled/>
16051605
</div>
16061606

1607-
<div style="padding: .1em" data-tip="River source width in pixels">
1607+
<div data-tip="River source width in pixels">
16081608
<div class="label">Source width:</div>
16091609
<input id="riverSourceWidth" type="number" min=0 max=3 step=.1 />
16101610
</div>
16111611

1612-
<div style="padding: .1em" data-tip="River width multiplier">
1612+
<div data-tip="River width multiplier">
16131613
<div class="label">Width modifier:</div>
16141614
<input id="riverWidthFactor" type="number" min=.1 max=4 step=.1 />
16151615
</div>
@@ -1626,31 +1626,70 @@
16261626

16271627
<div id="lakeEditor" class="dialog" style="display: none">
16281628
<div id="lakeBody" style="padding-bottom: .3em">
1629-
<div style="padding: .1em">
1629+
<div>
16301630
<div class="label" style="width: 4.8em">Name:</div>
16311631
<span id="lakeNameCulture" data-tip="Generate culture-specific name for the lake" class="icon-book pointer"></span>
16321632
<span id="lakeNameRandom" data-tip="Generate random name for the lake" class="icon-globe pointer"></span>
16331633
<input id="lakeName" data-tip="Type to rename the lake" autocorrect="off" spellcheck="false">
16341634
<span data-tip="Speak the name. You can change voice and language in options" class="speaker">🔊</span>
16351635
</div>
16361636

1637-
<div style="padding: .1em" data-tip="Type to change lake type (group)">
1638-
<div class="label">Type:</div>
1639-
1640-
<select id="lakeGroup" data-tip="Select lake type (group)" style="width:9em"></select>
1641-
<input id="lakeGroupName" placeholder="new group name" data-tip="Provide a name for the new group" style="display:none; width:9em"/>
1642-
<span id="lakeGroupAdd" data-tip="Create new type (group) for the lake" class="icon-plus pointer"></span>
1637+
<div data-tip="Type to change lake type (group)">
1638+
<div class="label" style="width: 4.8em">Type:</div>
16431639
<span id="lakeGroupRemove" data-tip="Remove the group" class="icon-trash-empty pointer"></span>
1640+
<span id="lakeGroupAdd" data-tip="Create new type (group) for the lake" class="icon-plus pointer"></span>
1641+
<select id="lakeGroup" data-tip="Select lake type (group)"></select>
1642+
<input id="lakeGroupName" placeholder="type name" data-tip="Provide a name for the new group" style="display:none"/>
1643+
<span id="lakeEditStyle" data-tip="Edit lake group style in Style Editor" class="icon-brush pointer"></span>
16441644
</div>
16451645

1646-
<div style="padding: .1em" data-tip="Lake area in selected units">
1646+
<div data-tip="Lake area in selected units">
16471647
<div class="label">Area:</div>
16481648
<input id="lakeArea" disabled/>
16491649
</div>
1650+
1651+
<div data-tip="Lake shore length in selected units">
1652+
<div class="label">Shore length:</div>
1653+
<input id="lakeShoreLength" disabled/>
1654+
</div>
1655+
1656+
<div data-tip="Lake elevation in selected units">
1657+
<div class="label">Elevation:</div>
1658+
<input id="lakeElevation" disabled/>
1659+
</div>
1660+
1661+
<div data-tip="Lake average depth in selected units">
1662+
<div class="label">Avarage depth:</div>
1663+
<input id="lakeAvarageDepth" disabled/>
1664+
</div>
1665+
1666+
<div data-tip="Lake maximum depth in selected units">
1667+
<div class="label">Max depth:</div>
1668+
<input id="lakeMaxDepth" disabled/>
1669+
</div>
1670+
1671+
<div data-tip="Lake water supply. If supply > evaporation and there is an outlet, the lake water is fresh. If supply is very low, the lake becomes dry">
1672+
<div class="label">Supply:</div>
1673+
<input id="lakeFlux" disabled/>
1674+
</div>
1675+
1676+
<div data-tip="Evaporation from lake surface. If evaporation > supply, the lake water is saline. If difference is high, the lake becomes dry">
1677+
<div class="label">Evaporation:</div>
1678+
<input id="lakeEvaporation" disabled/>
1679+
</div>
1680+
1681+
<div data-tip="Number of lake inlet rivers">
1682+
<div class="label">Inlets:</div>
1683+
<input id="lakeInlets" disabled/>
1684+
</div>
1685+
1686+
<div data-tip="Lake outlet river">
1687+
<div class="label">Outlet:</div>
1688+
<input id="lakeOutlet" disabled/>
1689+
</div>
16501690
</div>
16511691

16521692
<div id="lakeBottom">
1653-
<button id="lakeEditStyle" data-tip="Edit lake group style in Style Editor" class="icon-brush"></button>
16541693
<button id="lakeLegend" data-tip="Edit free text notes (legend) for the lake" class="icon-edit"></button>
16551694
</div>
16561695
</div>
@@ -1854,16 +1893,16 @@
18541893
<div id="burgBody" style="padding-bottom: .3em">
18551894
<svg viewBox="0 0 200 200" width="14em" height="14em"><use id="burgEmblem"></use></svg>
18561895
<div style="float: right">
1857-
<div id="burgProvinceAndState" style="padding: .1em; font-style: italic; max-width: 16em"></div>
1896+
<div id="burgProvinceAndState" style="font-style: italic; max-width: 16em"></div>
18581897

1859-
<div style="padding: .1em">
1898+
<div>
18601899
<div class="label">Name:</div>
18611900
<input id="burgName" data-tip="Type to rename the burg" autocorrect="off" spellcheck="false" style="width: 8em">
18621901
<span data-tip="Speak the name. You can change voice and language in options" class="speaker">🔊</span>
18631902
<span id="burgNameReRandom" data-tip="Generate random name for the burg" class="icon-globe pointer"></span>
18641903
</div>
18651904

1866-
<div style="padding: .1em" data-tip="Select burg type. Type slightly affects emblem generation">
1905+
<div data-tip="Select burg type. Type slightly affects emblem generation">
18671906
<div class="label">Type:</div>
18681907
<select id="burgType" style="width: 8em">
18691908
<option value="Generic">Generic</option>
@@ -1876,18 +1915,18 @@
18761915
</select>
18771916
</div>
18781917

1879-
<div style="padding: .1em" data-tip="Select dominant culture">
1918+
<div data-tip="Select dominant culture">
18801919
<div class="label">Culture:</div>
18811920
<select id="burgCulture" style="width: 8em"></select>
18821921
<span id="burgNameReCulture" data-tip="Generate culture-specific name for the burg" class="icon-book pointer"></span>
18831922
</div>
18841923

1885-
<div style="padding: .1em" data-tip="Set burg population">
1924+
<div data-tip="Set burg population">
18861925
<div class="label">Population:</div>
18871926
<input id="burgPopulation" type="number" min=0 step=1 style="width: 8em">
18881927
</div>
18891928

1890-
<div style="padding: .1em">
1929+
<div>
18911930
<div class="label">Features:</div>
18921931
<span id="burgCapital" data-tip="Shows whether the burg is a state capital. Click to toggle" data-feature="capital" class="burgFeature icon-star"></span>
18931932
<span id="burgPort" data-tip="Shows whether the burg is a port. Click to toggle" data-feature="port" class="burgFeature icon-anchor"></span>
@@ -1898,13 +1937,13 @@
18981937
<span id="burgShanty" data-tip="Shows whether the burg has a shanty town. Click to toggle" data-feature="shanty" class="burgFeature icon-campground" style="font-size: 1em"></span>
18991938
</div>
19001939

1901-
<div style="padding: .1em" data-tip="Burg mean annual temperature and real-world city for comparison">
1940+
<div data-tip="Burg mean annual temperature and real-world city for comparison">
19021941
<div class="label">Temperature:</div>
19031942
<span id="burgTemperature"></span>, like in
19041943
<span id="burgTemperatureLikeIn"></span>
19051944
</div>
19061945

1907-
<div style="padding: .1em" data-tip="Burg height above mean sea level">
1946+
<div data-tip="Burg height above mean sea level">
19081947
<div class="label">Elevation:</div>
19091948
<span id="burgElevation"></span> above sea level
19101949
</div>

main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// https://github.com/Azgaar/Fantasy-Map-Generator
33

44
"use strict";
5-
const version = "1.59"; // generator version
5+
const version = "1.6"; // generator version
66
document.title += " v" + version;
77

88
// Switches to disable/enable logging features
@@ -338,7 +338,7 @@ function applyDefaultBiomesSystem() {
338338
}
339339

340340
function showWelcomeMessage() {
341-
const post = "Main changes:" //link("https://www.reddit.com/r/FantasyMapGenerator/comments/ft5b41/update_v15/", "Main changes:");
341+
const post = "Main changes:" //link("https://www.reddit.com/r/FantasyMapGenerator/comments/ft5b41/update_v16/", "Main changes:");
342342
const changelog = link("https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Changelog", "previous version");
343343
const reddit = link("https://www.reddit.com/r/FantasyMapGenerator", "Reddit community");
344344
const discord = link("https://discordapp.com/invite/X7E84HU", "Discord server");

modules/save-and-load.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ function parseLoadedData(data) {
11001100
});
11011101
}
11021102

1103-
if (version < 1.59) {
1103+
if (version < 1.6) {
11041104
// v 1.6 changed rivers data
11051105
for (const river of pack.rivers) {
11061106
const el = document.getElementById("river"+river.i);
@@ -1115,8 +1115,22 @@ function parseLoadedData(data) {
11151115
Rivers.remove(river.i);
11161116
}
11171117
}
1118-
}
11191118

1119+
// v 1.6 changed lakes data
1120+
for (const f of pack.features) {
1121+
if (f.type !== "lake") continue;
1122+
if (f.evaporation) continue;
1123+
1124+
f.flux = f.flux || f.cells * 3;
1125+
f.temp = grid.cells.temp[pack.cells.g[f.firstCell]];
1126+
f.height = f.height || d3.min(pack.cells.c[f.firstCell].map(c => pack.cells.h[c]).filter(h => h >= 20));
1127+
const height = (f.height - 18) ** heightExponentInput.value;
1128+
const evaporation = (700 * (f.temp + .006 * height) / 50 + 75) / (80 - f.temp);
1129+
f.evaporation = rn(evaporation * f.cells);
1130+
f.name = f.name || Lakes.getName(f);
1131+
delete f.river;
1132+
}
1133+
}
11201134
}()
11211135

11221136
void function checkDataIntegrity() {

modules/ui/heightmap-editor.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ function editHeightmap() {
351351
if (!b.i || b.removed) continue;
352352
b.cell = findBurgCell(b.x, b.y);
353353
b.feature = pack.cells.f[b.cell];
354-
//if (b.port) b.port = pack.cells.f[pack.cells.haven[b.cell]]; // water body id
355354

356355
pack.cells.burg[b.cell] = b.i;
357356
if (!b.capital && pack.cells.h[b.cell] < 20) removeBurg(b.i);
@@ -383,7 +382,10 @@ function editHeightmap() {
383382
drawStates();
384383
drawBorders();
385384

386-
if (changeHeights.checked) Rivers.specify();
385+
if (changeHeights.checked) {
386+
Rivers.specify();
387+
Lakes.generateName();
388+
}
387389

388390
// restore zones from grid
389391
zones.selectAll("g").each(function() {

modules/ui/lakes-editor.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,32 @@ function editLake() {
4040
}
4141

4242
function updateLakeValues() {
43+
const cells = pack.cells;
44+
4345
const l = getLake();
4446
document.getElementById("lakeName").value = l.name;
45-
document.getElementById("lakeGroup").value = l.type;
4647

4748
const unit = areaUnit.value === "square" ? " " + distanceUnitInput.value + "²" : " " + areaUnit.value;
4849
document.getElementById("lakeArea").value = si(l.area * distanceScaleInput.value ** 2) + unit;
50+
51+
const length = d3.polygonLength(l.vertices.map(v => pack.vertices.p[v]));
52+
document.getElementById("lakeShoreLength").value = si(length * distanceScaleInput.value) + " " + distanceUnitInput.value;
53+
54+
const lakeCells = Array.from(cells.i.filter(i => cells.f[i] === l.i));
55+
const heights = lakeCells.map(i => cells.h[i]);
56+
57+
document.getElementById("lakeElevation").value = getHeight(l.height);
58+
document.getElementById("lakeAvarageDepth").value = getHeight(d3.mean(heights), "abs");
59+
document.getElementById("lakeMaxDepth").value = getHeight(d3.min(heights), "abs");
60+
61+
document.getElementById("lakeFlux").value = l.flux;
62+
document.getElementById("lakeEvaporation").value = l.evaporation;
63+
64+
const inlets = l.inlets && l.inlets.map(inlet => pack.rivers.find(river => river.i === inlet)?.name);
65+
const outlet = l.outlet ? pack.rivers.find(river => river.i === l.outlet)?.name : "no";
66+
document.getElementById("lakeInlets").value = inlets ? inlets.length : "no";
67+
document.getElementById("lakeInlets").title = inlets ? inlets.join(", ") : "";
68+
document.getElementById("lakeOutlet").value = outlet;
4969
}
5070

5171
function drawLakeVertices() {
@@ -110,6 +130,7 @@ function editLake() {
110130

111131
function changeLakeGroup() {
112132
document.getElementById(this.value).appendChild(elSelected.node());
133+
getLake().group = this.value;
113134
}
114135

115136
function toggleNewGroupInput() {
@@ -195,7 +216,7 @@ function editLake() {
195216

196217
function editLakeLegend() {
197218
const id = elSelected.attr("id");
198-
editNotes(id, id);
219+
editNotes(id, getLake().name + " " + lakeGroup.value + " lake");
199220
}
200221

201222
function closeLakesEditor() {

modules/ui/rivers-editor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ function editRiver(id) {
204204

205205
function editRiverLegend() {
206206
const id = elSelected.attr("id");
207-
editNotes(id, id);
207+
const river = getRiver();
208+
editNotes(id, river.name + " " + river.type);
208209
}
209210

210211
function toggleRiverCreationMode() {

0 commit comments

Comments
 (0)