Add the ability to regenerate cultures (#495)

* Add the ability to regenerate cultures

- Added a button to the tools menu for regeneration.
- Regeneration button will handle initial generation of cultures and expansion afterwards.
- Pressing regenerate will warn the user.
- Small cleanup of trailing whitespace.

* Refreshing cultures editor updates culture centers

* Regenerating cultures refreshes the culture editor

* Added a function to refresh all open editors

* Reset burg and state cultures after regeneration

* Address the problem of potential data loss

Any errors while iterating the states or burgs could potentially lose the index 0 metadata stored in the arrays. This will instead track the index and ignore the 0th result.

* Religions update cultures on culture regeneration

Updated function names to be more similar and more descriptive
This commit is contained in:
mdirienzo 2020-07-18 04:31:09 -04:00 committed by Azgaar
parent cf0a446b6a
commit fb28576f7c
6 changed files with 69 additions and 7 deletions

View file

@ -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');
}