mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
Requested Changes
This commit is contained in:
parent
6cbcc81332
commit
df9ede80f3
5 changed files with 15 additions and 16 deletions
15
main.js
15
main.js
|
|
@ -11,11 +11,10 @@ const version = "1.4"; // generator version
|
||||||
document.title += " v" + version;
|
document.title += " v" + version;
|
||||||
|
|
||||||
// Switches to disable/enable logging features
|
// Switches to disable/enable logging features
|
||||||
var LOG = 0;
|
const INFO = 0;
|
||||||
var TIME = 0;
|
const TIME = 0;
|
||||||
var GROUP = 0;
|
const WARN = 1;
|
||||||
var WARN = 0;
|
const ERROR = 1;
|
||||||
var ERROR = 0;
|
|
||||||
|
|
||||||
// if map version is not stored, clear localStorage and show a message
|
// if map version is not stored, clear localStorage and show a message
|
||||||
if (rn(localStorage.getItem("version"), 2) !== rn(version, 2)) {
|
if (rn(localStorage.getItem("version"), 2) !== rn(version, 2)) {
|
||||||
|
|
@ -514,7 +513,7 @@ function generate() {
|
||||||
const timeStart = performance.now();
|
const timeStart = performance.now();
|
||||||
invokeActiveZooming();
|
invokeActiveZooming();
|
||||||
generateSeed();
|
generateSeed();
|
||||||
GROUP && console.group("Generated Map " + seed);
|
INFO && console.group("Generated Map " + seed);
|
||||||
applyMapSize();
|
applyMapSize();
|
||||||
randomizeOptions();
|
randomizeOptions();
|
||||||
placePoints();
|
placePoints();
|
||||||
|
|
@ -557,7 +556,7 @@ function generate() {
|
||||||
|
|
||||||
WARN && console.warn(`TOTAL: ${rn((performance.now()-timeStart)/1000,2)}s`);
|
WARN && console.warn(`TOTAL: ${rn((performance.now()-timeStart)/1000,2)}s`);
|
||||||
showStatistics();
|
showStatistics();
|
||||||
GROUP && console.groupEnd("Generated Map " + seed);
|
INFO && console.groupEnd("Generated Map " + seed);
|
||||||
}
|
}
|
||||||
catch(error) {
|
catch(error) {
|
||||||
ERROR && console.error(error);
|
ERROR && console.error(error);
|
||||||
|
|
@ -1719,7 +1718,7 @@ function showStatistics() {
|
||||||
|
|
||||||
mapId = Date.now(); // unique map id is it's creation date number
|
mapId = Date.now(); // unique map id is it's creation date number
|
||||||
mapHistory.push({seed, width:graphWidth, height:graphHeight, template, created:mapId});
|
mapHistory.push({seed, width:graphWidth, height:graphHeight, template, created:mapId});
|
||||||
LOG && console.log(stats);
|
INFO && console.log(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
const regenerateMap = debounce(function() {
|
const regenerateMap = debounce(function() {
|
||||||
|
|
|
||||||
|
|
@ -564,7 +564,7 @@ function parseLoadedData(data) {
|
||||||
mapId = params[6] ? +params[6] : Date.now();
|
mapId = params[6] ? +params[6] : Date.now();
|
||||||
}()
|
}()
|
||||||
|
|
||||||
GROUP && console.group("Loaded Map " + seed);
|
INFO && console.group("Loaded Map " + seed);
|
||||||
|
|
||||||
void function parseSettings() {
|
void function parseSettings() {
|
||||||
const settings = data[1].split("|");
|
const settings = data[1].split("|");
|
||||||
|
|
@ -1067,7 +1067,7 @@ function parseLoadedData(data) {
|
||||||
|
|
||||||
WARN && console.warn(`TOTAL: ${rn((performance.now()-uploadMap.timeStart)/1000,2)}s`);
|
WARN && console.warn(`TOTAL: ${rn((performance.now()-uploadMap.timeStart)/1000,2)}s`);
|
||||||
showStatistics();
|
showStatistics();
|
||||||
GROUP && console.groupEnd("Loaded Map " + seed);
|
INFO && console.groupEnd("Loaded Map " + seed);
|
||||||
tip("Map is successfully loaded", true, "success", 7000);
|
tip("Map is successfully loaded", true, "success", 7000);
|
||||||
}
|
}
|
||||||
catch(error) {
|
catch(error) {
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ function editHeightmap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function regenerateErasedData() {
|
function regenerateErasedData() {
|
||||||
GROUP && console.group("Edit Heightmap");
|
INFO && console.group("Edit Heightmap");
|
||||||
TIME && console.time("regenerateErasedData");
|
TIME && console.time("regenerateErasedData");
|
||||||
|
|
||||||
const change = changeHeights.checked;
|
const change = changeHeights.checked;
|
||||||
|
|
@ -205,7 +205,7 @@ function editHeightmap() {
|
||||||
addMarkers();
|
addMarkers();
|
||||||
addZones();
|
addZones();
|
||||||
TIME && console.timeEnd("regenerateErasedData");
|
TIME && console.timeEnd("regenerateErasedData");
|
||||||
GROUP && console.groupEnd("Edit Heightmap");
|
INFO && console.groupEnd("Edit Heightmap");
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreKeptData() {
|
function restoreKeptData() {
|
||||||
|
|
@ -216,7 +216,7 @@ function editHeightmap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreRiskedData() {
|
function restoreRiskedData() {
|
||||||
GROUP && console.group("Edit Heightmap");
|
INFO && console.group("Edit Heightmap");
|
||||||
TIME && console.time("restoreRiskedData");
|
TIME && console.time("restoreRiskedData");
|
||||||
|
|
||||||
// assign pack data to grid cells
|
// assign pack data to grid cells
|
||||||
|
|
@ -402,7 +402,7 @@ function editHeightmap() {
|
||||||
});
|
});
|
||||||
|
|
||||||
TIME && console.timeEnd("restoreRiskedData");
|
TIME && console.timeEnd("restoreRiskedData");
|
||||||
GROUP && console.groupEnd("Edit Heightmap");
|
INFO && console.groupEnd("Edit Heightmap");
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger heightmap redraw and history update if at least 1 cell is changed
|
// trigger heightmap redraw and history update if at least 1 cell is changed
|
||||||
|
|
|
||||||
|
|
@ -653,7 +653,7 @@ function setBase64Texture(url) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function fetchTextureURL(url) {
|
function fetchTextureURL(url) {
|
||||||
LOG && console.log("Provided URL is", url);
|
INFO && console.log("Provided URL is", url);
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
const canvas = document.getElementById("texturePreview");
|
const canvas = document.getElementById("texturePreview");
|
||||||
|
|
|
||||||
|
|
@ -628,4 +628,4 @@ void function() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// indexedDB; ldb object
|
// indexedDB; ldb object
|
||||||
!function(){function e(t,o){return n?void(n.transaction("s").objectStore("s").get(t).onsuccess=function(e){var t=e.target.result&&e.target.result.v||null;o(t)}):void setTimeout(function(){e(t,o)},100)}var t=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB;if(!t)return void ERROR && console.error("indexedDB not supported");var n,o={k:"",v:""},r=t.open("d2",1);r.onsuccess=function(e){n=this.result},r.onerror=function(e){ERROR && console.error("indexedDB request error"),LOG && console.log(e)},r.onupgradeneeded=function(e){n=null;var t=e.target.result.createObjectStore("s",{keyPath:"k"});t.transaction.oncomplete=function(e){n=e.target.db}},window.ldb={get:e,set:function(e,t){o.k=e,o.v=t,n.transaction("s","readwrite").objectStore("s").put(o)}}}();
|
!function(){function e(t,o){return n?void(n.transaction("s").objectStore("s").get(t).onsuccess=function(e){var t=e.target.result&&e.target.result.v||null;o(t)}):void setTimeout(function(){e(t,o)},100)}var t=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB;if(!t)return void ERROR && console.error("indexedDB not supported");var n,o={k:"",v:""},r=t.open("d2",1);r.onsuccess=function(e){n=this.result},r.onerror=function(e){ERROR && console.error("indexedDB request error"),INFO && console.log(e)},r.onupgradeneeded=function(e){n=null;var t=e.target.result.createObjectStore("s",{keyPath:"k"});t.transaction.oncomplete=function(e){n=e.target.db}},window.ldb={get:e,set:function(e,t){o.k=e,o.v=t,n.transaction("s","readwrite").objectStore("s").put(o)}}}();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue