mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
Merge remote-tracking branch 'origin/master' into gui/lock-everything
# Conflicts: # index.html # versioning.js
This commit is contained in:
commit
ae9ba6c077
9 changed files with 39 additions and 27 deletions
|
|
@ -980,7 +980,7 @@ fieldset {
|
|||
|
||||
#templateBody > div > span {
|
||||
float: right;
|
||||
margin: 0 1px 0 0.5px;
|
||||
margin-inline: 1px;
|
||||
}
|
||||
|
||||
#templateBody > div > i {
|
||||
|
|
@ -989,10 +989,9 @@ fieldset {
|
|||
|
||||
#templateBody input,
|
||||
#templateBody select {
|
||||
width: 4em;
|
||||
width: 4.5em;
|
||||
height: 1em;
|
||||
border: 0;
|
||||
font-size: 0.95em;
|
||||
background-color: #ffffff95;
|
||||
color: #05044d;
|
||||
font-style: italic;
|
||||
|
|
|
|||
15
index.html
15
index.html
|
|
@ -4055,9 +4055,10 @@
|
|||
onclick="wiki('Heightmap-template-editor')"
|
||||
></button>
|
||||
<label
|
||||
data-tip="Set seed if you want template to generate the same heightmap each time. Leave blank to use random seed"
|
||||
data-tip="Lock seed (click on lock icon) if you want template to generate the same heightmap each time"
|
||||
>
|
||||
Seed: <input id="templateSeed" value="" type="number" min="1" max="999999999" step="1" style="width: 7em" />
|
||||
Seed: <input id="templateSeed" value="" type="number" min="1" max="999999999" step="1" style="width: 8em" />
|
||||
<i data-locked="0" id="lock_templateSeed" class="icon-lock-open"></i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -7824,7 +7825,7 @@
|
|||
<script src="utils/commonUtils.js"></script>
|
||||
<script src="utils/arrayUtils.js"></script>
|
||||
<script src="utils/colorUtils.js"></script>
|
||||
<script src="utils/graphUtils.js"></script>
|
||||
<script src="utils/graphUtils.js?v=1.88.02"></script>
|
||||
<script src="utils/nodeUtils.js"></script>
|
||||
<script src="utils/numberUtils.js"></script>
|
||||
<script src="utils/polyfills.js"></script>
|
||||
|
|
@ -7857,16 +7858,16 @@
|
|||
<script src="modules/ui/measurers.js?v=1.87.02"></script>
|
||||
<script src="modules/ui/stylePresets.js"></script>
|
||||
|
||||
<script src="modules/ui/general.js?v=1.87.00"></script>
|
||||
<script src="modules/ui/options.js?v=1.87.15"></script>
|
||||
<script src="main.js?v=1.87.15"></script>
|
||||
<script src="modules/ui/general.js?v=1.87.03"></script>
|
||||
<script src="modules/ui/options.js?v=1.88.02"></script>
|
||||
<script src="main.js?v=1.88.02"></script>
|
||||
|
||||
<script defer src="modules/relief-icons.js"></script>
|
||||
<script defer src="modules/ui/style.js"></script>
|
||||
<script defer src="modules/ui/editors.js?v=1.87.07"></script>
|
||||
<script defer src="modules/ui/tools.js?v=1.89.00"></script>
|
||||
<script defer src="modules/ui/world-configurator.js"></script>
|
||||
<script defer src="modules/ui/heightmap-editor.js?v=1.88.00"></script>
|
||||
<script defer src="modules/ui/heightmap-editor.js?v=1.88.03"></script>
|
||||
<script defer src="modules/ui/provinces-editor.js?v=1.89.00"></script>
|
||||
<script defer src="modules/ui/biomes-editor.js"></script>
|
||||
<script defer src="modules/ui/namesbase-editor.js?v=1.87.10"></script>
|
||||
|
|
|
|||
8
main.js
8
main.js
|
|
@ -692,7 +692,7 @@ async function generate(options) {
|
|||
applyMapSize();
|
||||
randomizeOptions();
|
||||
|
||||
if (shouldRegenerateGrid(grid)) grid = precreatedGraph || generateGrid();
|
||||
if (shouldRegenerateGrid(grid, precreatedSeed)) grid = precreatedGraph || generateGrid();
|
||||
else delete grid.cells.h;
|
||||
grid.cells.h = await HeightmapGenerator.generate(grid);
|
||||
|
||||
|
|
@ -774,12 +774,10 @@ async function generate(options) {
|
|||
function setSeed(precreatedSeed) {
|
||||
if (!precreatedSeed) {
|
||||
const first = !mapHistory[0];
|
||||
const url = new URL(window.location.href);
|
||||
const params = url.searchParams;
|
||||
const urlSeed = url.searchParams.get("seed");
|
||||
const params = new URL(window.location.href).searchParams;
|
||||
const urlSeed = params.get("seed");
|
||||
if (first && params.get("from") === "MFCG" && urlSeed.length === 13) seed = urlSeed.slice(0, -4);
|
||||
else if (first && urlSeed) seed = urlSeed;
|
||||
else if (optionsSeed.value && optionsSeed.value != seed) seed = optionsSeed.value;
|
||||
else seed = generateSeed();
|
||||
} else {
|
||||
seed = precreatedSeed;
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ function getName(id) {
|
|||
}
|
||||
|
||||
function getGraph(currentGraph) {
|
||||
const newGraph = shouldRegenerateGrid(currentGraph) ? generateGrid() : deepCopy(currentGraph);
|
||||
const newGraph = shouldRegenerateGrid(currentGraph, seed) ? generateGrid() : deepCopy(currentGraph);
|
||||
delete newGraph.cells.h;
|
||||
return newGraph;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ function unlock(id) {
|
|||
// check if option is locked
|
||||
function locked(id) {
|
||||
const lockEl = document.getElementById("lock_" + id);
|
||||
return lockEl.dataset.locked == 1;
|
||||
return lockEl.dataset.locked === "1";
|
||||
}
|
||||
|
||||
// return key value stored in localStorage or null
|
||||
|
|
|
|||
|
|
@ -1041,8 +1041,10 @@ function editHeightmap(options) {
|
|||
const steps = byId("templateBody").querySelectorAll("#templateBody > div");
|
||||
if (!steps.length) return;
|
||||
|
||||
const seed = byId("templateSeed").value;
|
||||
if (seed) Math.random = aleaPRNG(seed);
|
||||
const currentSeed = byId("templateSeed").value;
|
||||
const seed = (locked("templateSeed") && currentSeed) || generateSeed();
|
||||
Math.random = aleaPRNG(seed);
|
||||
byId("templateSeed").value = seed;
|
||||
|
||||
grid.cells.h = createTypedArray({maxValue: 100, length: grid.points.length});
|
||||
HeightmapGenerator.setGraph(grid);
|
||||
|
|
|
|||
|
|
@ -257,8 +257,8 @@ function testSpeaker() {
|
|||
}
|
||||
|
||||
function generateMapWithSeed() {
|
||||
if (optionsSeed.value == seed) return tip("The current map already has this seed", false, "error");
|
||||
regeneratePrompt();
|
||||
if (optionsSeed.value === seed) return tip("The current map already has this seed", false, "error");
|
||||
regeneratePrompt({seed: optionsSeed.value});
|
||||
}
|
||||
|
||||
function showSeedHistoryDialog() {
|
||||
|
|
@ -288,7 +288,7 @@ function restoreSeed(id) {
|
|||
|
||||
if (locked("template")) unlock("template");
|
||||
|
||||
regeneratePrompt();
|
||||
regeneratePrompt({seed});
|
||||
}
|
||||
|
||||
function restoreDefaultZoomExtent() {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
// FMG utils related to graph
|
||||
|
||||
// check if new grid graph should be generated or we can use the existing one
|
||||
function shouldRegenerateGrid(grid) {
|
||||
function shouldRegenerateGrid(grid, expectedSeed) {
|
||||
if (expectedSeed && expectedSeed !== grid.seed) return true;
|
||||
|
||||
const cellsDesired = +byId("pointsInput").dataset.cells;
|
||||
if (cellsDesired !== grid.cellsDesired) return true;
|
||||
|
||||
|
|
@ -17,7 +19,7 @@ function generateGrid() {
|
|||
Math.random = aleaPRNG(seed); // reset PRNG
|
||||
const {spacing, cellsDesired, boundary, points, cellsX, cellsY} = placePoints();
|
||||
const {cells, vertices} = calculateVoronoi(points, boundary);
|
||||
return {spacing, cellsDesired, boundary, points, cellsX, cellsY, cells, vertices};
|
||||
return {spacing, cellsDesired, boundary, points, cellsX, cellsY, cells, vertices, seed};
|
||||
}
|
||||
|
||||
// place random points to calculate Voronoi diagram
|
||||
|
|
@ -96,7 +98,10 @@ function getJitteredGrid(width, height, spacing) {
|
|||
|
||||
// return cell index on a regular square grid
|
||||
function findGridCell(x, y, grid) {
|
||||
return Math.floor(Math.min(y / grid.spacing, grid.cellsY - 1)) * grid.cellsX + Math.floor(Math.min(x / grid.spacing, grid.cellsX - 1));
|
||||
return (
|
||||
Math.floor(Math.min(y / grid.spacing, grid.cellsY - 1)) * grid.cellsX +
|
||||
Math.floor(Math.min(x / grid.spacing, grid.cellsX - 1))
|
||||
);
|
||||
}
|
||||
|
||||
// return array of cell indexes in radius on a regular square grid
|
||||
|
|
@ -246,7 +251,14 @@ void (function addFindAll() {
|
|||
i++;
|
||||
|
||||
// Stop searching if this quadrant can’t contain a closer node.
|
||||
if (!(t.node = t.q.node) || (t.x1 = t.q.x0) > t.x3 || (t.y1 = t.q.y0) > t.y3 || (t.x2 = t.q.x1) < t.x0 || (t.y2 = t.q.y1) < t.y0) continue;
|
||||
if (
|
||||
!(t.node = t.q.node) ||
|
||||
(t.x1 = t.q.x0) > t.x3 ||
|
||||
(t.y1 = t.q.y0) > t.y3 ||
|
||||
(t.x2 = t.q.x1) < t.x0 ||
|
||||
(t.y2 = t.q.y1) < t.y0
|
||||
)
|
||||
continue;
|
||||
|
||||
// Bisect the current quadrant.
|
||||
if (t.node.length) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
// version and caching control
|
||||
const version = "1.89.00"; // generator version, update each time
|
||||
const version = "1.89.00";
|
||||
|
||||
{
|
||||
document.title += " v" + version;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue