From 57f1bd9695c5e4dd3efcc7ed40e04544c3a6d5e4 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 14 Sep 2019 14:17:26 +0300 Subject: [PATCH] v.1.0.34 --- index.css | 3 +-- index.html | 1 + main.js | 22 ++++++++++++---------- modules/ui/tools.js | 8 +++++++- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/index.css b/index.css index b5b95ea5..ad272338 100644 --- a/index.css +++ b/index.css @@ -1769,8 +1769,7 @@ div#notes { background: rgba(255, 250, 228, 0.7); box-shadow: 2px 2px 5px -3px #3a2804; white-space: pre-line; - -moz-user-select: none; - user-select: none; + pointer-events: none; } div#notesHeader { diff --git a/index.html b/index.html index 6e404474..0c605d8a 100644 --- a/index.html +++ b/index.html @@ -1746,6 +1746,7 @@ +
diff --git a/main.js b/main.js index d95f94d1..f469ea95 100644 --- a/main.js +++ b/main.js @@ -1192,13 +1192,13 @@ function addZone() { } // add some markers as an example -function addMarkers() { +function addMarkers(number = 1) { console.time("addMarkers"); const cells = pack.cells; void function addVolcanoes() { let mounts = Array.from(cells.i).filter(i => cells.h[i] > 70).sort((a, b) => cells.h[b] - cells.h[a]); - let count = mounts.length < 10 ? 0 : Math.ceil(mounts.length / 300); + let count = mounts.length < 10 ? 0 : Math.ceil(mounts.length / 300 * number); if (count) addMarker("volcano", "🌋", 52, 52, 17.5); while (count) { @@ -1219,7 +1219,7 @@ function addMarkers() { void function addHotSprings() { let springs = Array.from(cells.i).filter(i => cells.h[i] > 50).sort((a, b) => cells.h[b]-cells.h[a]); - let count = springs.length < 30 ? 0 : Math.ceil(springs.length / 1000); + let count = springs.length < 30 ? 0 : Math.ceil(springs.length / 1000 * number); if (count) addMarker("hot_springs", "♨", 50, 50, 19.5); while (count) { @@ -1240,7 +1240,7 @@ function addMarkers() { void function addMines() { let hills = Array.from(cells.i).filter(i => cells.h[i] > 47 && cells.burg[i]); - let count = !hills.length ? 0 : Math.ceil(hills.length / 7); + let count = !hills.length ? 0 : Math.ceil(hills.length / 7 * number); if (!count) return; addMarker("mine", "⚒", 50, 50, 20); @@ -1272,7 +1272,7 @@ function addMarkers() { .filter(i => cells.burg[i] && cells.h[i] >= 20 && cells.r[i] && cells.fl[i] > meanFlux && cells.road[i] > meanRoad) .sort((a, b) => (cells.road[b] + cells.fl[b] / 10) - (cells.road[a] + cells.fl[a] / 10)); - let count = !bridges.length ? 0 : Math.ceil(bridges.length / 12); + let count = !bridges.length ? 0 : Math.ceil(bridges.length / 12 * number); if (count) addMarker("bridge", "🌉", 50, 50, 16.5); while (count) { @@ -1296,14 +1296,14 @@ function addMarkers() { const maxRoad = d3.max(cells.road) * .9; let taverns = Array.from(cells.i).filter(i => cells.crossroad[i] && cells.h[i] >= 20 && cells.road[i] > maxRoad); if (!taverns.length) return; + const count = Math.ceil(4 * number); addMarker("inn", "🍻", 50, 50, 17.5); const color = ["Dark", "Light", "Bright", "Golden", "White", "Black", "Red", "Pink", "Purple", "Blue", "Green", "Yellow", "Amber", "Orange", "Brown", "Grey"]; const animal = ["Antelope", "Ape", "Badger", "Bear", "Beaver", "Bison", "Boar", "Buffalo", "Cat", "Crane", "Crocodile", "Crow", "Deer", "Dog", "Eagle", "Elk", "Fox", "Goat", "Goose", "Hare", "Hawk", "Heron", "Horse", "Hyena", "Ibis", "Jackal", "Jaguar", "Lark", "Leopard", "Lion", "Mantis", "Marten", "Moose", "Mule", "Narwhal", "Owl", "Panther", "Rat", "Raven", "Rook", "Scorpion", "Shark", "Sheep", "Snake", "Spider", "Swan", "Tiger", "Turtle", "Wolf", "Wolverine", "Camel", "Falcon", "Hound", "Ox"]; const adj = ["New", "Good", "High", "Old", "Great", "Big", "Major", "Happy", "Main", "Huge", "Far", "Beautiful", "Fair", "Prime", "Ancient", "Golden", "Proud", "Lucky", "Fat", "Honest", "Giant", "Distant", "Friendly", "Loud", "Hungry", "Magical", "Superior", "Peaceful", "Frozen", "Divine", "Favorable", "Brave", "Sunny", "Flying"]; - - for (let i=0; i < taverns.length && i < 4; i++) { + for (let i=0; i < taverns.length && i < count; i++) { const cell = taverns.splice(Math.floor(Math.random() * taverns.length), 1); const x = cells.p[cell][0], y = cells.p[cell][1]; const id = getNextId("markerElement"); @@ -1323,8 +1323,9 @@ function addMarkers() { const lands = cells.i.filter(i => cells.harbor[i] > 6 && cells.c[i].some(c => cells.h[c] < 20 && cells.road[c])); const lighthouses = Array.from(lands).map(i => [i, cells.v[i][cells.c[i].findIndex(c => cells.h[c] < 20 && cells.road[c])]]); if (lighthouses.length) addMarker("lighthouse", "🚨", 50, 50, 16); + const count = Math.ceil(4 * number); - for (let i=0; i < lighthouses.length && i < 4; i++) { + for (let i=0; i < lighthouses.length && i < count; i++) { const cell = lighthouses[i][0], vertex = lighthouses[i][1]; const x = pack.vertices.p[vertex][0], y = pack.vertices.p[vertex][1]; const id = getNextId("markerElement"); @@ -1342,8 +1343,9 @@ function addMarkers() { void function addWaterfalls() { const waterfalls = cells.i.filter(i => cells.r[i] && cells.h[i] > 70); if (waterfalls.length) addMarker("waterfall", "⟱", 50, 54, 16.5); + const count = Math.ceil(3 * number); - for (let i=0; i < waterfalls.length && i < 3; i++) { + for (let i=0; i < waterfalls.length && i < count; i++) { const cell = waterfalls[i]; const x = cells.p[cell][0], y = cells.p[cell][1]; const id = getNextId("markerElement"); @@ -1360,7 +1362,7 @@ function addMarkers() { void function addBattlefields() { let battlefields = Array.from(cells.i).filter(i => cells.pop[i] > 2 && cells.h[i] < 50 && cells.h[i] > 25); - let count = battlefields.length < 100 ? 0 : Math.ceil(battlefields.length / 500); + let count = battlefields.length < 100 ? 0 : Math.ceil(battlefields.length / 500 * number); const era = Names.getCulture(0, 3, 7, "", 0) + " Era"; if (count) addMarker("battlefield", "⚔", 50, 50, 20); diff --git a/modules/ui/tools.js b/modules/ui/tools.js index 20841f49..ec7feeb2 100644 --- a/modules/ui/tools.js +++ b/modules/ui/tools.js @@ -59,7 +59,8 @@ function processFeatureRegeneration(button) { if (button === "regenerateBurgs") regenerateBurgs(); else if (button === "regenerateStates") regenerateStates(); else if (button === "regenerateProvinces") regenerateProvinces(); else - if (button === "regenerateReligions") regenerateReligions(); + if (button === "regenerateReligions") regenerateReligions(); else + if (button === "regenerateMarkers") regenerateMarkers(); } function regenerateRivers() { @@ -199,6 +200,11 @@ function regenerateReligions() { if (!layerIsOn("toggleReligions")) toggleReligions(); else drawReligions(); } +function regenerateMarkers() { + markers.selectAll("use").remove(); + addMarkers(gauss(1, .5, .3, 5, 2)); +} + function unpressClickToAddButton() { addFeature.querySelectorAll("button.pressed").forEach(b => b.classList.remove("pressed")); restoreDefaultEvents();