mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
* Add the ability to lock states, provinces, cultures, and religions (#902) * Add the basis for locking everything, code and test the culture locking * Got the religion generator working, but not the tree. There are cycles being generated * Religions work now, including the tree view * Got the states and provinces working as well, all good and ready * Refresh the province editor when regenerating * Implement the versioning steps * Fix the state naming and color changing even when locked * The fix did not work with loaded maps, fix that too * Fix a few more bugs and address the PR feedback * Fix the state expanding event when they're locked bug * Implement some logic to ignore state being locked when regenerating provinces directly. * refactor(#902): start with states regenertion * refactor(#902): locked states cells to be assigned on start * refactor(#902): lock state - keep label * refactor(#902): lock provinces * refactor(#902): regenerate states - update provinces * refactor(#902): regenerate cultures * refactor(#902): regenerate religions Co-authored-by: Guillaume St-Pierre <gstpierre01@gmail.com> Co-authored-by: Azgaar <maxganiev@yandex.com>
73 lines
2.8 KiB
JavaScript
73 lines
2.8 KiB
JavaScript
"use strict";
|
||
|
||
// version and caching control
|
||
const version = "1.89.00"; // generator version, update each time
|
||
|
||
{
|
||
document.title += " v" + version;
|
||
const loadingScreenVersion = document.getElementById("version");
|
||
if (loadingScreenVersion) loadingScreenVersion.innerHTML = version;
|
||
|
||
const versionNumber = parseFloat(version);
|
||
const storedVersion = localStorage.getItem("version") ? parseFloat(localStorage.getItem("version")) : 0;
|
||
|
||
const isOutdated = storedVersion !== versionNumber;
|
||
if (isOutdated) clearCache();
|
||
|
||
const showUpdate = storedVersion < versionNumber;
|
||
if (showUpdate) setTimeout(showUpdateWindow, 6000);
|
||
|
||
function showUpdateWindow() {
|
||
const changelog = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Changelog";
|
||
const reddit = "https://www.reddit.com/r/FantasyMapGenerator";
|
||
const discord = "https://discordapp.com/invite/X7E84HU";
|
||
const patreon = "https://www.patreon.com/azgaar";
|
||
|
||
alertMessage.innerHTML = /* html */ `The Fantasy Map Generator is updated up to version <strong>${version}</strong>. This version is compatible with <a href="${changelog}" target="_blank">previous versions</a>, loaded <i>.map</i> files will be auto-updated.
|
||
${storedVersion ? "<span>Reload the page to fetch fresh code.</span>" : ""}
|
||
|
||
<ul>
|
||
<strong>Latest changes:</strong>
|
||
<li>Lock states, provinces, cultures, and religions from regeneration</li>
|
||
<li>Heightmap brushes: linear edit option</li>
|
||
<li>Data Charts screen</li>
|
||
<li>Сultures and religions can have multiple parents in hierarchy tree</li>
|
||
<li>Heightmap selection screen</li>
|
||
<li>Dialogs optimization for mobile</li>
|
||
<li>New heightmap template: Fractious</li>
|
||
<li>Template Editor: mask and invert tools</li>
|
||
</ul>
|
||
|
||
<p>Join our <a href="${discord}" target="_blank">Discord server</a> and <a href="${reddit}" target="_blank">Reddit community</a> to ask questions, share maps, discuss the Generator and Worlbuilding, report bugs and propose new features.</p>
|
||
<span><i>Thanks for all supporters on <a href="${patreon}" target="_blank">Patreon</a>!</i></span>`;
|
||
|
||
const buttons = {
|
||
Ok: function () {
|
||
$(this).dialog("close");
|
||
if (storedVersion) localStorage.clear();
|
||
localStorage.setItem("version", version);
|
||
}
|
||
};
|
||
|
||
if (storedVersion) {
|
||
buttons.Reload = () => {
|
||
localStorage.clear();
|
||
localStorage.setItem("version", version);
|
||
location.reload();
|
||
};
|
||
}
|
||
|
||
$("#alert").dialog({
|
||
resizable: false,
|
||
title: "Fantasy Map Generator update",
|
||
width: "28em",
|
||
position: {my: "center center-4em", at: "center", of: "svg"},
|
||
buttons
|
||
});
|
||
}
|
||
|
||
async function clearCache() {
|
||
const cacheNames = await caches.keys();
|
||
Promise.all(cacheNames.map(cacheName => caches.delete(cacheName)));
|
||
}
|
||
}
|