mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
Merge branch 'master' of https://github.com/Azgaar/Fantasy-Map-Generator into dev-economics
This commit is contained in:
commit
7dc71a5616
33 changed files with 5797 additions and 2941 deletions
|
|
@ -16,15 +16,9 @@ function editHeightmap() {
|
|||
title: 'Edit Heightmap',
|
||||
width: '28em',
|
||||
buttons: {
|
||||
Erase: function () {
|
||||
enterHeightmapEditMode('erase');
|
||||
},
|
||||
Keep: function () {
|
||||
enterHeightmapEditMode('keep');
|
||||
},
|
||||
Risk: function () {
|
||||
enterHeightmapEditMode('risk');
|
||||
},
|
||||
Erase: () => enterHeightmapEditMode('erase'),
|
||||
Keep: () => enterHeightmapEditMode('keep'),
|
||||
Risk: () => enterHeightmapEditMode('risk'),
|
||||
Cancel: function () {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
|
|
@ -77,7 +71,7 @@ function editHeightmap() {
|
|||
convertImage.style.display = type === 'erase' ? 'inline-block' : 'none';
|
||||
|
||||
// hide erosion checkbox if mode is Keep
|
||||
changeHeightsBox.style.display = type === 'keep' ? 'none' : 'inline-block';
|
||||
allowErosionBox.style.display = type === 'keep' ? 'none' : 'inline-block';
|
||||
|
||||
// show finalize button
|
||||
if (!sessionStorage.getItem('noExitButtonAnimation')) {
|
||||
|
|
@ -191,19 +185,22 @@ function editHeightmap() {
|
|||
INFO && console.group('Edit Heightmap');
|
||||
TIME && console.time('regenerateErasedData');
|
||||
|
||||
const change = changeHeights.checked;
|
||||
const erosionAllowed = allowErosion.checked;
|
||||
markFeatures();
|
||||
getSignedDistanceField();
|
||||
if (change) openNearSeaLakes();
|
||||
markupGridOcean();
|
||||
if (erosionAllowed) {
|
||||
addLakesInDeepDepressions();
|
||||
openNearSeaLakes();
|
||||
}
|
||||
OceanLayers();
|
||||
calculateTemperatures();
|
||||
generatePrecipitation();
|
||||
reGraph();
|
||||
drawCoastline();
|
||||
|
||||
Rivers.generate(change);
|
||||
Rivers.generate(erosionAllowed);
|
||||
|
||||
if (!change) {
|
||||
if (!erosionAllowed) {
|
||||
for (const i of pack.cells.i) {
|
||||
const g = pack.cells.g[i];
|
||||
if (pack.cells.h[i] !== grid.cells.h[g] && pack.cells.h[i] >= 20 === grid.cells.h[g] >= 20) pack.cells.h[i] = grid.cells.h[g];
|
||||
|
|
@ -248,6 +245,7 @@ function editHeightmap() {
|
|||
function restoreRiskedData() {
|
||||
INFO && console.group('Edit Heightmap');
|
||||
TIME && console.time('restoreRiskedData');
|
||||
const erosionAllowed = allowErosion.checked;
|
||||
|
||||
// assign pack data to grid cells
|
||||
const l = grid.cells.i.length;
|
||||
|
|
@ -262,7 +260,7 @@ function editHeightmap() {
|
|||
const culture = new Uint16Array(l);
|
||||
const religion = new Uint16Array(l);
|
||||
|
||||
// rivers data, stored only if changeHeights is unchecked
|
||||
// rivers data, stored only if allowErosion is unchecked
|
||||
const fl = new Uint16Array(l);
|
||||
const r = new Uint16Array(l);
|
||||
const conf = new Uint8Array(l);
|
||||
|
|
@ -280,7 +278,7 @@ function editHeightmap() {
|
|||
burg[g] = pack.cells.burg[i];
|
||||
religion[g] = pack.cells.religion[i];
|
||||
|
||||
if (!changeHeights.checked) {
|
||||
if (!erosionAllowed) {
|
||||
fl[g] = pack.cells.fl[i];
|
||||
r[g] = pack.cells.r[i];
|
||||
conf[g] = pack.cells.conf[i];
|
||||
|
|
@ -312,14 +310,15 @@ function editHeightmap() {
|
|||
});
|
||||
|
||||
markFeatures();
|
||||
getSignedDistanceField();
|
||||
markupGridOcean();
|
||||
if (erosionAllowed) addLakesInDeepDepressions();
|
||||
OceanLayers();
|
||||
calculateTemperatures();
|
||||
generatePrecipitation();
|
||||
reGraph();
|
||||
drawCoastline();
|
||||
|
||||
if (changeHeights.checked) Rivers.generate(changeHeights.checked);
|
||||
if (erosionAllowed) Rivers.generate(true);
|
||||
|
||||
// assign saved pack data from grid back to pack
|
||||
const n = pack.cells.i.length;
|
||||
|
|
@ -334,7 +333,7 @@ function editHeightmap() {
|
|||
pack.cells.religion = new Uint16Array(n);
|
||||
pack.cells.biome = new Uint8Array(n);
|
||||
|
||||
if (!changeHeights.checked) {
|
||||
if (!erosionAllowed) {
|
||||
pack.cells.r = new Uint16Array(n);
|
||||
pack.cells.conf = new Uint8Array(n);
|
||||
pack.cells.fl = new Uint16Array(n);
|
||||
|
|
@ -348,7 +347,7 @@ function editHeightmap() {
|
|||
pack.cells.biome[i] = land && biome[g] ? biome[g] : getBiomeId(grid.cells.prec[g], pack.cells.h[i]);
|
||||
|
||||
// rivers data
|
||||
if (!changeHeights.checked) {
|
||||
if (!erosionAllowed) {
|
||||
pack.cells.r[i] = r[g];
|
||||
pack.cells.conf[i] = conf[g];
|
||||
pack.cells.fl[i] = fl[g];
|
||||
|
|
@ -412,7 +411,7 @@ function editHeightmap() {
|
|||
drawStates();
|
||||
drawBorders();
|
||||
|
||||
if (changeHeights.checked) {
|
||||
if (erosionAllowed) {
|
||||
Rivers.specify();
|
||||
Lakes.generateName();
|
||||
}
|
||||
|
|
@ -817,10 +816,25 @@ function editHeightmap() {
|
|||
const steps = body.querySelectorAll('div').length;
|
||||
const changed = +body.getAttribute('data-changed');
|
||||
const template = e.target.value;
|
||||
if (!steps || !changed) return changeTemplate(template);
|
||||
if (!steps || !changed) {
|
||||
changeTemplate(template);
|
||||
return;
|
||||
}
|
||||
|
||||
const message = 'Are you sure you want to select a different template? <br>All changes will be lost';
|
||||
confirmationDialog({title: 'Change template', message, confirm: 'Change', onConfirm: () => changeTemplate(template)});
|
||||
alertMessage.innerHTML = 'Are you sure you want to select a different template? All changes will be lost.';
|
||||
$('#alert').dialog({
|
||||
resizable: false,
|
||||
title: 'Change Template',
|
||||
buttons: {
|
||||
Change: function () {
|
||||
changeTemplate(template);
|
||||
$(this).dialog('close');
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function changeTemplate(template) {
|
||||
|
|
@ -952,7 +966,8 @@ function editHeightmap() {
|
|||
|
||||
for (const s of steps) {
|
||||
if (s.style.opacity == 0.5) continue;
|
||||
const type = s.getAttribute('data-type');
|
||||
const type = s.dataset.type;
|
||||
|
||||
const elCount = s.querySelector('.templateCount') || '';
|
||||
const elHeight = s.querySelector('.templateHeight') || '';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue