Merge pull request #800 from Azgaar/states-editor-dynamic-load

States editor dynamic load
This commit is contained in:
Azgaar 2022-05-15 20:09:10 +03:00 committed by GitHub
commit 458437624c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 1391 additions and 1396 deletions

View file

@ -1396,7 +1396,7 @@ div.totalLine > div {
} }
div.states > input { div.states > input {
width: 6em; width: 7em;
background: none; background: none;
border: 0; border: 0;
} }
@ -1405,20 +1405,11 @@ div.states div {
width: 3.2em; width: 3.2em;
} }
div.states .statePower,
div.states .biomeHabitability { div.states .biomeHabitability {
width: 4em; width: 4em;
-moz-appearance: textfield; -moz-appearance: textfield;
} }
div.states .stateBurgs {
width: 2.4em;
}
div.states > .stateArea {
width: 5em;
}
div.states > .statePopulation { div.states > .statePopulation {
width: 3em; width: 3em;
} }
@ -1471,7 +1462,7 @@ div.states > .culturePopulation {
} }
div.states > select { div.states > select {
width: 4.6em; width: 7em;
cursor: pointer; cursor: pointer;
border: 0; border: 0;
background-color: transparent; background-color: transparent;

View file

@ -107,7 +107,7 @@
} }
} }
</style> </style>
<link rel="stylesheet" href="index.css" /> <link rel="stylesheet" href="index.css?v=15052022" />
<link rel="stylesheet" href="icons.css" /> <link rel="stylesheet" href="icons.css" />
<link rel="stylesheet" href="libs/jquery-ui.css" /> <link rel="stylesheet" href="libs/jquery-ui.css" />
</head> </head>
@ -3083,110 +3083,6 @@
</div> </div>
</div> </div>
<div id="statesEditor" class="dialog stable" style="display: none">
<div id="statesHeader" class="header">
<div style="left: 1.8em" data-tip="Click to sort by state name" class="sortable alphabetically" data-sortby="name">State&nbsp;</div>
<div style="left: 9.7em" data-tip="Click to sort by state form name" class="sortable alphabetically" data-sortby="form">Form&nbsp;</div>
<div style="left: 16.3em" data-tip="Click to sort by capital name" class="sortable alphabetically hide" data-sortby="capital">Capital&nbsp;</div>
<div style="left: 23em" data-tip="Click to sort by state dominant culture" class="sortable alphabetically hide" data-sortby="culture">
Culture&nbsp;
</div>
<div style="left: 27.8em" data-tip="Click to sort by state burgs count" class="sortable hide" data-sortby="burgs">Burgs&nbsp;</div>
<div style="left: 32.5em" data-tip="Click to sort by state area" class="sortable hide icon-sort-number-down" data-sortby="area">Area&nbsp;</div>
<div style="left: 37em" data-tip="Click to sort by state population" class="sortable hide" data-sortby="population">Population&nbsp;</div>
<div style="left: 43.5em" data-tip="Click to sort by state type" class="sortable alphabetically hidden show hide" data-sortby="type">Type&nbsp;</div>
<div style="left: 47em" data-tip="Click to sort by state expansion value" class="sortable hidden show hide" data-sortby="expansionism">
Expansion&nbsp;
</div>
<div style="left: 53.5em" data-tip="Click to sort by state cells count" class="sortable hidden show hide" data-sortby="cells">Cells&nbsp;</div>
</div>
<div id="statesBodySection" class="table" data-type="absolute"></div>
<div id="statesFooter" class="totalLine">
<div data-tip="States number" style="margin-left: 5px">States:&nbsp;<span id="statesFooterStates">0</span></div>
<div data-tip="Total land cells number" style="margin-left: 12px">Cells:&nbsp;<span id="statesFooterCells">0</span></div>
<div data-tip="Total burgs number" style="margin-left: 12px">Burgs:&nbsp;<span id="statesFooterBurgs">0</span></div>
<div data-tip="Total land area" style="margin-left: 12px">Land Area:&nbsp;<span id="statesFooterArea">0</span></div>
<div data-tip="Total population" style="margin-left: 12px">Population:&nbsp;<span id="statesFooterPopulation">0</span></div>
</div>
<div id="statesBottom">
<button id="statesEditorRefresh" data-tip="Refresh the Editor" class="icon-cw"></button>
<button id="statesEditStyle" data-tip="Edit states style in Style Editor" class="icon-adjust"></button>
<button id="statesLegend" data-tip="Toggle Legend box" class="icon-list-bullet"></button>
<button id="statesPercentage" data-tip="Toggle percentage / absolute values views" class="icon-percent"></button>
<button id="statesChart" data-tip="Show states bubble chart" class="icon-chart-area"></button>
<button id="statesRegenerate" data-tip="Show the regeneration menu and more data" class="icon-cog-alt"></button>
<div id="statesRegenerateButtons" style="display: none">
<button id="statesRegenerateBack" data-tip="Hide the regeneration menu" class="icon-cog-alt"></button>
<button id="statesRandomize" data-tip="Randomize states Expansion value and re-calculate states and provinces" class="icon-shuffle"></button>
<span data-tip="Additional growth rate. Defines how many lands will stay neutral">
<label class="italic">Growth rate:</label>
<input
id="statesNeutral"
oninput="tip('Growth rate: '+this.value); statesNeutralNumber.value = this.value"
type="range"
min=".1"
max="3"
step=".05"
value="1"
style="width: 90px"
/>
<input
id="statesNeutralNumber"
oninput="tip('Growth rate: '+this.value); statesNeutral.value = this.value"
type="number"
min=".1"
max="3"
step=".05"
value="1"
style="width: 42px"
/>
</span>
<button id="statesRecalculate" data-tip="Recalculate states based on current values of growth-related attributes" class="icon-retweet"></button>
<span data-tip="Allow states neutral distance, expansion and type changes to take an immediate effect">
<input id="statesAutoChange" class="checkbox" type="checkbox" />
<label for="statesAutoChange" class="checkbox-label"><i>auto-apply changes</i></label>
</span>
<span data-tip="Allow system to change state labels when states data is change">
<input id="adjustLabels" class="checkbox" type="checkbox" />
<label for="adjustLabels" class="checkbox-label"><i>auto-change labels</i></label>
</span>
</div>
<button id="statesManually" data-tip="Manually re-assign states" class="icon-brush"></button>
<div id="statesManuallyButtons" style="display: none">
<label data-tip="Change brush size. Shortcut: + (increase), (decrease)" class="italic"
>Brush size:
<input
id="statesManuallyBrush"
oninput="tip('Brush size: '+this.value); statesManuallyBrushNumber.value = this.value"
type="range"
min="5"
max="99"
value="15"
style="width: 5em"
/>
<input
id="statesManuallyBrushNumber"
oninput="tip('Brush size: '+this.value); statesManuallyBrush.value = this.value"
type="number"
min="5"
max="99"
value="15"
/> </label
><br />
<button id="statesManuallyApply" data-tip="Apply assignment" class="icon-check"></button>
<button id="statesManuallyCancel" data-tip="Cancel assignment" class="icon-cancel"></button>
</div>
<button id="statesAdd" data-tip="Add a new state. Hold Shift to add multiple" class="icon-plus"></button>
<button id="statesExport" data-tip="Save state-related data as a text file (.csv)" class="icon-download"></button>
</div>
</div>
<div id="stateNameEditor" class="dialog" data-state="0" style="display: none"> <div id="stateNameEditor" class="dialog" data-state="0" style="display: none">
<div> <div>
<div data-tip="State short name" class="label">Short name:</div> <div data-tip="State short name" class="label">Short name:</div>
@ -3295,11 +3191,11 @@
<div id="provincesEditor" class="dialog stable" style="display: none"> <div id="provincesEditor" class="dialog stable" style="display: none">
<div id="provincesHeader" class="header"> <div id="provincesHeader" class="header">
<div style="left: 1.8em" data-tip="Click to sort by province name" class="sortable alphabetically" data-sortby="name">Province&nbsp;</div> <div style="left: 1.8em" data-tip="Click to sort by province name" class="sortable alphabetically" data-sortby="name">Province&nbsp;</div>
<div style="left: 9.7em" data-tip="Click to sort by province form name" class="sortable alphabetically hide" data-sortby="form">Form&nbsp;</div> <div style="left: 10.8em" data-tip="Click to sort by province form name" class="sortable alphabetically hide" data-sortby="form">Form&nbsp;</div>
<div style="left: 15.9em" data-tip="Click to sort by province capital" class="sortable alphabetically hide" data-sortby="capital">Capital&nbsp;</div> <div style="left: 18.8em" data-tip="Click to sort by province capital" class="sortable alphabetically hide" data-sortby="capital">Capital&nbsp;</div>
<div style="left: 23.2em" data-tip="Click to sort by province owner" class="sortable alphabetically" data-sortby="state">State&nbsp;</div> <div style="left: 25.3em" data-tip="Click to sort by province owner" class="sortable alphabetically" data-sortby="state">State&nbsp;</div>
<div style="left: 30em" data-tip="Click to sort by province area" class="sortable hide" data-sortby="area">Area&nbsp;</div> <div style="left: 33.9em" data-tip="Click to sort by province area" class="sortable hide" data-sortby="area">Area&nbsp;</div>
<div style="left: 35.3em" data-tip="Click to sort by province population" class="sortable hide" data-sortby="population">Population&nbsp;</div> <div style="left: 39.3em" data-tip="Click to sort by province population" class="sortable hide" data-sortby="population">Population&nbsp;</div>
</div> </div>
<div id="provincesBodySection" class="table" data-type="absolute"></div> <div id="provincesBodySection" class="table" data-type="absolute"></div>
@ -3450,15 +3346,15 @@
<div id="culturesEditor" class="dialog stable" style="display: none"> <div id="culturesEditor" class="dialog stable" style="display: none">
<div id="culturesHeader" class="header"> <div id="culturesHeader" class="header">
<div style="left: 1.8em" data-tip="Click to sort by culture name" class="sortable alphabetically" data-sortby="name">Culture&nbsp;</div> <div style="left: 1.8em" data-tip="Click to sort by culture name" class="sortable alphabetically" data-sortby="name">Culture&nbsp;</div>
<div style="left: 9.8em" data-tip="Click to sort by culture cells count" class="sortable hide" data-sortby="cells">Cells&nbsp;</div> <div style="left: 9.9em" data-tip="Click to sort by culture cells count" class="sortable hide" data-sortby="cells">Cells&nbsp;</div>
<div style="left: 14.3em" data-tip="Click to sort by expansionism" class="sortable hide" data-sortby="expansionism">Expan.&nbsp;</div> <div style="left: 14.5em" data-tip="Click to sort by expansionism" class="sortable hide" data-sortby="expansionism">Expan.&nbsp;</div>
<div style="left: 19.7em" data-tip="Click to sort by type" class="sortable alphabetically" data-sortby="type">Type&nbsp;</div> <div style="left: 20.3em" data-tip="Click to sort by type" class="sortable alphabetically" data-sortby="type">Type&nbsp;</div>
<div style="left: 26em" data-tip="Click to sort by culture area" class="sortable hide" data-sortby="area">Area&nbsp;</div> <div style="left: 29.1em" data-tip="Click to sort by culture area" class="sortable hide" data-sortby="area">Area&nbsp;</div>
<div style="left: 29.9em" data-tip="Click to sort by culture population" class="sortable hide icon-sort-number-down" data-sortby="population"> <div style="left: 33em" data-tip="Click to sort by culture population" class="sortable hide icon-sort-number-down" data-sortby="population">
Population&nbsp; Population&nbsp;
</div> </div>
<div style="left: 36.9em" data-tip="Click to sort by culture namesbase" class="sortable" data-sortby="base">Namesbase&nbsp;</div> <div style="left: 39.5em" data-tip="Click to sort by culture namesbase" class="sortable" data-sortby="base">Namesbase&nbsp;</div>
<div style="left: 44em" data-tip="Click to sort by culture emblems shape" class="sortable alphabetically hide" data-sortby="emblems"> <div style="left: 47em" data-tip="Click to sort by culture emblems shape" class="sortable alphabetically hide" data-sortby="emblems">
Emblems&nbsp; Emblems&nbsp;
</div> </div>
</div> </div>
@ -3570,9 +3466,9 @@
<div id="customHeader" class="header"> <div id="customHeader" class="header">
<div style="left: 1.8em" data-tip="Zone description">Description&nbsp;</div> <div style="left: 1.8em" data-tip="Zone description">Description&nbsp;</div>
<div style="left: 13em" data-tip="Zone type">Type&nbsp;</div> <div style="left: 13em" data-tip="Zone type">Type&nbsp;</div>
<div style="left: 19em" data-tip="Zone cells count" class="hide">Cells&nbsp;</div> <div style="left: 20em" data-tip="Zone cells count" class="hide">Cells&nbsp;</div>
<div style="left: 23.6em" data-tip="Zone area" class="hide">Area&nbsp;</div> <div style="left: 26.1em" data-tip="Zone area" class="hide">Area&nbsp;</div>
<div style="left: 30.6em" data-tip="Zone population" class="hide">Population&nbsp;</div> <div style="left: 31.6em" data-tip="Zone population" class="hide">Population&nbsp;</div>
</div> </div>
<div id="zonesBodySection" class="table" data-type="absolute"></div> <div id="zonesBodySection" class="table" data-type="absolute"></div>
@ -3648,13 +3544,13 @@
<div id="religionsEditor" class="dialog stable" style="display: none"> <div id="religionsEditor" class="dialog stable" style="display: none">
<div id="religionsHeader" class="header"> <div id="religionsHeader" class="header">
<div style="left: 1.8em" data-tip="Click to sort by religion name" class="sortable alphabetically" data-sortby="name">Religion&nbsp;</div> <div style="left: 1.8em" data-tip="Click to sort by religion name" class="sortable alphabetically" data-sortby="name">Religion&nbsp;</div>
<div style="left: 12.6em" data-tip="Click to sort by religion type" class="sortable alphabetically icon-sort-name-down" data-sortby="type"> <div style="left: 12.8em" data-tip="Click to sort by religion type" class="sortable alphabetically icon-sort-name-down" data-sortby="type">
Type&nbsp; Type&nbsp;
</div> </div>
<div style="left: 18em" data-tip="Click to sort by religion form" class="sortable alphabetically hide" data-sortby="form">Form&nbsp;</div> <div style="left: 18.4em" data-tip="Click to sort by religion form" class="sortable alphabetically hide" data-sortby="form">Form&nbsp;</div>
<div style="left: 25.1em" data-tip="Click to sort by supreme deity" class="sortable alphabetically hide" data-sortby="deity">Supreme Deity&nbsp;</div> <div style="left: 25.6em" data-tip="Click to sort by supreme deity" class="sortable alphabetically hide" data-sortby="deity">Supreme Deity&nbsp;</div>
<div style="left: 42.1em" data-tip="Click to sort by religion area" class="sortable hide" data-sortby="area">Area&nbsp;</div> <div style="left: 42.2em" data-tip="Click to sort by religion area" class="sortable hide" data-sortby="area">Area&nbsp;</div>
<div style="left: 47em" data-tip="Click to sort by number of believers (religion area population)" class="sortable hide" data-sortby="population"> <div style="left: 47.5em" data-tip="Click to sort by number of believers (religion area population)" class="sortable hide" data-sortby="population">
Believers&nbsp; Believers&nbsp;
</div> </div>
</div> </div>
@ -3978,12 +3874,12 @@
<div id="burgsOverview" class="dialog stable" style="display: none"> <div id="burgsOverview" class="dialog stable" style="display: none">
<div id="burgsHeader" class="header"> <div id="burgsHeader" class="header">
<div style="left: 1.8em" data-tip="Click to sort by burg name" class="sortable alphabetically icon-sort-name-up" data-sortby="name">Burg&nbsp;</div> <div style="left: 1.8em" data-tip="Click to sort by burg name" class="sortable alphabetically icon-sort-name-up" data-sortby="name">Burg&nbsp;</div>
<div style="left: 7.6em" data-tip="Click to sort by province name" class="sortable alphabetically" data-sortby="province">Province&nbsp;</div> <div style="left: 8em" data-tip="Click to sort by province name" class="sortable alphabetically" data-sortby="province">Province&nbsp;</div>
<div style="left: 14em" data-tip="Click to sort by state name" class="sortable alphabetically" data-sortby="state">State&nbsp;</div> <div style="left: 14.2em" data-tip="Click to sort by state name" class="sortable alphabetically" data-sortby="state">State&nbsp;</div>
<div style="left: 20.1em" data-tip="Click to sort by culture name" class="sortable alphabetically" data-sortby="culture">Culture&nbsp;</div> <div style="left: 20.2em" data-tip="Click to sort by culture name" class="sortable alphabetically" data-sortby="culture">Culture&nbsp;</div>
<div style="left: 24.7em" data-tip="Click to sort by burg population" class="sortable" data-sortby="population">Population&nbsp;</div> <div style="left: 27em" data-tip="Click to sort by burg population" class="sortable" data-sortby="population">Population&nbsp;</div>
<div style="left: 31.2em" data-tip="Click to sort by burg type" class="sortable alphabetically" data-sortby="type">Type&nbsp;</div> <div style="left: 33.7em" data-tip="Click to sort by burg type" class="sortable alphabetically" data-sortby="type">Type&nbsp;</div>
<div id="burgsInvertLock" style="left: 35.5em; color: #6e5e66" data-tip="Click to invert lock for all burgs" class="icon-lock pointer"></div> <div id="burgsInvertLock" style="left: 38em; color: #6e5e66" data-tip="Click to invert lock for all burgs" class="icon-lock pointer"></div>
</div> </div>
<div id="burgsBody" class="table"></div> <div id="burgsBody" class="table"></div>
@ -4158,7 +4054,7 @@
<div id="markersOverview" class="dialog stable" style="display: none"> <div id="markersOverview" class="dialog stable" style="display: none">
<div id="markersHeader" class="header"> <div id="markersHeader" class="header">
<div style="left: 1em" data-tip="Click to sort by marker type" class="sortable alphabetically" data-sortby="type">Type&nbsp;</div> <div style="left: 1.8em" data-tip="Click to sort by marker type" class="sortable alphabetically" data-sortby="type">Type&nbsp;</div>
<div id="markersInverPin" style="left: 14.9em; color: #6e5e66" data-tip="Click to invert pin state for all markers" class="icon-pin pointer"></div> <div id="markersInverPin" style="left: 14.9em; color: #6e5e66" data-tip="Click to invert pin state for all markers" class="icon-pin pointer"></div>
<div id="markersInverLock" style="left: 16.1em; color: #6e5e66" data-tip="Click to invert lock state for all markers" class="icon-lock pointer"></div> <div id="markersInverLock" style="left: 16.1em; color: #6e5e66" data-tip="Click to invert lock state for all markers" class="icon-lock pointer"></div>
</div> </div>
@ -6278,7 +6174,7 @@
<script src="modules/lakes.js"></script> <script src="modules/lakes.js"></script>
<script src="modules/names-generator.js"></script> <script src="modules/names-generator.js"></script>
<script src="modules/cultures-generator.js"></script> <script src="modules/cultures-generator.js"></script>
<script src="modules/burgs-and-states.js?v=14052022"></script> <script src="modules/burgs-and-states.js?v=15052022"></script>
<script src="modules/routes-generator.js"></script> <script src="modules/routes-generator.js"></script>
<script src="modules/religions-generator.js"></script> <script src="modules/religions-generator.js"></script>
<script src="modules/military-generator.js"></script> <script src="modules/military-generator.js"></script>
@ -6293,17 +6189,16 @@
<script src="modules/ui/measurers.js"></script> <script src="modules/ui/measurers.js"></script>
<script src="modules/ui/stylePresets.js"></script> <script src="modules/ui/stylePresets.js"></script>
<script src="modules/ui/general.js"></script> <script src="modules/ui/general.js?v=15052022"></script>
<script src="modules/ui/options.js?v=14052022"></script> <script src="modules/ui/options.js?v=14052022"></script>
<script src="main.js?v=14052022"></script> <script src="main.js?v=15052022"></script>
<script defer src="modules/relief-icons.js"></script> <script defer src="modules/relief-icons.js"></script>
<script defer src="modules/ui/style.js"></script> <script defer src="modules/ui/style.js"></script>
<script defer src="modules/ui/editors.js?v=15052022"></script>
<script defer src="modules/ui/tools.js"></script> <script defer src="modules/ui/tools.js"></script>
<script defer src="modules/ui/world-configurator.js"></script> <script defer src="modules/ui/world-configurator.js"></script>
<script defer src="modules/ui/editors.js"></script>
<script defer src="modules/ui/heightmap-editor.js"></script> <script defer src="modules/ui/heightmap-editor.js"></script>
<script defer src="modules/ui/states-editor.js"></script>
<script defer src="modules/ui/provinces-editor.js"></script> <script defer src="modules/ui/provinces-editor.js"></script>
<script defer src="modules/ui/biomes-editor.js"></script> <script defer src="modules/ui/biomes-editor.js"></script>
<script defer src="modules/ui/cultures-editor.js"></script> <script defer src="modules/ui/cultures-editor.js"></script>
@ -6342,7 +6237,7 @@
<script defer src="libs/jszip.min.js"></script> <script defer src="libs/jszip.min.js"></script>
<script defer src="modules/io/save.js"></script> <script defer src="modules/io/save.js"></script>
<script defer src="modules/io/load.js?v=14052022-5"></script> <script defer src="modules/io/load.js?v=15052022-5"></script>
<script defer src="modules/io/cloud.js"></script> <script defer src="modules/io/cloud.js"></script>
<script defer src="modules/io/export.js"></script> <script defer src="modules/io/export.js"></script>
<script defer src="modules/io/export-json.js"></script> <script defer src="modules/io/export-json.js"></script>

View file

@ -168,6 +168,7 @@ let populationRate = +document.getElementById("populationRateInput").value;
let distanceScale = +document.getElementById("distanceScaleInput").value; let distanceScale = +document.getElementById("distanceScaleInput").value;
let urbanization = +document.getElementById("urbanizationInput").value; let urbanization = +document.getElementById("urbanizationInput").value;
let urbanDensity = +document.getElementById("urbanDensityInput").value; let urbanDensity = +document.getElementById("urbanDensityInput").value;
let statesNeutral = 1; // statesEditor growth parameter
applyStoredOptions(); applyStoredOptions();

View file

@ -352,7 +352,7 @@ window.BurgsAndStates = (function () {
cells.state = new Uint16Array(cells.i.length); cells.state = new Uint16Array(cells.i.length);
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p}); const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
const cost = []; const cost = [];
const neutral = (cells.i.length / 5000) * 2500 * neutralInput.value * statesNeutral.value; // limit cost for state growth const neutral = (cells.i.length / 5000) * 2500 * neutralInput.value * statesNeutral; // limit cost for state growth
states states
.filter(s => s.i && !s.removed) .filter(s => s.i && !s.removed)

File diff suppressed because it is too large Load diff

View file

@ -124,9 +124,8 @@ function uploadMap(file, callback) {
const isInvalid = !mapData || isNaN(mapVersion) || mapData.length < 26 || !mapData[5]; const isInvalid = !mapData || isNaN(mapVersion) || mapData.length < 26 || !mapData[5];
const isUpdated = mapVersion === currentVersion; const isUpdated = mapVersion === currentVersion;
const isAncient = mapVersion < OLDEST_SUPPORTED_VERSION; const isAncient = mapVersion < OLDEST_SUPPORTED_VERSION;
// TODO: temp condition for 1.811, remove when 1.82 is released const isNewer = mapVersion > currentVersion;
const isNewer = mapVersion > currentVersion && mapVersion !== 1.811; const isOutdated = mapVersion < currentVersion;
const isOutdated = mapVersion < currentVersion || mapVersion === 1.811;
if (isInvalid) return showUploadMessage("invalid", mapData, mapVersion); if (isInvalid) return showUploadMessage("invalid", mapData, mapVersion);
if (isUpdated) return parseLoadedData(mapData); if (isUpdated) return parseLoadedData(mapData);

View file

@ -80,23 +80,23 @@ function fitContent() {
// apply sorting behaviour for lines on Editor header click // apply sorting behaviour for lines on Editor header click
document.querySelectorAll(".sortable").forEach(function (e) { document.querySelectorAll(".sortable").forEach(function (e) {
e.addEventListener("click", function (e) { e.addEventListener("click", function () {
sortLines(this); sortLines(this);
}); });
}); });
function sortLines(header) { function sortLines(headerElement) {
const type = header.classList.contains("alphabetically") ? "name" : "number"; const type = headerElement.classList.contains("alphabetically") ? "name" : "number";
let order = header.className.includes("-down") ? "-up" : "-down"; let order = headerElement.className.includes("-down") ? "-up" : "-down";
if (!header.className.includes("icon-sort") && type === "name") order = "-up"; if (!headerElement.className.includes("icon-sort") && type === "name") order = "-up";
const headers = header.parentNode; const headers = headerElement.parentNode;
headers.querySelectorAll("div.sortable").forEach(e => { headers.querySelectorAll("div.sortable").forEach(e => {
e.classList.forEach(c => { e.classList.forEach(c => {
if (c.includes("icon-sort")) e.classList.remove(c); if (c.includes("icon-sort")) e.classList.remove(c);
}); });
}); });
header.classList.add("icon-sort-" + type + order); headerElement.classList.add("icon-sort-" + type + order);
applySorting(headers); applySorting(headers);
} }
@ -1093,3 +1093,10 @@ function refreshAllEditors() {
if (document.getElementById("zonesEditorRefresh").offsetParent) zonesEditorRefresh.click(); if (document.getElementById("zonesEditorRefresh").offsetParent) zonesEditorRefresh.click();
TIME && console.timeEnd("refreshAllEditors"); TIME && console.timeEnd("refreshAllEditors");
} }
// dynamically loaded editors
async function editStates() {
if (customization) return;
const StateEditor = await import("../dynamic/editors/states-editor.js");
StateEditor.open();
}

View file

@ -75,12 +75,12 @@ function handleMouseMove() {
const g = findGridCell(point[0], point[1]); // grid cell id const g = findGridCell(point[0], point[1]); // grid cell id
if (tooltip.dataset.main) showMainTip(); if (tooltip.dataset.main) showMainTip();
else showMapTooltip(point, d3.event, i, g); else showMapTooltip(point, d3.event, i, g);
if (cellInfo.offsetParent) updateCellInfo(point, i, g); if (cellInfo?.offsetParent) updateCellInfo(point, i, g);
} }
// show note box on hover (if any) // show note box on hover (if any)
function showNotes(e) { function showNotes(e) {
if (notesEditor.offsetParent) return; if (notesEditor?.offsetParent) return;
let id = e.target.id || e.target.parentNode.id || e.target.parentNode.parentNode.id; let id = e.target.id || e.target.parentNode.id || e.target.parentNode.parentNode.id;
if (e.target.parentNode.parentNode.id === "burgLabels") id = "burg" + e.target.dataset.id; if (e.target.parentNode.parentNode.id === "burgLabels") id = "burg" + e.target.dataset.id;
else if (e.target.parentNode.parentNode.id === "burgIcons") id = "burg" + e.target.dataset.id; else if (e.target.parentNode.parentNode.id === "burgIcons") id = "burg" + e.target.dataset.id;
@ -90,7 +90,7 @@ function showNotes(e) {
document.getElementById("notes").style.display = "block"; document.getElementById("notes").style.display = "block";
document.getElementById("notesHeader").innerHTML = note.name; document.getElementById("notesHeader").innerHTML = note.name;
document.getElementById("notesBody").innerHTML = note.legend; document.getElementById("notesBody").innerHTML = note.legend;
} else if (!options.pinNotes && !markerEditor.offsetParent) { } else if (!options.pinNotes && !markerEditor?.offsetParent) {
document.getElementById("notes").style.display = "none"; document.getElementById("notes").style.display = "none";
document.getElementById("notesHeader").innerHTML = ""; document.getElementById("notesHeader").innerHTML = "";
document.getElementById("notesBody").innerHTML = ""; document.getElementById("notesBody").innerHTML = "";
@ -129,7 +129,7 @@ function showMapTooltip(point, e, i, g) {
const r = pack.rivers.find(r => r.i === river); const r = pack.rivers.find(r => r.i === river);
const name = r ? r.name + " " + r.type : ""; const name = r ? r.name + " " + r.type : "";
tip(name + ". Click to edit"); tip(name + ". Click to edit");
if (riversOverview.offsetParent) highlightEditorLine(riversOverview, river, 5000); if (riversOverview?.offsetParent) highlightEditorLine(riversOverview, river, 5000);
return; return;
} }
@ -142,7 +142,7 @@ function showMapTooltip(point, e, i, g) {
const b = pack.burgs[burg]; const b = pack.burgs[burg];
const population = si(b.population * populationRate * urbanization); const population = si(b.population * populationRate * urbanization);
tip(`${b.name}. Population: ${population}. Click to edit`); tip(`${b.name}. Population: ${population}. Click to edit`);
if (burgsOverview.offsetParent) highlightEditorLine(burgsOverview, burg, 5000); if (burgsOverview?.offsetParent) highlightEditorLine(burgsOverview, burg, 5000);
return; return;
} }
if (group === "labels") return tip("Click to edit the Label"); if (group === "labels") return tip("Click to edit the Label");
@ -176,7 +176,7 @@ function showMapTooltip(point, e, i, g) {
if (group === "zones") { if (group === "zones") {
const zone = path[path.length - 8]; const zone = path[path.length - 8];
tip(zone.dataset.description); tip(zone.dataset.description);
if (zonesEditor.offsetParent) highlightEditorLine(zonesEditor, zone.id, 5000); if (zonesEditor?.offsetParent) highlightEditorLine(zonesEditor, zone.id, 5000);
return; return;
} }
@ -189,27 +189,27 @@ function showMapTooltip(point, e, i, g) {
else if (layerIsOn("toggleBiomes") && pack.cells.biome[i]) { else if (layerIsOn("toggleBiomes") && pack.cells.biome[i]) {
const biome = pack.cells.biome[i]; const biome = pack.cells.biome[i];
tip("Biome: " + biomesData.name[biome]); tip("Biome: " + biomesData.name[biome]);
if (biomesEditor.offsetParent) highlightEditorLine(biomesEditor, biome); if (biomesEditor?.offsetParent) highlightEditorLine(biomesEditor, biome);
} else if (layerIsOn("toggleReligions") && pack.cells.religion[i]) { } else if (layerIsOn("toggleReligions") && pack.cells.religion[i]) {
const religion = pack.cells.religion[i]; const religion = pack.cells.religion[i];
const r = pack.religions[religion]; const r = pack.religions[religion];
const type = r.type === "Cult" || r.type == "Heresy" ? r.type : r.type + " religion"; const type = r.type === "Cult" || r.type == "Heresy" ? r.type : r.type + " religion";
tip(type + ": " + r.name); tip(type + ": " + r.name);
if (religionsEditor.offsetParent) highlightEditorLine(religionsEditor, religion); if (religionsEditor?.offsetParent) highlightEditorLine(religionsEditor, religion);
} else if (pack.cells.state[i] && (layerIsOn("toggleProvinces") || layerIsOn("toggleStates"))) { } else if (pack.cells.state[i] && (layerIsOn("toggleProvinces") || layerIsOn("toggleStates"))) {
const state = pack.cells.state[i]; const state = pack.cells.state[i];
const stateName = pack.states[state].fullName; const stateName = pack.states[state].fullName;
const province = pack.cells.province[i]; const province = pack.cells.province[i];
const prov = province ? pack.provinces[province].fullName + ", " : ""; const prov = province ? pack.provinces[province].fullName + ", " : "";
tip(prov + stateName); tip(prov + stateName);
if (statesEditor.offsetParent) highlightEditorLine(statesEditor, state); if (statesEditor?.offsetParent) highlightEditorLine(statesEditor, state);
if (diplomacyEditor.offsetParent) highlightEditorLine(diplomacyEditor, state); if (diplomacyEditor?.offsetParent) highlightEditorLine(diplomacyEditor, state);
if (militaryOverview.offsetParent) highlightEditorLine(militaryOverview, state); if (militaryOverview?.offsetParent) highlightEditorLine(militaryOverview, state);
if (provincesEditor.offsetParent) highlightEditorLine(provincesEditor, province); if (provincesEditor?.offsetParent) highlightEditorLine(provincesEditor, province);
} else if (layerIsOn("toggleCultures") && pack.cells.culture[i]) { } else if (layerIsOn("toggleCultures") && pack.cells.culture[i]) {
const culture = pack.cells.culture[i]; const culture = pack.cells.culture[i];
tip("Culture: " + pack.cultures[culture].name); tip("Culture: " + pack.cultures[culture].name);
if (culturesEditor.offsetParent) highlightEditorLine(culturesEditor, culture); if (culturesEditor?.offsetParent) highlightEditorLine(culturesEditor, culture);
} else if (layerIsOn("toggleHeight")) tip("Height: " + getFriendlyHeight(point)); } else if (layerIsOn("toggleHeight")) tip("Height: " + getFriendlyHeight(point));
} }

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
"use strict"; "use strict";
// version and caching control // version and caching control
const version = "1.81.11"; // generator version, update each time const version = "1.82.0"; // generator version, update each time
{ {
document.title += " v" + version; document.title += " v" + version;