From 5ec59da7b764db24752b8bccc8f86e0abef26009 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 21 Nov 2023 04:39:54 +0400 Subject: [PATCH 1/5] fix: don't redraw removed scaleBar --- index.html | 8 ++++---- modules/io/export.js | 15 ++++++++------- modules/ui/3d.js | 2 +- modules/ui/measurers.js | 2 +- modules/ui/submap.js | 26 ++++++++++++++++++++++---- versioning.js | 2 +- 6 files changed, 37 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index 80ce2360..1cf490c1 100644 --- a/index.html +++ b/index.html @@ -7942,7 +7942,7 @@ - + @@ -7982,8 +7982,8 @@ - - + + @@ -7991,7 +7991,7 @@ - + diff --git a/modules/io/export.js b/modules/io/export.js index 648c29e5..7a6c65a7 100644 --- a/modules/io/export.js +++ b/modules/io/export.js @@ -138,16 +138,15 @@ async function exportToPngTiles() { } // parse map svg to object url -async function getMapURL(type, options = {}) { +async function getMapURL(type, options) { const { debug = false, - globe = false, noLabels = false, noWater = false, noScaleBar = false, noIce = false, fullMap = false - } = options; + } = options || {}; const cloneEl = document.getElementById("map").cloneNode(true); // clone svg cloneEl.id = "fantasyMap"; @@ -160,7 +159,6 @@ async function getMapURL(type, options = {}) { const isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1; if (isFirefox && type === "mesh") clone.select("#oceanPattern")?.remove(); - if (globe) clone.select("#scaleBar")?.remove(); if (noLabels) { clone.select("#labels #states")?.remove(); clone.select("#labels #burgLabels")?.remove(); @@ -171,14 +169,17 @@ async function getMapURL(type, options = {}) { clone.select("#oceanPattern").attr("opacity", 0); } if (noIce) clone.select("#ice")?.remove(); - if (noScaleBar) clone.select("#scaleBar")?.remove(); if (fullMap) { // reset transform to show the whole map clone.attr("width", graphWidth).attr("height", graphHeight); clone.select("#viewbox").attr("transform", null); - drawScaleBar(clone.select("#scaleBar"), 1); - fitScaleBar(clone.select("#scaleBar"), graphWidth, graphHeight); + + if (!noScaleBar) { + drawScaleBar(clone.select("#scaleBar"), 1); + fitScaleBar(clone.select("#scaleBar"), graphWidth, graphHeight); + } } + if (noScaleBar) clone.select("#scaleBar")?.remove(); if (type === "svg") removeUnusedElements(clone); if (customization && type === "mesh") updateMeshCells(clone); diff --git a/modules/ui/3d.js b/modules/ui/3d.js index 2c021116..81356130 100644 --- a/modules/ui/3d.js +++ b/modules/ui/3d.js @@ -623,7 +623,7 @@ window.ThreeD = (function () { material.map = texture; if (addMesh) addGlobe3dMesh(); }; - img2.src = await getMapURL("mesh", {globe: true, fullMap: true}); + img2.src = await getMapURL("mesh", {noScaleBar: true, fullMap: true}); } function addGlobe3dMesh() { diff --git a/modules/ui/measurers.js b/modules/ui/measurers.js index c9a1aff9..eedeaffb 100644 --- a/modules/ui/measurers.js +++ b/modules/ui/measurers.js @@ -535,7 +535,7 @@ class Planimeter extends Measurer { // Scale bar function drawScaleBar(scaleBar, scaleLevel) { - if (scaleBar.style("display") === "none") return; // no need to re-draw hidden element + if (!scaleBar.size() || scaleBar.style("display") === "none") return; scaleBar.selectAll("*").remove(); // fully redraw every time const distanceScale = +distanceScaleInput.value; diff --git a/modules/ui/submap.js b/modules/ui/submap.js index 737560c3..2a476faa 100644 --- a/modules/ui/submap.js +++ b/modules/ui/submap.js @@ -136,7 +136,14 @@ window.UISubmap = (function () { } async function loadPreview($container, w, h) { - const url = await getMapURL("png", {globe: false, noWater: true, fullMap: true, noLabels: true, noScaleBar: true, noIce: true}); + const url = await getMapURL("png", { + globe: false, + noWater: true, + fullMap: true, + noLabels: true, + noScaleBar: true, + noIce: true + }); const canvas = document.createElement("canvas"); const ctx = canvas.getContext("2d"); @@ -173,7 +180,11 @@ window.UISubmap = (function () { const {angle, shiftX, shiftY, ratio, mirrorH, mirrorV} = getTransformInput(); const [cx, cy] = [graphWidth / 2, graphHeight / 2]; - const rot = alfa => (x, y) => [(x - cx) * Math.cos(alfa) - (y - cy) * Math.sin(alfa) + cx, (y - cy) * Math.cos(alfa) + (x - cx) * Math.sin(alfa) + cy]; + const rot = alfa => (x, y) => + [ + (x - cx) * Math.cos(alfa) - (y - cy) * Math.sin(alfa) + cx, + (y - cy) * Math.cos(alfa) + (x - cx) * Math.sin(alfa) + cy + ]; const shift = (dx, dy) => (x, y) => [x + dx, y + dy]; const scale = r => (x, y) => [(x - cx) * r + cx, (y - cy) * r + cy]; const flipH = (x, y) => [-x + 2 * cx, y]; @@ -185,7 +196,11 @@ window.UISubmap = (function () { let inverse = id; if (angle) [projection, inverse] = [rot(angle), rot(-angle)]; - if (ratio) [projection, inverse] = [app(scale(Math.pow(1.1, ratio)), projection), app(inverse, scale(Math.pow(1.1, -ratio)))]; + if (ratio) + [projection, inverse] = [ + app(scale(Math.pow(1.1, ratio)), projection), + app(inverse, scale(Math.pow(1.1, -ratio))) + ]; if (mirrorH) [projection, inverse] = [app(flipH, projection), app(inverse, flipH)]; if (mirrorV) [projection, inverse] = [app(flipV, projection), app(inverse, flipV)]; if (shiftX || shiftY) { @@ -244,7 +259,10 @@ window.UISubmap = (function () { // fix scale distanceScaleInput.value = distanceScaleOutput.value = rn((distanceScale = distanceScaleOutput.value / scale), 2); - populationRateInput.value = populationRateOutput.value = rn((populationRate = populationRateOutput.value / scale), 2); + populationRateInput.value = populationRateOutput.value = rn( + (populationRate = populationRateOutput.value / scale), + 2 + ); customization = 0; startResample(options); }, 1000); diff --git a/versioning.js b/versioning.js index 7ad37a21..cdcb00b6 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.94.02"; // generator version, update each time +const version = "1.94.03"; // generator version, update each time { document.title += " v" + version; From 3353789146fd9d9a05dc3dc0cd606a2004501a35 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 22 Nov 2023 00:23:01 +0400 Subject: [PATCH 2/5] fix: dropbox sharing maps --- index.html | 4 ++-- modules/io/cloud.js | 4 ++-- modules/io/load.js | 23 ++++++++++------------- versioning.js | 2 +- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index 1cf490c1..ff9c45e2 100644 --- a/index.html +++ b/index.html @@ -7989,8 +7989,8 @@ - - + + diff --git a/modules/io/cloud.js b/modules/io/cloud.js index 01338c0b..4e174194 100644 --- a/modules/io/cloud.js +++ b/modules/io/cloud.js @@ -118,9 +118,9 @@ window.Cloud = (function () { }, async getLink(path) { - // return existitng shared link + // return existing shared link const sharedLinks = await this.call("sharingListSharedLinks", {path}); - if (sharedLinks.result.links.length) return resp.result.links[0].url; + if (sharedLinks.result.links.length) return sharedLinks.result.links[0].url; // create new shared link const settings = { diff --git a/modules/io/load.js b/modules/io/load.js index f2154872..d3c97efe 100644 --- a/modules/io/load.js +++ b/modules/io/load.js @@ -21,22 +21,19 @@ async function createSharableDropboxLink() { const mapFile = document.querySelector("#loadFromDropbox select").value; const sharableLink = document.getElementById("sharableLink"); const sharableLinkContainer = document.getElementById("sharableLinkContainer"); - let url; + try { - url = await Cloud.providers.dropbox.getLink(mapFile); - } catch { + const previewLink = await Cloud.providers.dropbox.getLink(mapFile); + const directLink = previewLink.replace("www.dropbox.com", "dl.dropboxusercontent.com"); // DL allows CORS + const finalLink = `${location.origin}${location.pathname}?maplink=${directLink}`; + + sharableLink.innerText = finalLink.slice(0, 45) + "..."; + sharableLink.setAttribute("href", finalLink); + sharableLinkContainer.style.display = "block"; + } catch (error) { + ERROR && console.error(error); return tip("Dropbox API error. Can not create link.", true, "error", 2000); } - - const fmg = window.location.href.split("?")[0]; - const reallink = `${fmg}?maplink=${url}`; - // voodoo magic required by the yellow god of CORS - const link = reallink.replace("www.dropbox.com/s/", "dl.dropboxusercontent.com/1/view/"); - const shortLink = link.slice(0, 50) + "..."; - - sharableLinkContainer.style.display = "block"; - sharableLink.innerText = shortLink; - sharableLink.setAttribute("href", link); } function loadMapPrompt(blob) { diff --git a/versioning.js b/versioning.js index cdcb00b6..e6d0c034 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.94.03"; // generator version, update each time +const version = "1.94.04"; // generator version, update each time { document.title += " v" + version; From c3cfffec87245bddd2e016b916c6c42bfb20bc6b Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 22 Nov 2023 20:35:55 +0400 Subject: [PATCH 3/5] fix #1020: recreate texture if it's missing --- index.html | 2 +- modules/io/load.js | 9 +++++++++ versioning.js | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index ff9c45e2..f9756635 100644 --- a/index.html +++ b/index.html @@ -7989,7 +7989,7 @@ - + diff --git a/modules/io/load.js b/modules/io/load.js index d3c97efe..282cf009 100644 --- a/modules/io/load.js +++ b/modules/io/load.js @@ -346,6 +346,15 @@ async function parseLoadedData(data) { burgLabels = labels.select("#burgLabels"); })(); + void (function addMissingElements() { + if (!texture.size()) { + texture = viewbox + .insert("g", "#landmass") + .attr("id", "texture") + .attr("data-href", "./images/textures/plaster.jpg"); + } + })(); + void (function parseGridData() { grid = JSON.parse(data[6]); diff --git a/versioning.js b/versioning.js index e6d0c034..ba1646f2 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.94.04"; // generator version, update each time +const version = "1.94.05"; // generator version, update each time { document.title += " v" + version; From 9991b4a3c0ac26d1dfa057b7c42ae40e2e13686a Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 25 Nov 2023 03:07:38 +0400 Subject: [PATCH 4/5] fix: execute focus on after fitToScreen --- index.html | 2 +- main.js | 2 +- versioning.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index f9756635..1c6917f9 100644 --- a/index.html +++ b/index.html @@ -7947,7 +7947,7 @@ - + diff --git a/main.js b/main.js index 78270510..945fb0bd 100644 --- a/main.js +++ b/main.js @@ -306,9 +306,9 @@ async function checkLoadParameters() { async function generateMapOnLoad() { await applyStyleOnLoad(); // apply previously selected default or custom style await generate(); // generate map - focusOn(); // based on searchParams focus on point, cell or burg from MFCG applyPreset(); // apply saved layers preset fitMapToScreen(); + focusOn(); // based on searchParams focus on point, cell or burg from MFCG } // focus on coordinates, cell or burg provided in searchParams diff --git a/versioning.js b/versioning.js index ba1646f2..69e65f3c 100644 --- a/versioning.js +++ b/versioning.js @@ -1,7 +1,7 @@ "use strict"; // version and caching control -const version = "1.94.05"; // generator version, update each time +const version = "1.94.06"; // generator version, update each time { document.title += " v" + version; From 537abf122371198872720862c1a7f5f66109b0e4 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 25 Nov 2023 15:04:29 +0400 Subject: [PATCH 5/5] feat: supporters update --- index.html | 2 +- modules/dynamic/supporters.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 1c6917f9..31f3b8df 100644 --- a/index.html +++ b/index.html @@ -7946,7 +7946,7 @@ - + diff --git a/modules/dynamic/supporters.js b/modules/dynamic/supporters.js index f65caf62..2c608cb4 100644 --- a/modules/dynamic/supporters.js +++ b/modules/dynamic/supporters.js @@ -541,4 +541,9 @@ Igor John Todd burning.rosary Shane Roppel -Hank Agrippa`; +Hank Agrippa +Noah Morris +Phil Karecki +Matthew Jarocki +Lucius Licinius Lucullus +Andrew Haney`;