mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 18:41:23 +01:00
feat: drawFeatures
This commit is contained in:
parent
6d9c86ba74
commit
4b071730f7
16 changed files with 233 additions and 416 deletions
|
|
@ -225,7 +225,6 @@ function editHeightmap(options) {
|
|||
generatePrecipitation();
|
||||
reGraph();
|
||||
Features.markupPack();
|
||||
drawCoastline();
|
||||
|
||||
Rivers.generate(erosionAllowed);
|
||||
|
||||
|
|
@ -237,7 +236,6 @@ function editHeightmap(options) {
|
|||
}
|
||||
}
|
||||
|
||||
Lakes.defineGroup();
|
||||
Biomes.define();
|
||||
rankCells();
|
||||
|
||||
|
|
@ -255,7 +253,7 @@ function editHeightmap(options) {
|
|||
drawStateLabels();
|
||||
|
||||
Rivers.specify();
|
||||
Lakes.generateName();
|
||||
Features.specify();
|
||||
|
||||
Military.generate();
|
||||
Markers.generate();
|
||||
|
|
@ -343,7 +341,6 @@ function editHeightmap(options) {
|
|||
generatePrecipitation();
|
||||
reGraph();
|
||||
Features.markupPack();
|
||||
drawCoastline();
|
||||
|
||||
if (erosionAllowed) Rivers.generate(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -92,28 +92,23 @@ function restoreCustomPresets() {
|
|||
}
|
||||
|
||||
// run on map generation
|
||||
function applyPreset() {
|
||||
function applyLayersPreset() {
|
||||
const preset = localStorage.getItem("preset") || byId("layersPreset").value;
|
||||
changePreset(preset);
|
||||
changeLayersPreset(preset);
|
||||
}
|
||||
|
||||
// toggle layers on preset change
|
||||
function changePreset(preset) {
|
||||
function changeLayersPreset(preset) {
|
||||
const layers = presets[preset]; // layers to be turned on
|
||||
document
|
||||
.getElementById("mapLayers")
|
||||
.querySelectorAll("li")
|
||||
.forEach(function (e) {
|
||||
if (layers.includes(e.id) && !layerIsOn(e.id)) e.click();
|
||||
else if (!layers.includes(e.id) && layerIsOn(e.id)) e.click();
|
||||
});
|
||||
layersPreset.value = preset;
|
||||
localStorage.setItem("preset", preset);
|
||||
|
||||
const isDefault = getDefaultPresets()[preset];
|
||||
removePresetButton.style.display = isDefault ? "none" : "inline-block";
|
||||
savePresetButton.style.display = "none";
|
||||
if (byId("canvas3d")) setTimeout(ThreeD.update(), 400);
|
||||
byId("removePresetButton").style.display = isDefault ? "none" : "inline-block";
|
||||
byId("savePresetButton").style.display = "none";
|
||||
|
||||
document.querySelectorAll("#mapLayers > li").forEach(e => (e.className = layers.includes(e.id) ? null : "buttonoff"));
|
||||
drawLayers();
|
||||
if (byId("canvas3d")) setTimeout(() => ThreeD.update(), 400);
|
||||
}
|
||||
|
||||
function savePreset() {
|
||||
|
|
@ -161,8 +156,9 @@ function getCurrentPreset() {
|
|||
savePresetButton.style.display = "inline-block";
|
||||
}
|
||||
|
||||
// run on map regeneration
|
||||
function restoreLayers() {
|
||||
// run on each map generation
|
||||
function drawLayers() {
|
||||
drawFeatures();
|
||||
if (layerIsOn("toggleTexture")) drawTexture();
|
||||
if (layerIsOn("toggleHeight")) drawHeightmap();
|
||||
if (layerIsOn("toggleCells")) drawCells();
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ window.UISubmap = (function () {
|
|||
|
||||
oldstate = null; // destroy old state to free memory
|
||||
|
||||
restoreLayers();
|
||||
drawLayers();
|
||||
if (ThreeD.options.isOn) ThreeD.redraw();
|
||||
if ($("#worldConfigurator").is(":visible")) editWorld();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ function regenerateRoutes() {
|
|||
|
||||
function regenerateRivers() {
|
||||
Rivers.generate();
|
||||
Lakes.defineGroup();
|
||||
Rivers.specify();
|
||||
Features.specify();
|
||||
if (layerIsOn("toggleRivers")) drawRivers();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,10 +86,10 @@ function editWorld() {
|
|||
generatePrecipitation();
|
||||
const heights = new Uint8Array(pack.cells.h);
|
||||
Rivers.generate();
|
||||
Lakes.defineGroup();
|
||||
Rivers.specify();
|
||||
pack.cells.h = new Float32Array(heights);
|
||||
Biomes.define();
|
||||
Features.specify();
|
||||
|
||||
if (layerIsOn("toggleTemperature")) drawTemperature();
|
||||
if (layerIsOn("togglePrecipitation")) drawPrecipitation();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue