diff --git a/index.html b/index.html
index 635a1f376..f3774fdac 100644
--- a/index.html
+++ b/index.html
@@ -1861,6 +1861,7 @@
+
@@ -3456,7 +3457,7 @@
Rate
War Alert
-
+
@@ -3486,7 +3487,7 @@
Name
Total
-
+
diff --git a/modules/burgs-and-states.js b/modules/burgs-and-states.js
index 1d9406530..4cc36e2d4 100644
--- a/modules/burgs-and-states.js
+++ b/modules/burgs-and-states.js
@@ -353,6 +353,32 @@
console.timeEnd("normalizeStates");
}
+ // Resets the cultures of all burgs and states to their
+ // cell or center cell's (respectively) culture.
+ const updateCultures = function () {
+ console.time('updateCulturesForBurgsAndStates');
+
+ // Assign the culture associated with the burgs cell.
+ pack.burgs = pack.burgs.map( (burg, index) => {
+ // Ignore metadata burg
+ if(index === 0) {
+ return burg;
+ }
+ return {...burg, culture: pack.cells.culture[burg.cell]};
+ });
+
+ // Assign the culture associated with the states' center cell.
+ pack.states = pack.states.map( (state, index) => {
+ // Ignore neutrals state
+ if(index === 0) {
+ return state;
+ }
+ return {...state, culture: pack.cells.culture[state.center]};
+ });
+
+ console.timeEnd('updateCulturesForBurgsAndStates');
+ }
+
// calculate and draw curved state labels for a list of states
const drawStateLabels = function(list) {
console.time("drawStateLabels");
@@ -1029,6 +1055,6 @@
return {generate, expandStates, normalizeStates, assignColors,
drawBurgs, specifyBurgs, defineBurgFeatures, drawStateLabels, collectStatistics,
- generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces};
+ generateCampaigns, generateDiplomacy, defineStateForms, getFullName, generateProvinces, updateCultures};
})));
diff --git a/modules/religions-generator.js b/modules/religions-generator.js
index 096b32607..90ee88eea 100644
--- a/modules/religions-generator.js
+++ b/modules/religions-generator.js
@@ -279,6 +279,17 @@
});
}
+ function updateCultures() {
+ console.time('updateCulturesForReligions');
+ pack.religions = pack.religions.map( (religion, index) => {
+ if(index === 0) {
+ return religion;
+ }
+ return {...religion, culture: pack.cells.culture[religion.center]};
+ });
+ console.timeEnd('updateCulturesForReligions');
+ }
+
// assign a unique two-letters code (abbreviation)
function getCode(rawName) {
const name = rawName.replace("Old ", ""); // remove Old prefix
@@ -350,6 +361,6 @@
return type() + " of the " + generateMeaning();
};
- return {generate, add, getDeityName, expandReligions};
+ return {generate, add, getDeityName, expandReligions, updateCultures};
})));
diff --git a/modules/ui/cultures-editor.js b/modules/ui/cultures-editor.js
index 369083af9..8c4e7965a 100644
--- a/modules/ui/cultures-editor.js
+++ b/modules/ui/cultures-editor.js
@@ -38,6 +38,7 @@ function editCultures() {
function refreshCulturesEditor() {
culturesCollectStatistics();
culturesEditorAddLines();
+ drawCultureCenters();
}
function culturesCollectStatistics() {
diff --git a/modules/ui/editors.js b/modules/ui/editors.js
index e858beaf9..6129dd592 100644
--- a/modules/ui/editors.js
+++ b/modules/ui/editors.js
@@ -630,4 +630,17 @@ function selectIcon(initial, callback) {
Apply: function() {callback(input.value||"⠀"); $(this).dialog("close")},
Close: function() {callback(initial); $(this).dialog("close")}}
});
+}
+
+// Calls the refresh functionality on all editors currently open.
+function refreshAllEditors() {
+ console.time('refreshAllEditors');
+ if (document.getElementById('culturesEditorRefresh').offsetParent) culturesEditorRefresh.click();
+ if (document.getElementById('biomesEditorRefresh').offsetParent) biomesEditorRefresh.click();
+ if (document.getElementById('diplomacyEditorRefresh').offsetParent) diplomacyEditorRefresh.click();
+ if (document.getElementById('provincesEditorRefresh').offsetParent) provincesEditorRefresh.click();
+ if (document.getElementById('religionsEditorRefresh').offsetParent) religionsEditorRefresh.click();
+ if (document.getElementById('statesEditorRefresh').offsetParent) statesEditorRefresh.click();
+ if (document.getElementById('zonesEditorRefresh').offsetParent) zonesEditorRefresh.click();
+ console.timeEnd('refreshAllEditors');
}
\ No newline at end of file
diff --git a/modules/ui/tools.js b/modules/ui/tools.js
index a72800f5c..066eda0b4 100644
--- a/modules/ui/tools.js
+++ b/modules/ui/tools.js
@@ -55,15 +55,16 @@ toolsContent.addEventListener("click", function(event) {
});
function processFeatureRegeneration(event, button) {
- if (button === "regenerateStateLabels") {BurgsAndStates.drawStateLabels(); if (!layerIsOn("toggleLabels")) toggleLabels();} else
- if (button === "regenerateReliefIcons") {ReliefIcons(); if (!layerIsOn("toggleRelief")) toggleRelief();} else
- if (button === "regenerateRoutes") {Routes.regenerate(); if (!layerIsOn("toggleRoutes")) toggleRoutes();} else
+ if (button === "regenerateStateLabels") {BurgsAndStates.drawStateLabels(); if (!layerIsOn("toggleLabels")) toggleLabels();} else
+ if (button === "regenerateReliefIcons") {ReliefIcons(); if (!layerIsOn("toggleRelief")) toggleRelief();} else
+ if (button === "regenerateRoutes") {Routes.regenerate(); if (!layerIsOn("toggleRoutes")) toggleRoutes();} else
if (button === "regenerateRivers") regenerateRivers(); else
if (button === "regeneratePopulation") recalculatePopulation(); else
if (button === "regenerateBurgs") regenerateBurgs(); else
if (button === "regenerateStates") regenerateStates(); else
if (button === "regenerateProvinces") regenerateProvinces(); else
if (button === "regenerateReligions") regenerateReligions(); else
+ if (button === "regenerateCultures") regenerateCultures(); else
if (button === "regenerateMilitary") regenerateMilitary(); else
if (button === "regenerateIce") regenerateIce(); else
if (button === "regenerateMarkers") regenerateMarkers(event); else
@@ -244,6 +245,15 @@ function regenerateReligions() {
if (!layerIsOn("toggleReligions")) toggleReligions(); else drawReligions();
}
+function regenerateCultures() {
+ Cultures.generate();
+ Cultures.expand();
+ BurgsAndStates.updateCultures();
+ Religions.updateCultures();
+ if (!layerIsOn("toggleCultures")) toggleCultures(); else drawCultures();
+ refreshAllEditors();
+}
+
function regenerateMilitary() {
Military.generate();
if (!layerIsOn("toggleMilitary")) toggleMilitary();