mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
refactor file save type to .gz and update the data in ui.
This commit is contained in:
parent
3f205cd499
commit
d25f626b8b
9 changed files with 40 additions and 39 deletions
|
|
@ -1,5 +1,5 @@
|
|||
"use strict";
|
||||
// functions to save project as .map file
|
||||
// functions to save project as .gz file
|
||||
|
||||
// prepare map data for saving
|
||||
function getMapData() {
|
||||
|
|
@ -126,7 +126,7 @@ async function compressMapData(mapData){
|
|||
}
|
||||
|
||||
|
||||
// Download .map file
|
||||
// Download .gz file
|
||||
async function downloadMap() {
|
||||
if (customization)
|
||||
return tip("Map cannot be saved when edit mode is active, please exit the mode and retry", false, "error");
|
||||
|
|
@ -136,7 +136,7 @@ async function downloadMap() {
|
|||
const blob = new Blob([mapData], {type: "text/plain"});
|
||||
const URL = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement("a");
|
||||
link.download = getFileName() + ".map";
|
||||
link.download = getFileName() + ".gz";
|
||||
link.href = URL;
|
||||
link.click();
|
||||
tip(`${link.download} is saved. Open "Downloads" screen (CTRL + J) to check`, true, "success", 7000);
|
||||
|
|
@ -148,13 +148,13 @@ async function saveToDropbox() {
|
|||
return tip("Map cannot be saved when edit mode is active, please exit the mode and retry", false, "error");
|
||||
closeDialogs("#alert");
|
||||
const mapData = await compressMapData(getMapData());
|
||||
const filename = getFileName() + ".map";
|
||||
const filename = getFileName() + ".gz";
|
||||
try {
|
||||
await Cloud.providers.dropbox.save(filename, mapData);
|
||||
tip("Map is saved to your Dropbox", true, "success", 8000);
|
||||
} catch (msg) {
|
||||
ERROR && console.error(msg);
|
||||
tip("Cannot save .map to your Dropbox", true, "error", 8000);
|
||||
tip("Cannot save .gz to your Dropbox", true, "error", 8000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,19 +188,19 @@ async function quickSave() {
|
|||
const mapData = await compressMapData(getMapData());
|
||||
const blob = new Blob([mapData], {type: "text/plain"});
|
||||
await ldb.set("lastMap", blob); // auto-save map
|
||||
tip("Map is saved to browser memory. Please also save as .map file to secure progress", true, "success", 2000);
|
||||
tip("Map is saved to browser memory. Please also save as .gz file to secure progress", true, "success", 2000);
|
||||
}
|
||||
|
||||
const saveReminder = function () {
|
||||
if (localStorage.getItem("noReminder")) return;
|
||||
const message = [
|
||||
"Please don't forget to save your work as a .map file",
|
||||
"Please remember to save work as a .map file",
|
||||
"Saving in .map format will ensure your data won't be lost in case of issues",
|
||||
"Please don't forget to save your work as a .gz file",
|
||||
"Please remember to save work as a .gz file",
|
||||
"Saving in .gz format will ensure your data won't be lost in case of issues",
|
||||
"Safety is number one priority. Please save the map",
|
||||
"Don't forget to save your map on a regular basis!",
|
||||
"Just a gentle reminder for you to save the map",
|
||||
"Please don't forget to save your progress (saving as .map is the best option)",
|
||||
"Please don't forget to save your progress (saving as .gz is the best option)",
|
||||
"Don't want to be reminded about need to save? Press CTRL+Q"
|
||||
];
|
||||
const interval = 15 * 60 * 1000; // remind every 15 minutes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue