diff --git a/index.html b/index.html index 0c8a1e58..4fa89057 100644 --- a/index.html +++ b/index.html @@ -6076,21 +6076,37 @@
⚠️ Important Backup Warning
++ 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. + When saving to machine, files may be automatically renamed if a file with the same name already exists. +
- 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. -
A map is already saved in browser storage.
+Do you want to overwrite the existing saved map with the current one?
++ ⚠️ The previous map will be permanently lost if you continue. + Consider saving to machine first as a backup. +
+ `; + + $("#alert").dialog({ + resizable: false, + title: "Overwrite existing save?", + width: "28em", + buttons: { + "Yes, overwrite": function () { + $(this).dialog("close"); + resolve(true); + }, + "Cancel": function () { + $(this).dialog("close"); + resolve(false); + } + }, + position: {my: "center", at: "center", of: "svg"} + }); + }); +} diff --git a/modules/ui/editors.js b/modules/ui/editors.js index 3ebff350..b66e8173 100644 --- a/modules/ui/editors.js +++ b/modules/ui/editors.js @@ -892,10 +892,15 @@ function unfog(id) { if (!defs.selectAll("#fog path").size()) fogging.style("display", "none"); } -function getFileName(dataType) { +function getFileName(dataType, customName = null, includeTimestamp = true) { const formatTime = time => (time < 10 ? "0" + time : time); - const name = mapName.value; + const name = customName || mapName.value; const type = dataType ? dataType + " " : ""; + + if (!includeTimestamp) { + return name + (type ? " " + type.trim() : ""); + } + const date = new Date(); const year = date.getFullYear(); const month = formatTime(date.getMonth() + 1); diff --git a/modules/ui/options.js b/modules/ui/options.js index 537a6a4e..6e24e777 100644 --- a/modules/ui/options.js +++ b/modules/ui/options.js @@ -738,10 +738,24 @@ function showSavePane() { const sharableLinkContainer = byId("sharableLinkContainer"); sharableLinkContainer.style.display = "none"; + // Initialize the custom filename input with current map name + const customFileNameInput = byId("customFileName"); + const includeTimestampCheckbox = byId("includeTimestamp"); + + if (customFileNameInput) { + customFileNameInput.value = mapName.value || "Fantasy Map"; + // Store default state + customFileNameInput.dataset.defaultValue = customFileNameInput.value; + } + + if (includeTimestampCheckbox) { + includeTimestampCheckbox.checked = true; + } + $("#saveMapData").dialog({ title: "Save map", resizable: false, - width: "25em", + width: "32em", position: {my: "center", at: "center", of: "svg"}, buttons: { Close: function () {