From b759d23df092210d03665d192a2e2a08bb7eeb54 Mon Sep 17 00:00:00 2001 From: Evolvedexperiment Date: Sun, 21 Jun 2020 17:38:23 +0000 Subject: [PATCH 1/9] Fix for last burg sometimes not appearing in elevation-profile --- modules/ui/elevation-profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/elevation-profile.js b/modules/ui/elevation-profile.js index c47c833c..995f0270 100644 --- a/modules/ui/elevation-profile.js +++ b/modules/ui/elevation-profile.js @@ -83,7 +83,7 @@ function showElevationProfile(data, routeLen, isRiver) { chartData.ma = Math.max(chartData.ma, chartData.height[i]); } - if (lastBurgIndex != 0 && lastBurgCell == chartData.cell[data.length-1] && lastBurgIndex < data.length) { + if (lastBurgIndex != 0 && lastBurgCell == chartData.cell[data.length-1] && lastBurgIndex < data.length-1) { chartData.burg[data.length-1] = chartData.burg[lastBurgIndex]; chartData.burg[lastBurgIndex] = 0; } From 783ea4a35f3ce98d0f2dacb8cfd0fac9804c2113 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sun, 21 Jun 2020 20:54:48 +0300 Subject: [PATCH 2/9] v1.4.30 --- modules/ui/options.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/ui/options.js b/modules/ui/options.js index 4d789173..f5f2d4b9 100644 --- a/modules/ui/options.js +++ b/modules/ui/options.js @@ -109,6 +109,8 @@ optionsContent.addEventListener("change", function(event) { if (id === "zoomExtentMin" || id === "zoomExtentMax") changeZoomExtent(value); else if (id === "optionsSeed") generateMapWithSeed(); else if (id === "uiSizeInput") changeUIsize(value); + else if (id === "yearInput") changeYear(); + else if (id === "eraInput") changeEra(); }); optionsContent.addEventListener("click", function(event) { @@ -408,6 +410,18 @@ function regenerateEra() { options.eraShort = options.era.split(" ").map(w => w[0].toUpperCase()).join(""); } +function changeYear() { + if (!yearInputthis.value) return; + if (isNaN(+yearInput.value)) {tip("Current year should be a number", false, "error"); return;} + options.year = +yearInput.value; +} + +function changeEra() { + if (!eraInput.value) return; + lock("era"); + options.era = eraInput.value; +} + // remove all saved data from LocalStorage and reload the page function restoreDefaultOptions() { localStorage.clear(); From 46b94c01ef3ab23143c02bd00bbe2f4a520584c8 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sun, 21 Jun 2020 23:36:36 +0300 Subject: [PATCH 3/9] v1.4.31 --- modules/ui/states-editor.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/modules/ui/states-editor.js b/modules/ui/states-editor.js index 5740b1ee..f4c123a7 100644 --- a/modules/ui/states-editor.js +++ b/modules/ui/states-editor.js @@ -454,15 +454,6 @@ function editStates() { }); armies.select("g#army"+state).remove(); - const military = pack.states[elSelected.dataset.state].military; - const regIndex = military.indexOf(regiment()); - if (regIndex === -1) return; - military.splice(regIndex, 1); - - const index = notes.findIndex(n => n.id === elSelected.id); - if (index != -1) notes.splice(index, 1); - elSelected.remove(); - const capital = pack.states[state].capital; pack.burgs[capital].capital = 0; pack.burgs[capital].state = 0; From 7fa056fe983b3fc1112825927df6e1bc8f9acdeb Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 22 Jun 2020 01:19:53 +0300 Subject: [PATCH 4/9] v1.4.32 --- modules/burgs-and-states.js | 12 +++++++----- modules/ui/options.js | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/burgs-and-states.js b/modules/burgs-and-states.js index b3083ac6..1fb2d9b5 100644 --- a/modules/burgs-and-states.js +++ b/modules/burgs-and-states.js @@ -599,14 +599,15 @@ // generate historical conflicts of each state const generateCampaigns = function() { - const wars = {"War":4, "Conflict":2, "Campaign":4, "Invasion":2, "Rebellion":2, "Conquest":2, "Intervention":1, "Expedition":1, "Crusade":1}; + const wars = {"War":6, "Conflict":2, "Campaign":4, "Invasion":2, "Rebellion":2, "Conquest":2, "Intervention":1, "Expedition":1, "Crusade":1}; pack.states.forEach(s => { if (!s.i || s.removed) return; const n = s.neighbors.length ? s.neighbors : [0]; s.campaigns = n.map(i => { const name = i && P(.8) ? pack.states[i].name : Names.getCultureShort(s.culture); - const start = gauss(options.year-100, 150, 1, options.year-6), end = start + gauss(4, 5, 1, options.year - start - 1); + const start = gauss(options.year-100, 150, 1, options.year-6); + const end = start + gauss(4, 5, 1, options.year - start - 1); return {name:getAdjective(name) + " " + rw(wars), start, end}; }).sort((a, b) => a.start - b.start); }); @@ -689,9 +690,10 @@ // start a war const war = [`${an}-${trimVowels(dn)}ian War`,`${an} declared a war on its rival ${dn}`]; - const start = options.year - gauss(2, 2, 0, 5); - states[attacker].campaigns.push({name: `${trimVowels(dn)}ian War`, start, end:options.year}); - states[defender].campaigns.push({name: `${trimVowels(an)}ian War`, start, end:options.year}); + const end = options.year; + const start = end - gauss(2, 2, 0, 5); + states[attacker].campaigns.push({name: `${trimVowels(dn)}ian War`, start, end}); + states[defender].campaigns.push({name: `${trimVowels(an)}ian War`, start, end}); // attacker vassals join the war ad.forEach((r, d) => {if (r === "Suzerain") { diff --git a/modules/ui/options.js b/modules/ui/options.js index f5f2d4b9..581800c0 100644 --- a/modules/ui/options.js +++ b/modules/ui/options.js @@ -399,7 +399,7 @@ function randomizeCultureSet() { function generateEra() { if (!stored("year")) yearInput.value = rand(100, 2000); // current year if (!stored("era")) eraInput.value = Names.getBaseShort(P(.7) ? 1 : rand(nameBases.length)) + " Era"; - options.year = yearInput.value; + options.year = +yearInput.value; options.era = eraInput.value; options.eraShort = options.era.split(" ").map(w => w[0].toUpperCase()).join(""); // short name for era } From 361b66a186c040230172658159afcefce1a1df09 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 22 Jun 2020 02:00:53 +0300 Subject: [PATCH 5/9] v1.4.33 --- index.html | 3 ++- main.js | 2 +- modules/ui/general.js | 3 ++- modules/ui/notes-editor.js | 10 ++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index eaf4bf58..d72ca539 100644 --- a/index.html +++ b/index.html @@ -3212,11 +3212,12 @@
- Legend:
+ Note:
+ diff --git a/main.js b/main.js index 5265820a..cd76e80b 100644 --- a/main.js +++ b/main.js @@ -117,7 +117,7 @@ let scale = 1, viewX = 0, viewY = 0; const zoom = d3.zoom().scaleExtent([1, 20]).on("zoom", zoomed); // default options -let options = {}; // options object +let options = {pinNotes:false}; // options object let mapCoordinates = {}; // map coordinates on globe options.winds = [225, 45, 225, 315, 135, 315]; // default wind directions diff --git a/modules/ui/general.js b/modules/ui/general.js index 3546f018..7689b1b5 100644 --- a/modules/ui/general.js +++ b/modules/ui/general.js @@ -61,6 +61,7 @@ function moved() { // show note box on hover (if any) function showNotes(e, i) { + if (notesEditor.offsetParent) return; let id = e.target.id || e.target.parentNode.id || e.target.parentNode.parentNode.id; if (e.target.parentNode.parentNode.id === "burgLabels") id = "burg" + e.target.dataset.id; else if (e.target.parentNode.parentNode.id === "burgIcons") id = "burg" + e.target.dataset.id; @@ -70,7 +71,7 @@ function showNotes(e, i) { document.getElementById("notes").style.display = "block"; document.getElementById("notesHeader").innerHTML = note.name; document.getElementById("notesBody").innerHTML = note.legend; - } else { + } else if (!options.pinNotes) { document.getElementById("notes").style.display = "none"; document.getElementById("notesHeader").innerHTML = ""; document.getElementById("notesBody").innerHTML = ""; diff --git a/modules/ui/notes-editor.js b/modules/ui/notes-editor.js index cc49d536..939c97ea 100644 --- a/modules/ui/notes-editor.js +++ b/modules/ui/notes-editor.js @@ -18,6 +18,7 @@ function editNotes(id, name) { select.value = id; notesName.value = note.name; notesText.value = note.legend; + showNote(note); } else { const value = "There are no added notes. Click on element (e.g. label) and add a free text note"; document.getElementById("notesText").value = value; @@ -37,12 +38,19 @@ function editNotes(id, name) { document.getElementById("notesSelect").addEventListener("change", changeObject); document.getElementById("notesName").addEventListener("input", changeName); document.getElementById("notesText").addEventListener("input", changeText); + document.getElementById("notesPin").addEventListener("click", () => options.pinNotes = !options.pinNotes); document.getElementById("notesFocus").addEventListener("click", validateHighlightElement); document.getElementById("notesDownload").addEventListener("click", downloadLegends); document.getElementById("notesUpload").addEventListener("click", () => legendsToLoad.click()); document.getElementById("legendsToLoad").addEventListener("change", function() {uploadFile(this, uploadLegends)}); document.getElementById("notesRemove").addEventListener("click", triggerNotesRemove); + function showNote(note) { + document.getElementById("notes").style.display = "block"; + document.getElementById("notesHeader").innerHTML = note.name; + document.getElementById("notesBody").innerHTML = note.legend; + } + function changeObject() { const note = notes.find(note => note.id === this.value); if (!note) return; @@ -55,6 +63,7 @@ function editNotes(id, name) { const note = notes.find(note => note.id === id); if (!note) return; note.name = this.value; + showNote(note); } function changeText() { @@ -62,6 +71,7 @@ function editNotes(id, name) { const note = notes.find(note => note.id === id); if (!note) return; note.legend = this.value; + showNote(note); } function validateHighlightElement() { From a3f75c7f2729d870a7e6ceaea46f141143fb4d79 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 22 Jun 2020 02:07:10 +0300 Subject: [PATCH 6/9] v1.4.34 --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index d72ca539..e66b78d3 100644 --- a/index.html +++ b/index.html @@ -2538,7 +2538,7 @@ Attackers
-
+
@@ -2551,7 +2551,7 @@ Defenders
-
+
From 7224addbc605879b2085c89cf4f0f2595c756448 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 22 Jun 2020 02:22:55 +0300 Subject: [PATCH 7/9] v1.4.35 --- modules/ui/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/options.js b/modules/ui/options.js index 581800c0..72e39b21 100644 --- a/modules/ui/options.js +++ b/modules/ui/options.js @@ -411,7 +411,7 @@ function regenerateEra() { } function changeYear() { - if (!yearInputthis.value) return; + if (!yearInput.value) return; if (isNaN(+yearInput.value)) {tip("Current year should be a number", false, "error"); return;} options.year = +yearInput.value; } From 300a05b75db3516f918d715f9bb56c200302a81a Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 23 Jun 2020 02:29:39 +0300 Subject: [PATCH 8/9] v1.4.36 --- index.css | 41 +++++++- index.html | 9 +- libs/pell.js | 163 ++++++++++++++++++++++++++++++++ libs/publicstorage.js | 188 ------------------------------------- modules/save-and-load.js | 7 +- modules/ui/notes-editor.js | 31 +++--- modules/utils.js | 4 +- 7 files changed, 231 insertions(+), 212 deletions(-) create mode 100644 libs/pell.js delete mode 100644 libs/publicstorage.js diff --git a/index.css b/index.css index 57d0df7f..3b577177 100644 --- a/index.css +++ b/index.css @@ -2089,9 +2089,10 @@ svg.button { padding: 1.2em; border: solid 1px #000; font-size: 1.2em; + z-index: 1000; } -#promptTest { +#promptText { padding: 0 0 .6em 0; font-weight: bold; font-family: sans-serif; @@ -2125,6 +2126,44 @@ svg.button { stroke-width: 0; } +.pell { + border: 1px solid hsla(0,0%,4%,.1) +} + +.pell,.pell-content { + box-sizing: border-box +} + +.pell-content { + height: 14em; + outline: 0; + overflow-y: auto; + padding: .6em; + font-family: Copperplate, monospace; + background-color: #fff; + border: 1px solid #dedede; +} + +.pell-actionbar { + background-color: #fff; + border: 1px solid #dedede; + border-bottom: 0; +} + +.pell-button { + background-color: transparent; + border: none; + cursor: pointer; + height: 30px; + outline: 0; + width: 30px; + vertical-align: bottom +} + +.pell-button-selected { + background-color: #f0f0f0 +} + #debug { font-size: 1px; opacity: .8; diff --git a/index.html b/index.html index e66b78d3..f63d3c73 100644 --- a/index.html +++ b/index.html @@ -3211,10 +3211,7 @@ Object name:
-
- Note:
- -
+
@@ -3673,7 +3670,7 @@ @@ -3209,7 +3209,7 @@ Select object: Object name: - +
diff --git a/modules/save-and-load.js b/modules/save-and-load.js index 66a4fa51..0ef3ad0c 100644 --- a/modules/save-and-load.js +++ b/modules/save-and-load.js @@ -526,7 +526,7 @@ function uploadMap(file, callback) { } else { load = true; message = `The map version (${mapVersion}) does not match the Generator version (${version}). -
The map will be auto-updated. In case of issues please keep using an ${archive} of the Generator`; +
Click OK to get map auto-updated. In case of issues please keep using an ${archive} of the Generator`; } alertMessage.innerHTML = message; $("#alert").dialog({title: "Version conflict", width: "38em", buttons: {