Select from the list or paste a Unicode character here:
@@ -7860,10 +7860,10 @@
-
+
-
+
@@ -7877,12 +7877,12 @@
-
-
+
+
-
+
diff --git a/main.js b/main.js
index 5cf0edc3..a7756124 100644
--- a/main.js
+++ b/main.js
@@ -694,6 +694,7 @@ async function generate(options) {
if (shouldRegenerateGrid(grid, precreatedSeed)) grid = precreatedGraph || generateGrid();
else delete grid.cells.h;
grid.cells.h = await HeightmapGenerator.generate(grid);
+ pack = {}; // reset pack
markFeatures();
markupGridOcean();
diff --git a/modules/cultures-generator.js b/modules/cultures-generator.js
index eeb09407..1c0e07a7 100644
--- a/modules/cultures-generator.js
+++ b/modules/cultures-generator.js
@@ -118,21 +118,23 @@ window.Cultures = (function () {
function selectCultures(culturesNumber) {
let def = getDefault(culturesNumber);
- if (culturesNumber === def.length) return def;
- if (def.every(d => d.odd === 1)) return def.splice(0, culturesNumber);
-
- const count = Math.min(culturesNumber, def.length);
-
const cultures = [];
+
pack.cultures?.forEach(function (culture) {
if (culture.lock) cultures.push(culture);
});
+
+ if (!cultures.length) {
+ if (culturesNumber === def.length) return def;
+ if (def.every(d => d.odd === 1)) return def.splice(0, culturesNumber);
+ }
- for (let culture, rnd, i = 0; cultures.length < count && i < 200; i++) {
+ for (let culture, rnd, i = 0; cultures.length < culturesNumber && def.length > 0;) {
do {
rnd = rand(def.length - 1);
culture = def[rnd];
- } while (!P(culture.odd));
+ i++;
+ } while (i < 200 && !P(culture.odd));
cultures.push(culture);
def.splice(rnd, 1);
}
diff --git a/modules/dynamic/editors/cultures-editor.js b/modules/dynamic/editors/cultures-editor.js
index 15fe1f32..5e66941d 100644
--- a/modules/dynamic/editors/cultures-editor.js
+++ b/modules/dynamic/editors/cultures-editor.js
@@ -590,16 +590,23 @@ function drawCultureCenters() {
}
function cultureCenterDrag() {
- const $el = d3.select(this);
const cultureId = +this.id.slice(13);
- d3.event.on("drag", () => {
+ const tr = parseTransform(this.getAttribute("transform"));
+ const x0 = +tr[0] - d3.event.x;
+ const y0 = +tr[1] - d3.event.y;
+
+ function handleDrag() {
const {x, y} = d3.event;
- $el.attr("cx", x).attr("cy", y);
+ this.setAttribute("transform", `translate(${x0 + x},${y0 + y})`);
const cell = findCell(x, y);
if (pack.cells.h[cell] < 20) return; // ignore dragging on water
+
pack.cultures[cultureId].center = cell;
recalculateCultures();
- });
+ }
+
+ const dragDebounced = debounce(handleDrag, 50);
+ d3.event.on("drag", dragDebounced);
}
function toggleLegend() {
diff --git a/modules/dynamic/editors/religions-editor.js b/modules/dynamic/editors/religions-editor.js
index 8a4abc5e..b6b2b5a0 100644
--- a/modules/dynamic/editors/religions-editor.js
+++ b/modules/dynamic/editors/religions-editor.js
@@ -3,11 +3,11 @@ addListeners();
export function open() {
closeDialogs("#religionsEditor, .stable");
+ if (!layerIsOn("toggleReligions")) toggleReligions();
if (layerIsOn("toggleStates")) toggleStates();
if (layerIsOn("toggleBiomes")) toggleBiomes();
- if (layerIsOn("toggleCultures")) toggleReligions();
+ if (layerIsOn("toggleCultures")) toggleCultures();
if (layerIsOn("toggleProvinces")) toggleProvinces();
- if (!layerIsOn("toggleReligions")) toggleReligions();
refreshReligionsEditor();
drawReligionCenters();
@@ -23,13 +23,15 @@ export function open() {
function insertEditorHtml() {
const editorHtml = /* html */ `
-
+
+
+
+
+
`;
@@ -109,6 +116,7 @@ function addListeners() {
byId("religionsManuallyCancel").on("click", () => exitReligionsManualAssignment());
byId("religionsAdd").on("click", enterAddReligionMode);
byId("religionsExport").on("click", downloadReligionsCsv);
+ byId("religionsRecalculate").on("click", () => recalculateReligions(true));
}
function refreshReligionsEditor() {
@@ -166,9 +174,10 @@ function religionsEditorAddLines() {
data-type=""
data-form=""
data-deity=""
+ data-expansion=""
data-expansionism=""
>
-