From 8907cd62ecfe459ccb00292f3e82386e45663e63 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Fri, 13 Sep 2024 15:38:47 +0200 Subject: [PATCH] fix: redraw population on change --- modules/dynamic/editors/cultures-editor.js | 1 + modules/dynamic/editors/religions-editor.js | 1 + modules/dynamic/editors/states-editor.js | 1 + modules/ui/provinces-editor.js | 1 + modules/ui/tools.js | 3 +++ modules/ui/zones-editor.js | 1 + 6 files changed, 8 insertions(+) diff --git a/modules/dynamic/editors/cultures-editor.js b/modules/dynamic/editors/cultures-editor.js index f4d15528..c6143dc2 100644 --- a/modules/dynamic/editors/cultures-editor.js +++ b/modules/dynamic/editors/cultures-editor.js @@ -485,6 +485,7 @@ function applyPopulationChange(oldRural, oldUrban, newRural, newUrban, culture) burgs.forEach(b => (b.population = population)); } + if (layerIsOn("togglePopulation")) drawPopulation(); refreshCulturesEditor(); } diff --git a/modules/dynamic/editors/religions-editor.js b/modules/dynamic/editors/religions-editor.js index 00bcbc5b..effa90cf 100644 --- a/modules/dynamic/editors/religions-editor.js +++ b/modules/dynamic/editors/religions-editor.js @@ -462,6 +462,7 @@ function changePopulation() { burgs.forEach(b => (b.population = population)); } + if (layerIsOn("togglePopulation")) drawPopulation(); refreshReligionsEditor(); } } diff --git a/modules/dynamic/editors/states-editor.js b/modules/dynamic/editors/states-editor.js index dbca9fff..9c4a0299 100644 --- a/modules/dynamic/editors/states-editor.js +++ b/modules/dynamic/editors/states-editor.js @@ -543,6 +543,7 @@ function changePopulation(stateId) { burgs.forEach(b => (b.population = population)); } + if (layerIsOn("togglePopulation")) drawPopulation(); refreshStatesEditor(); } } diff --git a/modules/ui/provinces-editor.js b/modules/ui/provinces-editor.js index dba4a741..9bd046a3 100644 --- a/modules/ui/provinces-editor.js +++ b/modules/ui/provinces-editor.js @@ -454,6 +454,7 @@ function editProvinces() { p.burgs.forEach(b => (pack.burgs[b].population = population)); } + if (layerIsOn("togglePopulation")) drawPopulation(); refreshProvincesEditor(); } } diff --git a/modules/ui/tools.js b/modules/ui/tools.js index b876cb11..0e753037 100644 --- a/modules/ui/tools.js +++ b/modules/ui/tools.js @@ -135,6 +135,7 @@ function regenerateRivers() { function recalculatePopulation() { rankCells(); + pack.burgs.forEach(b => { if (!b.i || b.removed || b.lock) return; const i = b.cell; @@ -144,6 +145,8 @@ function recalculatePopulation() { if (b.port) b.population = b.population * 1.3; // increase port population b.population = rn(b.population * gauss(2, 3, 0.6, 20, 3), 3); }); + + if (layerIsOn("togglePopulation")) drawPopulation(); } function regenerateStates() { diff --git a/modules/ui/zones-editor.js b/modules/ui/zones-editor.js index a7ac8835..0b5d069a 100644 --- a/modules/ui/zones-editor.js +++ b/modules/ui/zones-editor.js @@ -472,6 +472,7 @@ function editZones() { burgs.forEach(b => (b.population = population)); } + if (layerIsOn("togglePopulation")) drawPopulation(); zonesEditorAddLines(); } }