mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31: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
14
index.html
14
index.html
|
|
@ -1830,6 +1830,7 @@
|
|||
<td>
|
||||
<select id="onloadBehavior" data-stored="onloadBehavior">
|
||||
<option value="random" selected>Generate random map</option>
|
||||
<option value="default">Open default map</option>
|
||||
<option value="lastSaved">Open last saved map</option>
|
||||
</select>
|
||||
</td>
|
||||
|
|
@ -6087,6 +6088,15 @@
|
|||
browser
|
||||
</button>
|
||||
</div>
|
||||
<div style="margin-top: 0.8em; padding-top: 0.8em; border-top: 1px solid #ccc">
|
||||
<strong>Default map</strong>
|
||||
<button onclick="saveAsDefaultMap()" data-tip="Set this map as the default that opens on load (requires 'Open default map' onload behavior)">
|
||||
Set as default
|
||||
</button>
|
||||
<button onclick="clearDefaultMap()" data-tip="Clear the current default map setting">
|
||||
Clear default
|
||||
</button>
|
||||
</div>
|
||||
<p>
|
||||
Maps are saved in <i>.map</i> format, that can be loaded back via the <i>Load</i> 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.
|
||||
|
|
@ -8118,7 +8128,7 @@
|
|||
<script src="modules/ui/style-presets.js?v=1.100.00"></script>
|
||||
<script src="modules/ui/general.js?v=1.100.00"></script>
|
||||
<script src="modules/ui/options.js?v=1.106.2"></script>
|
||||
<script src="main.js?v=1.108.1"></script>
|
||||
<script src="main.js?v=1.108.12">
|
||||
|
||||
<script defer src="modules/ui/style.js?v=1.108.4"></script>
|
||||
<script defer src="modules/ui/editors.js?v=1.108.5"></script>
|
||||
|
|
@ -8163,7 +8173,7 @@
|
|||
<script defer src="modules/coa-renderer.js?v=1.99.00"></script>
|
||||
<script defer src="libs/rgbquant.min.js"></script>
|
||||
<script defer src="libs/jquery.ui.touch-punch.min.js"></script>
|
||||
<script defer src="modules/io/save.js?v=1.107.4"></script>
|
||||
<script defer src="modules/io/save.js?v=1.108.12">
|
||||
<script defer src="modules/io/load.js?v=1.108.0"></script>
|
||||
<script defer src="modules/io/cloud.js?v=1.106.0"></script>
|
||||
<script defer src="modules/io/export.js?v=1.108.11"></script>
|
||||
|
|
|
|||
16
main.js
16
main.js
|
|
@ -291,6 +291,22 @@ async function checkLoadParameters() {
|
|||
return;
|
||||
}
|
||||
|
||||
// check if there is a default map saved to indexedDB
|
||||
if (byId("onloadBehavior").value === "default") {
|
||||
try {
|
||||
const blob = await ldb.get("defaultMap");
|
||||
if (blob) {
|
||||
WARN && console.warn("Loading default map");
|
||||
uploadMap(blob);
|
||||
return;
|
||||
} else {
|
||||
WARN && console.warn("No default map set, generating random map");
|
||||
}
|
||||
} catch (error) {
|
||||
ERROR && console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
// check if there is a map saved to indexedDB
|
||||
if (byId("onloadBehavior").value === "lastSaved") {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -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"});
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2
|
||||
*/
|
||||
|
||||
const VERSION = "1.108.11";
|
||||
const VERSION = "1.108.12";
|
||||
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue