mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
test
This commit is contained in:
commit
1619bed334
2 changed files with 34 additions and 21 deletions
|
|
@ -4538,7 +4538,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="provincesEditor" class="dialog stable" style="display: none">
|
<div id="provincesEditor" class="dialog stable" style="display: none">
|
||||||
<div id="provincesHeader" class="header" style="grid-template-columns: 11em 8em 8em 8em 5em 8em">
|
<div id="provincesHeader" class="header" style="grid-template-columns: 11em 8em 8em 6em 6em 6em 8em">
|
||||||
<div data-tip="Click to sort by province name" class="sortable alphabetically" data-sortby="name">
|
<div data-tip="Click to sort by province name" class="sortable alphabetically" data-sortby="name">
|
||||||
Province
|
Province
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -4551,6 +4551,7 @@
|
||||||
<div data-tip="Click to sort by province owner" class="sortable alphabetically" data-sortby="state">
|
<div data-tip="Click to sort by province owner" class="sortable alphabetically" data-sortby="state">
|
||||||
State
|
State
|
||||||
</div>
|
</div>
|
||||||
|
<div data-tip="Click to sort by province burgs count" class="sortable hide" data-sortby="burgs">Burgs </div>
|
||||||
<div data-tip="Click to sort by province area" class="sortable hide" data-sortby="area">Area </div>
|
<div data-tip="Click to sort by province area" class="sortable hide" data-sortby="area">Area </div>
|
||||||
<div data-tip="Click to sort by province population" class="sortable hide" data-sortby="population">
|
<div data-tip="Click to sort by province population" class="sortable hide" data-sortby="population">
|
||||||
Population
|
Population
|
||||||
|
|
@ -4563,6 +4564,9 @@
|
||||||
<div data-tip="Provinces displayed" style="margin-left: 4px">
|
<div data-tip="Provinces displayed" style="margin-left: 4px">
|
||||||
Provinces: <span id="provincesFooterNumber">0</span>
|
Provinces: <span id="provincesFooterNumber">0</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div data-tip="Total burgs number" style="margin-left: 12px">
|
||||||
|
Burgs: <span id="provincesFooterBurgs">0</span>
|
||||||
|
</div>
|
||||||
<div data-tip="Average area" style="margin-left: 14px">
|
<div data-tip="Average area" style="margin-left: 14px">
|
||||||
Mean area: <span id="provincesFooterArea">0</span>
|
Mean area: <span id="provincesFooterArea">0</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -44,12 +44,14 @@ function editProvinces() {
|
||||||
cl = el.classList,
|
cl = el.classList,
|
||||||
line = el.parentNode,
|
line = el.parentNode,
|
||||||
p = +line.dataset.id;
|
p = +line.dataset.id;
|
||||||
|
const stateId = pack.provinces[p].state;
|
||||||
|
|
||||||
if (el.tagName === "FILL-BOX") changeFill(el);
|
if (el.tagName === "FILL-BOX") changeFill(el);
|
||||||
else if (cl.contains("name")) editProvinceName(p);
|
else if (cl.contains("name")) editProvinceName(p);
|
||||||
else if (cl.contains("coaIcon")) editEmblem("province", "provinceCOA" + p, pack.provinces[p]);
|
else if (cl.contains("coaIcon")) editEmblem("province", "provinceCOA" + p, pack.provinces[p]);
|
||||||
else if (cl.contains("icon-star-empty")) capitalZoomIn(p);
|
else if (cl.contains("icon-star-empty")) capitalZoomIn(p);
|
||||||
else if (cl.contains("icon-flag-empty")) triggerIndependencePromps(p);
|
else if (cl.contains("icon-flag-empty")) triggerIndependencePromps(p);
|
||||||
|
else if (cl.contains("icon-dot-circled")) overviewBurgs({stateId});
|
||||||
else if (cl.contains("culturePopulation")) changePopulation(p);
|
else if (cl.contains("culturePopulation")) changePopulation(p);
|
||||||
else if (cl.contains("icon-pin")) toggleFog(p, cl);
|
else if (cl.contains("icon-pin")) toggleFog(p, cl);
|
||||||
else if (cl.contains("icon-trash-empty")) removeProvince(p);
|
else if (cl.contains("icon-trash-empty")) removeProvince(p);
|
||||||
|
|
@ -71,9 +73,8 @@ function editProvinces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectStatistics() {
|
function collectStatistics() {
|
||||||
const cells = pack.cells,
|
const {cells, provinces, burgs} = pack;
|
||||||
provinces = pack.provinces,
|
|
||||||
burgs = pack.burgs;
|
|
||||||
provinces.forEach(p => {
|
provinces.forEach(p => {
|
||||||
if (!p.i || p.removed) return;
|
if (!p.i || p.removed) return;
|
||||||
p.area = p.rural = p.urban = 0;
|
p.area = p.rural = p.urban = 0;
|
||||||
|
|
@ -107,16 +108,18 @@ function editProvinces() {
|
||||||
statesSorted.forEach(s => stateFilter.options.add(new Option(s.name, s.i, false, s.i == selectedState)));
|
statesSorted.forEach(s => stateFilter.options.add(new Option(s.name, s.i, false, s.i == selectedState)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add line for each state
|
// add line for each province
|
||||||
function provincesEditorAddLines() {
|
function provincesEditorAddLines() {
|
||||||
const unit = " " + getAreaUnit();
|
const unit = " " + getAreaUnit();
|
||||||
const selectedState = +document.getElementById("provincesFilterState").value;
|
const selectedState = +document.getElementById("provincesFilterState").value;
|
||||||
let filtered = pack.provinces.filter(p => p.i && !p.removed); // all valid burgs
|
let filtered = pack.provinces.filter(p => p.i && !p.removed); // all valid burgs
|
||||||
if (selectedState != -1) filtered = filtered.filter(p => p.state === selectedState); // filtered by state
|
if (selectedState != -1) filtered = filtered.filter(p => p.state === selectedState); // filtered by state
|
||||||
body.innerHTML = "";
|
body.innerHTML = "";
|
||||||
let lines = "",
|
|
||||||
totalArea = 0,
|
let lines = "";
|
||||||
totalPopulation = 0;
|
let totalArea = 0;
|
||||||
|
let totalPopulation = 0;
|
||||||
|
let totalBurgs = 0;
|
||||||
|
|
||||||
for (const p of filtered) {
|
for (const p of filtered) {
|
||||||
const area = getArea(p.area);
|
const area = getArea(p.area);
|
||||||
|
|
@ -128,6 +131,7 @@ function editProvinces() {
|
||||||
rural
|
rural
|
||||||
)}; Urban population: ${si(urban)}`;
|
)}; Urban population: ${si(urban)}`;
|
||||||
totalPopulation += population;
|
totalPopulation += population;
|
||||||
|
totalBurgs += p.burgs.length;
|
||||||
|
|
||||||
const stateName = pack.states[p.state].name;
|
const stateName = pack.states[p.state].name;
|
||||||
const capital = p.burg ? pack.burgs[p.burg].name : "";
|
const capital = p.burg ? pack.burgs[p.burg].name : "";
|
||||||
|
|
@ -144,6 +148,7 @@ function editProvinces() {
|
||||||
data-state="${stateName}"
|
data-state="${stateName}"
|
||||||
data-area=${area}
|
data-area=${area}
|
||||||
data-population=${population}
|
data-population=${population}
|
||||||
|
data-burgs=${p.burgs.length}
|
||||||
>
|
>
|
||||||
<fill-box fill="${p.color}"></fill-box>
|
<fill-box fill="${p.color}"></fill-box>
|
||||||
<input data-tip="Province name. Click to change" class="name pointer" value="${p.name}" readonly />
|
<input data-tip="Province name. Click to change" class="name pointer" value="${p.name}" readonly />
|
||||||
|
|
@ -163,6 +168,8 @@ function editProvinces() {
|
||||||
${p.burgs.length ? getCapitalOptions(p.burgs, p.burg) : ""}
|
${p.burgs.length ? getCapitalOptions(p.burgs, p.burg) : ""}
|
||||||
</select>
|
</select>
|
||||||
<input data-tip="Province owner" class="provinceOwner" value="${stateName}" disabled">
|
<input data-tip="Province owner" class="provinceOwner" value="${stateName}" disabled">
|
||||||
|
<span data-tip="Click to overview province burgs" style="padding-right: 1px" class="icon-dot-circled pointer hide"></span>
|
||||||
|
<div data-tip="Burgs count" class="provinceBurgs hide">${p.burgs.length}</div>
|
||||||
<span data-tip="Province area" style="padding-right: 4px" class="icon-map-o hide"></span>
|
<span data-tip="Province area" style="padding-right: 4px" class="icon-map-o hide"></span>
|
||||||
<div data-tip="Province area" class="biomeArea hide">${si(area) + unit}</div>
|
<div data-tip="Province area" class="biomeArea hide">${si(area) + unit}</div>
|
||||||
<span data-tip="${populationTip}" class="icon-male hide"></span>
|
<span data-tip="${populationTip}" class="icon-male hide"></span>
|
||||||
|
|
@ -179,11 +186,12 @@ function editProvinces() {
|
||||||
body.innerHTML = lines;
|
body.innerHTML = lines;
|
||||||
|
|
||||||
// update footer
|
// update footer
|
||||||
provincesFooterNumber.innerHTML = filtered.length;
|
byId("provincesFooterNumber").innerHTML = filtered.length;
|
||||||
provincesFooterArea.innerHTML = filtered.length ? si(totalArea / filtered.length) + unit : 0 + unit;
|
byId("provincesFooterBurgs").innerHTML = totalBurgs;
|
||||||
provincesFooterPopulation.innerHTML = filtered.length ? si(totalPopulation / filtered.length) : 0;
|
byId("provincesFooterArea").innerHTML = filtered.length ? si(totalArea / filtered.length) + unit : 0 + unit;
|
||||||
provincesFooterArea.dataset.area = totalArea;
|
byId("provincesFooterPopulation").innerHTML = filtered.length ? si(totalPopulation / filtered.length) : 0;
|
||||||
provincesFooterPopulation.dataset.population = totalPopulation;
|
byId("provincesFooterArea").dataset.area = totalArea;
|
||||||
|
byId("provincesFooterPopulation").dataset.population = totalPopulation;
|
||||||
|
|
||||||
body.querySelectorAll("div.states").forEach(el => {
|
body.querySelectorAll("div.states").forEach(el => {
|
||||||
el.addEventListener("click", selectProvinceOnLineClick);
|
el.addEventListener("click", selectProvinceOnLineClick);
|
||||||
|
|
@ -579,12 +587,15 @@ function editProvinces() {
|
||||||
function togglePercentageMode() {
|
function togglePercentageMode() {
|
||||||
if (body.dataset.type === "absolute") {
|
if (body.dataset.type === "absolute") {
|
||||||
body.dataset.type = "percentage";
|
body.dataset.type = "percentage";
|
||||||
|
const totalBurgs = +byId("provincesFooterBurgs").innerText;
|
||||||
const totalArea = +provincesFooterArea.dataset.area;
|
const totalArea = +provincesFooterArea.dataset.area;
|
||||||
const totalPopulation = +provincesFooterPopulation.dataset.population;
|
const totalPopulation = +provincesFooterPopulation.dataset.population;
|
||||||
|
|
||||||
body.querySelectorAll(":scope > div").forEach(function (el) {
|
body.querySelectorAll(":scope > div").forEach(function (el) {
|
||||||
el.querySelector(".biomeArea").innerHTML = rn((+el.dataset.area / totalArea) * 100) + "%";
|
const {cells, burgs, area, population} = el.dataset;
|
||||||
el.querySelector(".culturePopulation").innerHTML = rn((+el.dataset.population / totalPopulation) * 100) + "%";
|
el.querySelector(".provinceBurgs").innerText = rn((+burgs / totalBurgs) * 100) + "%";
|
||||||
|
el.querySelector(".biomeArea").innerHTML = rn((+area / totalArea) * 100) + "%";
|
||||||
|
el.querySelector(".culturePopulation").innerHTML = rn((+population / totalPopulation) * 100) + "%";
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
body.dataset.type = "absolute";
|
body.dataset.type = "absolute";
|
||||||
|
|
@ -1067,10 +1078,7 @@ function editProvinces() {
|
||||||
|
|
||||||
function downloadProvincesData() {
|
function downloadProvincesData() {
|
||||||
const unit = areaUnit.value === "square" ? distanceUnitInput.value + "2" : areaUnit.value;
|
const unit = areaUnit.value === "square" ? distanceUnitInput.value + "2" : areaUnit.value;
|
||||||
let data =
|
let data = `Id,Province,Full Name,Form,State,Color,Capital,Area ${unit},Total Population,Rural Population,Urban Population,Burgs\n`; // headers
|
||||||
"Id,Province,Full Name,Form,State,Color,Capital,Area " +
|
|
||||||
unit +
|
|
||||||
",Total Population,Rural Population,Urban Population\n"; // headers
|
|
||||||
|
|
||||||
body.querySelectorAll(":scope > div").forEach(function (el) {
|
body.querySelectorAll(":scope > div").forEach(function (el) {
|
||||||
const key = parseInt(el.dataset.id);
|
const key = parseInt(el.dataset.id);
|
||||||
|
|
@ -1084,8 +1092,9 @@ function editProvinces() {
|
||||||
data += el.dataset.capital + ",";
|
data += el.dataset.capital + ",";
|
||||||
data += el.dataset.area + ",";
|
data += el.dataset.area + ",";
|
||||||
data += el.dataset.population + ",";
|
data += el.dataset.population + ",";
|
||||||
data += `${Math.round(provincePack.rural * populationRate)},`;
|
data += Math.round(provincePack.rural * populationRate) + ",";
|
||||||
data += `${Math.round(provincePack.urban * populationRate * urbanization)}\n`;
|
data += Math.round(provincePack.urban * populationRate * urbanization) + ",";
|
||||||
|
data += el.dataset.burgs + "\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
const name = getFileName("Provinces") + ".csv";
|
const name = getFileName("Provinces") + ".csv";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue