diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index b254d0ad..acedeb18 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -14,8 +14,8 @@
# Versioning
-
diff --git a/main.js b/main.js
index 83a7ef50..ff0b2b47 100644
--- a/main.js
+++ b/main.js
@@ -684,7 +684,7 @@ async function generate(options) {
buttons: {
"Clear data": function () {
localStorage.clear();
- localStorage.setItem("version", version);
+ localStorage.setItem("version", VERSION);
},
Regenerate: function () {
regenerateMap("generation error");
diff --git a/modules/dynamic/export-json.js b/modules/dynamic/export-json.js
index df0d6815..231c7a73 100644
--- a/modules/dynamic/export-json.js
+++ b/modules/dynamic/export-json.js
@@ -72,7 +72,7 @@ function getGridDataJson() {
function getMapInfo() {
return {
- version,
+ version: VERSION,
description: "Azgaar's Fantasy Map Generator output: azgaar.github.io/Fantasy-map-generator",
exportedAt: new Date().toISOString(),
mapName: mapName.value,
diff --git a/modules/io/load.js b/modules/io/load.js
index 2c9633ed..f8e23813 100644
--- a/modules/io/load.js
+++ b/modules/io/load.js
@@ -113,10 +113,10 @@ function uploadMap(file, callback) {
const [mapData, mapVersion] = await parseLoadedResult(result);
const isInvalid = !mapData || !isValidVersion(mapVersion) || mapData.length < 26 || !mapData[5];
- const isUpdated = compareVersions(mapVersion, version).isEqual;
+ const isUpdated = compareVersions(mapVersion, VERSION).isEqual;
const isAncient = compareVersions(mapVersion, "0.7.0").isOlder;
- const isNewer = compareVersions(mapVersion, version).isNewer;
- const isOutdated = compareVersions(mapVersion, version).isOlder;
+ const isNewer = compareVersions(mapVersion, VERSION).isNewer;
+ const isOutdated = compareVersions(mapVersion, VERSION).isOlder;
if (isInvalid) return showUploadMessage("invalid", mapData, mapVersion);
if (isUpdated) return showUploadMessage("updated", mapData, mapVersion);
@@ -181,7 +181,7 @@ function showUploadMessage(type, mapData, mapVersion) {
message = `The map version you are trying to load (${mapVersion}) is newer than the current version.
Please load the file in the appropriate version`;
title = "Newer file";
} else if (type === "outdated") {
- INFO && console.info(`Loading map. Auto-updating from ${mapVersion} to ${version}`);
+ INFO && console.info(`Loading map. Auto-updating from ${mapVersion} to ${VERSION}`);
parseLoadedData(mapData, mapVersion);
return;
}
@@ -707,7 +707,7 @@ async function parseLoadedData(data, mapVersion) {
ERROR && console.error(error);
clearMainTip();
- alertMessage.innerHTML = /* html */ `An error is occured on map loading. Select a different file to load,
generate a new random map or cancel the loading.
Map version: ${mapVersion}. Generator version: ${version}.
+ alertMessage.innerHTML = /* html */ `An error is occured on map loading. Select a different file to load,
generate a new random map or cancel the loading.
Map version: ${mapVersion}. Generator version: ${VERSION}.
${parseError(error)}
`; $("#alert").dialog({ diff --git a/modules/io/save.js b/modules/io/save.js index 73e6845f..83c352d3 100644 --- a/modules/io/save.js +++ b/modules/io/save.js @@ -41,7 +41,7 @@ function prepareMapData() { const date = new Date(); const dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); const license = "File can be loaded in azgaar.github.io/Fantasy-Map-Generator"; - const params = [version, license, dateString, seed, graphWidth, graphHeight, mapId].join("|"); + const params = [VERSION, license, dateString, seed, graphWidth, graphHeight, mapId].join("|"); const settings = [ distanceUnitInput.value, distanceScale, diff --git a/modules/ui/stylePresets.js b/modules/ui/stylePresets.js index 4ce4b2a5..ff3ae365 100644 --- a/modules/ui/stylePresets.js +++ b/modules/ui/stylePresets.js @@ -64,7 +64,7 @@ async function getStylePreset(desiredPreset) { async function fetchSystemPreset(preset) { try { - const res = await fetch(`./styles/${preset}.json?v=${version}`); + const res = await fetch(`./styles/${preset}.json?v=${VERSION}`); return await res.json(); } catch (err) { throw new Error("Cannot fetch style preset", preset); diff --git a/modules/ui/submap.js b/modules/ui/submap.js index d5e36fcc..7b9dab06 100644 --- a/modules/ui/submap.js +++ b/modules/ui/submap.js @@ -159,18 +159,6 @@ window.UISubmap = (function () { return canvas; } - // currently unused alternative to PNG version - async function loadPreviewSVG($container, w, h) { - $container.innerHTML = /*html*/ ` - - `; - return byId("submapPreviewSVG"); - } - // Resample the whole map to different cell resolution or shape const resampleCurrentMap = debounce(function () { WARN && console.warn("Resampling current map"); diff --git a/versioning.js b/versioning.js index 50110b67..3ddbaf12 100644 --- a/versioning.js +++ b/versioning.js @@ -1,15 +1,26 @@ "use strict"; - -// version and caching control -const version = "1.100.00"; // generator version, update each time +/** + * Version Control Guidelines + * -------------------------- + * We use Semantic Versioning: major.minor.patch. Refer to https://semver.org + * Our .map file format is considered the public API. + * + * Update the version MANUALLY on each merge to main: + * 1. MAJOR version: Incompatible changes that break existing maps + * 2. MINOR version: Backwards-compatible changes requiring old .map files to be updated + * 3. PATCH version: Backwards-compatible bug fixes or features not affecting .map file format + * + * Example: 1.102.0 -> Major version 1, Minor version 102, Patch version 0 + */ +const VERSION = "1.100.00"; { - document.title += " v" + version; + document.title += " v" + VERSION; const loadingScreenVersion = document.getElementById("versionText"); - if (loadingScreenVersion) loadingScreenVersion.innerText = `v${version}`; + if (loadingScreenVersion) loadingScreenVersion.innerText = `v${VERSION}`; const storedVersion = localStorage.getItem("version"); - if (compareVersions(storedVersion, version).isOlder) setTimeout(showUpdateWindow, 6000); + if (compareVersions(storedVersion, VERSION).isOlder) setTimeout(showUpdateWindow, 6000); function showUpdateWindow() { const changelog = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Changelog"; @@ -17,7 +28,7 @@ const version = "1.100.00"; // generator version, update each time 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 ${version}. This version is compatible with previous versions, loaded save files will be auto-updated. + alertMessage.innerHTML = /* html */ `The Fantasy Map Generator is updated up to version ${VERSION}. This version is compatible with previous versions, loaded save files will be auto-updated. ${storedVersion ? "Reload the page to fetch fresh code." : ""}