diff --git a/index.html b/index.html index 3c0ba0f3..9175879e 100644 --- a/index.html +++ b/index.html @@ -1830,6 +1830,7 @@
Maps are saved in .map format, that can be loaded back via the Load in menu. There is no way to restore the progress if file is lost. Please keep old save files on your machine or cloud storage as backups. @@ -8118,7 +8128,7 @@ - + @@ -8163,7 +8173,7 @@ - + diff --git a/main.js b/main.js index 848ff3c5..4f4bdb63 100644 --- a/main.js +++ b/main.js @@ -291,6 +291,22 @@ async function checkLoadParameters() { return; } + // check if there is a default map saved to indexedDB + if (byId("onloadBehavior").value === "default") { + try { + const blob = await ldb.get("defaultMap"); + if (blob) { + WARN && console.warn("Loading default map"); + uploadMap(blob); + return; + } else { + WARN && console.warn("No default map set, generating random map"); + } + } catch (error) { + ERROR && console.error(error); + } + } + // check if there is a map saved to indexedDB if (byId("onloadBehavior").value === "lastSaved") { try { diff --git a/modules/io/save.js b/modules/io/save.js index 304fef59..7a9236c7 100644 --- a/modules/io/save.js +++ b/modules/io/save.js @@ -167,6 +167,32 @@ async function saveToStorage(mapData, showTip = false) { showTip && tip("Map is saved to the browser storage", false, "success"); } +// save current map as the default map +async function saveAsDefaultMap() { + if (customization) return tip("Map cannot be saved in EDIT mode, please complete the edit and retry", false, "error"); + + try { + const mapData = prepareMapData(); + const blob = new Blob([mapData], {type: "text/plain"}); + await ldb.set("defaultMap", blob); + tip("Map is set as default and will open on load", true, "success", 5000); + } catch (error) { + ERROR && console.error(error); + tip("Failed to set default map", true, "error", 3000); + } +} + +// clear the default map setting +async function clearDefaultMap() { + try { + await ldb.set("defaultMap", null); + tip("Default map cleared", false, "success", 2000); + } catch (error) { + ERROR && console.error(error); + tip("Failed to clear default map", false, "error", 2000); + } +} + // download map file function saveToMachine(mapData, filename) { const blob = new Blob([mapData], {type: "text/plain"}); diff --git a/versioning.js b/versioning.js index a785e90e..1094599c 100644 --- a/versioning.js +++ b/versioning.js @@ -13,7 +13,7 @@ * Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2 */ -const VERSION = "1.108.11"; +const VERSION = "1.108.12"; if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function"); {