mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
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:
parent
6afa016920
commit
acc2d112f3
4 changed files with 55 additions and 3 deletions
|
|
@ -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"});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue