mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 10:01:23 +01:00
Implement improved save functionality with custom filename, timestamp toggle, and overwrite protection
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
This commit is contained in:
parent
ba837ab6f8
commit
df15f74d95
4 changed files with 113 additions and 18 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue