From f20029eac55c9c9a24c61853cbc9142800d10017 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 10 Dec 2022 19:55:23 +0300 Subject: [PATCH] feat(#901): ability to lock seed in templates editor --- index.css | 5 ++--- index.html | 11 ++++++----- modules/ui/general.js | 2 +- modules/ui/heightmap-editor.js | 6 ++++-- versioning.js | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/index.css b/index.css index 58e92533..ae603566 100644 --- a/index.css +++ b/index.css @@ -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; diff --git a/index.html b/index.html index a448ac30..18ea0f0f 100644 --- a/index.html +++ b/index.html @@ -108,7 +108,7 @@ } - + @@ -4055,9 +4055,10 @@ onclick="wiki('Heightmap-template-editor')" > @@ -7857,7 +7858,7 @@ - + @@ -7866,7 +7867,7 @@ - + diff --git a/modules/ui/general.js b/modules/ui/general.js index fa030418..238dd2f1 100644 --- a/modules/ui/general.js +++ b/modules/ui/general.js @@ -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 diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js index 7f83354a..07216f90 100644 --- a/modules/ui/heightmap-editor.js +++ b/modules/ui/heightmap-editor.js @@ -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); diff --git a/versioning.js b/versioning.js index ee613a00..70a3027b 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.88.02"; // generator version, update each time +const version = "1.88.03"; // generator version, update each time { document.title += " v" + version;