mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
Amount of types and fixes
Fixed some spacing in zoneTypes dialog, and made a count for the amount of zones per type.
This commit is contained in:
parent
b2350a77d7
commit
16312aa864
2 changed files with 26 additions and 24 deletions
|
|
@ -2951,7 +2951,7 @@
|
|||
<div id="zonesTypes" class="dialog stable" style="display: none">
|
||||
<div id="customHeader" class="header">
|
||||
<div style="left:1.8em" data-tip="Name of this type of zone">Type Name </div>
|
||||
<div style="left:12em" data-tip="Number of zones of this type" class="hide">Amount </div>
|
||||
<div style="left:14em" data-tip="Number of zones of this type" class="hide">Amount </div>
|
||||
</div>
|
||||
|
||||
<div id="zonesTypesBodySection" class="table" data-type="absolute"></div>
|
||||
|
|
@ -2962,7 +2962,6 @@
|
|||
|
||||
<div id="zonesTypesBottom">
|
||||
<button id="zonesNewBlank" data-tip="Add a new blank zone layer" class="icon-flag-empty"></button>
|
||||
<button id="zonesNewRandom" data-tip="Add a new pre-filled random zone layer" class="icon-flag"></button>
|
||||
<input type="text" id="zonesNewTypeInput" data-tip="Write the name of the type you want to add" maxlength="20" placeholder="Add type"></input>
|
||||
<input type="button" id="zonesNewTypeButton" data-tip="Click add to save the type" value="Add">
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ function editZones() {
|
|||
document.getElementById("zonesManuallyApply").addEventListener("click", applyZonesManualAssignent);
|
||||
document.getElementById("zonesManuallyCancel").addEventListener("click", cancelZonesManualAssignent);
|
||||
document.getElementById("zonesAdd").addEventListener("click", addZonesDialog);
|
||||
//document.getElementById("typeTrash").addEventListener("click", removeZoneType);
|
||||
document.getElementById("zonesNewBlank").addEventListener("click", addZonesLayer);
|
||||
document.getElementById("zonesNewRandom").addEventListener("click", addZonesLayer);
|
||||
document.getElementById("zonesNewTypeButton").addEventListener("click", addZonesType);
|
||||
document.getElementById("zonesExport").addEventListener("click", downloadZonesData);
|
||||
document.getElementById("zonesRemove").addEventListener("click", toggleEraseMode);
|
||||
|
|
@ -102,6 +100,12 @@ function editZones() {
|
|||
const unit = areaUnit.value === "square" ? " " + distanceUnitInput.value + "²" : " " + areaUnit.value;
|
||||
let lines = "";
|
||||
|
||||
// make sure all zone types are loaded from the SVG
|
||||
zones.selectAll("g").each(function () {
|
||||
const zoneType = this.dataset.type;
|
||||
if (!zoneTypes.includes(zoneType)) { zoneTypes.push(zoneType); }
|
||||
});
|
||||
|
||||
const selectedType = zonesFilterType.value || "All";
|
||||
zonesFilterType.options.length=0;
|
||||
zonesFilterType.options.add(new Option("All", "All", false, selectedType=="All"));
|
||||
|
|
@ -111,7 +115,6 @@ function editZones() {
|
|||
|
||||
zones.selectAll("g").each(function () {
|
||||
const zoneType = this.dataset.type;
|
||||
//if (zonesFilterButton.classList.contains("pressed") && zoneType !== selectedType) return;
|
||||
if (selectedType !== "All" && (zonesFilterButton.classList.contains("pressed") && zoneType !== selectedType)) return;
|
||||
|
||||
const c = this.dataset.cells ? this.dataset.cells.split(",").map(c => +c) : [];
|
||||
|
|
@ -144,8 +147,6 @@ function editZones() {
|
|||
});
|
||||
|
||||
body.innerHTML = lines;
|
||||
if (body.innerHTML === "") { body.innerHTML = `<div class="states"><span>Zero entries for this type. To see entries again, select "All" or disable the filter button</span>
|
||||
</div>`; }
|
||||
|
||||
// update footer
|
||||
const totalArea = (zonesFooterArea.dataset.area = graphWidth * graphHeight * distanceScaleInput.value ** 2);
|
||||
|
|
@ -522,7 +523,9 @@ function editZones() {
|
|||
const zoneTypeListBody = document.getElementById("zonesTypesBodySection");
|
||||
let lines = "";
|
||||
zoneTypes.forEach(function(z, i) {
|
||||
lines += `<div class="states"><span class="religionname">${z}</span>`;
|
||||
let count=0; // Amount of zones per type
|
||||
zones.selectAll("g").each(function() { if (this.dataset.type === z) count++; });
|
||||
lines += `<div class="states"><span class="religionDeity">${z}</span><span class="religionType">${count}</span>`;
|
||||
if (i > 5) {
|
||||
let id="removeZoneType" + i;
|
||||
lines += `<span data-tip="Remove zone type" class="icon-trash-empty" id="${id}"></span>`;
|
||||
|
|
@ -531,7 +534,7 @@ function editZones() {
|
|||
});
|
||||
zoneTypeListBody.innerHTML = lines;
|
||||
zonesTypesFooterNumber.innerHTML = zoneTypes.length;
|
||||
}
|
||||
}
|
||||
|
||||
function addZonesDialog() {
|
||||
$("#zonesTypes").dialog({
|
||||
|
|
@ -541,7 +544,7 @@ function editZones() {
|
|||
position: {my: "center", at: "center", of: "svg"},
|
||||
});
|
||||
zonesTypesAddLines();
|
||||
}
|
||||
}
|
||||
|
||||
function closeZoneTypesEditor() {
|
||||
zonesEditorAddLines();
|
||||
|
|
@ -560,7 +563,7 @@ function editZones() {
|
|||
}
|
||||
}
|
||||
|
||||
function removeZoneType(zoneType) {
|
||||
function removeZoneType(zoneType) {
|
||||
zones.selectAll("g").each(function () {
|
||||
if (this.dataset.type === zoneType) {
|
||||
this.dataset.type = "Unassigned";
|
||||
|
|
@ -574,7 +577,7 @@ function removeZoneType(zoneType) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function zoneRemove(zone) {
|
||||
zones.select("#" + zone).remove();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue