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
7
main.js
7
main.js
|
|
@ -1159,8 +1159,11 @@ const regenerateMap = debounce(function() {
|
||||||
resetZoom(1000);
|
resetZoom(1000);
|
||||||
generate();
|
generate();
|
||||||
restoreLayers();
|
restoreLayers();
|
||||||
if ($("#worldConfigurator").is(":visible")) editWorld();
|
if ($("#worldConfigurator").is(":visible")){
|
||||||
}, 500);
|
editWorld();
|
||||||
|
}
|
||||||
|
saveBreadCrumb("newMap");
|
||||||
|
}, 800);
|
||||||
|
|
||||||
// Clear the map
|
// Clear the map
|
||||||
function undraw() {
|
function undraw() {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,15 @@
|
||||||
* - at least you have the ability to revert your last change(s) now! ;)
|
* - 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?
|
* - users can customize the size of this maybe we should give them a hint?
|
||||||
*/
|
*/
|
||||||
function saveBreadCrumb() {
|
function saveBreadCrumb(newMap) {
|
||||||
console.time("saveBreadCrumb");
|
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 date = new Date();
|
||||||
const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||||
const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator";
|
const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator";
|
||||||
|
|
@ -50,7 +57,7 @@ function saveBreadCrumb() {
|
||||||
}
|
}
|
||||||
previousData[previousData.length] = data;
|
previousData[previousData.length] = data;
|
||||||
localStorage.setItem("breadCrumb", JSON.stringify(previousData));
|
localStorage.setItem("breadCrumb", JSON.stringify(previousData));
|
||||||
localStorage.setItem("breadCrumbIndex", previousData.length);
|
localStorage.setItem("breadCrumbIndex", previousData.length-1);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log("Storage failed: " + e);
|
console.log("Storage failed: " + e);
|
||||||
|
|
@ -114,11 +121,14 @@ function getPreviousBreadCrumb() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastCrumbIndex = localStorage.getItem("breadCrumbIndex");
|
var lastCrumbIndex = parseInt(localStorage.getItem("breadCrumbIndex"), 10);
|
||||||
if(lastCrumbIndex > 0){
|
if(lastCrumbIndex > 0){
|
||||||
localStorage.setItem("breadCrumbIndex", lastCrumbIndex-1);
|
lastCrumbIndex -= 1;
|
||||||
localStorage.setItem("breadCrumb", JSON.stringify(breadCrumbs.slice(0,breadCrumbs.length-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() {
|
function applyCultureManualAssignent() {
|
||||||
saveBreadCrumb();
|
|
||||||
const changed = cults.select("#temp").selectAll("polygon");
|
const changed = cults.select("#temp").selectAll("polygon");
|
||||||
changed.each(function() {
|
changed.each(function() {
|
||||||
const i = +this.dataset.cell;
|
const i = +this.dataset.cell;
|
||||||
|
|
@ -364,6 +363,7 @@ function editCultures() {
|
||||||
refreshCulturesEditor();
|
refreshCulturesEditor();
|
||||||
}
|
}
|
||||||
exitCulturesManualAssignment();
|
exitCulturesManualAssignment();
|
||||||
|
saveBreadCrumb("currentMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
function exitCulturesManualAssignment() {
|
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 === 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 (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
|
else if (ctrl && key === 89) redo.click(); // Ctrl + "Y" to redo
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue