mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
fixed previous problems
This commit is contained in:
parent
865fa6e5d1
commit
a13206eb4f
4 changed files with 24 additions and 11 deletions
9
main.js
9
main.js
|
|
@ -569,7 +569,7 @@ function generate() {
|
|||
BurgsAndStates.generate();
|
||||
BurgsAndStates.drawStateLabels();
|
||||
console.timeEnd("TOTAL");
|
||||
|
||||
|
||||
window.setTimeout(() => {
|
||||
showStatistics();
|
||||
console.groupEnd("Map " + seed);
|
||||
|
|
@ -1159,8 +1159,11 @@ const regenerateMap = debounce(function() {
|
|||
resetZoom(1000);
|
||||
generate();
|
||||
restoreLayers();
|
||||
if ($("#worldConfigurator").is(":visible")) editWorld();
|
||||
}, 500);
|
||||
if ($("#worldConfigurator").is(":visible")){
|
||||
editWorld();
|
||||
}
|
||||
saveBreadCrumb("newMap");
|
||||
}, 800);
|
||||
|
||||
// Clear the map
|
||||
function undraw() {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,15 @@
|
|||
* - at least you have the ability to revert your last change(s) now! ;)
|
||||
* - users can customize the size of this maybe we should give them a hint?
|
||||
*/
|
||||
function saveBreadCrumb() {
|
||||
function saveBreadCrumb(newMap) {
|
||||
console.time("saveBreadCrumb");
|
||||
|
||||
if(newMap != null && newMap == "newMap"){
|
||||
var emptyDataArray = new Array ();
|
||||
localStorage.setItem("breadCrumb", JSON.stringify(emptyDataArray));
|
||||
localStorage.setItem("breadCrumbIndex", emptyDataArray.length);
|
||||
}
|
||||
|
||||
const date = new Date();
|
||||
const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||
const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator";
|
||||
|
|
@ -50,7 +57,7 @@ function saveBreadCrumb() {
|
|||
}
|
||||
previousData[previousData.length] = data;
|
||||
localStorage.setItem("breadCrumb", JSON.stringify(previousData));
|
||||
localStorage.setItem("breadCrumbIndex", previousData.length);
|
||||
localStorage.setItem("breadCrumbIndex", previousData.length-1);
|
||||
}
|
||||
catch (e) {
|
||||
console.log("Storage failed: " + e);
|
||||
|
|
@ -114,11 +121,14 @@ function getPreviousBreadCrumb() {
|
|||
return null;
|
||||
}
|
||||
|
||||
const lastCrumbIndex = localStorage.getItem("breadCrumbIndex");
|
||||
var lastCrumbIndex = parseInt(localStorage.getItem("breadCrumbIndex"), 10);
|
||||
if(lastCrumbIndex > 0){
|
||||
localStorage.setItem("breadCrumbIndex", lastCrumbIndex-1);
|
||||
localStorage.setItem("breadCrumb", JSON.stringify(breadCrumbs.slice(0,breadCrumbs.length-1)));
|
||||
lastCrumbIndex -= 1;
|
||||
localStorage.setItem("breadCrumbIndex", lastCrumbIndex);
|
||||
localStorage.setItem("breadCrumb", JSON.stringify(breadCrumbs.slice(0,lastCrumbIndex+1)));
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
|
||||
return breadCrumbs[breadCrumbs.length-1];
|
||||
return breadCrumbs[lastCrumbIndex];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,7 +350,6 @@ function editCultures() {
|
|||
}
|
||||
|
||||
function applyCultureManualAssignent() {
|
||||
saveBreadCrumb();
|
||||
const changed = cults.select("#temp").selectAll("polygon");
|
||||
changed.each(function() {
|
||||
const i = +this.dataset.cell;
|
||||
|
|
@ -364,6 +363,7 @@ function editCultures() {
|
|||
refreshCulturesEditor();
|
||||
}
|
||||
exitCulturesManualAssignment();
|
||||
saveBreadCrumb("currentMap");
|
||||
}
|
||||
|
||||
function exitCulturesManualAssignment() {
|
||||
|
|
|
|||
|
|
@ -261,6 +261,6 @@ document.addEventListener("keydown", function(event) {
|
|||
else if (key === 56 || key === 104) zoom.scaleTo(svg, 8); // 8 to zoom to 8
|
||||
else if (key === 57 || key === 105) zoom.scaleTo(svg, 9); // 9 to zoom to 9
|
||||
|
||||
else if (ctrl && key === 90) {loadLastBreadCrumb(); undo.click();}// // Ctrl + "Z" to undo
|
||||
else if (ctrl && key === 90) { loadLastBreadCrumb(); }// // Ctrl + "Z" to undo undo.click();
|
||||
else if (ctrl && key === 89) redo.click(); // Ctrl + "Y" to redo
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue