feat: add default map setting feature

Add ability to set a specific map as the default that opens on load:

- Add 'Open default map' option to onload behavior dropdown
- Implement saveAsDefaultMap() to store map as default in IndexedDB
- Implement clearDefaultMap() to remove default map setting
- Modify checkLoadParameters() to load default map when configured
- Add UI buttons in Save dialog for setting/clearing default map
- Update version to 1.108.12 and hash in index.html

Users can now:
1. Open any map they want as default
2. Go to Options > Onload behavior > Select "Open default map"
3. Save > Click "Set as default" button
4. The map will now open automatically every time

This sets the foundation for the planned time-based worldbuilding
and lore database features by ensuring users always start with
their primary world map.
This commit is contained in:
Claude 2025-11-14 02:33:16 +00:00
parent 6afa016920
commit acc2d112f3
No known key found for this signature in database
4 changed files with 55 additions and 3 deletions

View file

@ -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"});