mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
zone editor - restore init state + type display
This commit is contained in:
parent
61d4d52589
commit
08a9d75bc9
3 changed files with 6 additions and 86 deletions
9
main.js
9
main.js
|
|
@ -158,7 +158,6 @@ let customization = 0;
|
||||||
|
|
||||||
let biomesData = applyDefaultBiomesSystem();
|
let biomesData = applyDefaultBiomesSystem();
|
||||||
let nameBases = Names.getNameBases(); // cultures-related data
|
let nameBases = Names.getNameBases(); // cultures-related data
|
||||||
const zoneTypes = ["Invasion", "Rebels", "Proselytism", "Crusade", "Disease", "Disaster"];
|
|
||||||
|
|
||||||
let color = d3.scaleSequential(d3.interpolateSpectral); // default color scheme
|
let color = d3.scaleSequential(d3.interpolateSpectral); // default color scheme
|
||||||
const lineGen = d3.line().curve(d3.curveBasis); // d3 line generator with default curve interpolation
|
const lineGen = d3.line().curve(d3.curveBasis); // d3 line generator with default curve interpolation
|
||||||
|
|
@ -2057,14 +2056,6 @@ function addZones(number = 1) {
|
||||||
TIME && console.timeEnd("addZones");
|
TIME && console.timeEnd("addZones");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update zone types
|
|
||||||
function updateZoneType(zoneId, newType) {
|
|
||||||
const zone = document.getElementById(zoneId);
|
|
||||||
if (zone) {
|
|
||||||
zone.dataset.type = newType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// show map stats on generation complete
|
// show map stats on generation complete
|
||||||
function showStatistics() {
|
function showStatistics() {
|
||||||
const heightmap = byId("templateInput").value;
|
const heightmap = byId("templateInput").value;
|
||||||
|
|
|
||||||
|
|
@ -884,6 +884,10 @@ function parseLoadedData(data) {
|
||||||
// v1.73 moved the hatching patterns out of the user's SVG
|
// v1.73 moved the hatching patterns out of the user's SVG
|
||||||
document.getElementById("hatching")?.remove();
|
document.getElementById("hatching")?.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version < 1.731) {
|
||||||
|
// v1.731 added type to zones
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
void (function checkDataIntegrity() {
|
void (function checkDataIntegrity() {
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@ function editZones() {
|
||||||
document.getElementById("zonesManuallyApply").addEventListener("click", applyZonesManualAssignent);
|
document.getElementById("zonesManuallyApply").addEventListener("click", applyZonesManualAssignent);
|
||||||
document.getElementById("zonesManuallyCancel").addEventListener("click", cancelZonesManualAssignent);
|
document.getElementById("zonesManuallyCancel").addEventListener("click", cancelZonesManualAssignent);
|
||||||
document.getElementById("zonesAdd").addEventListener("click", addZonesLayer);
|
document.getElementById("zonesAdd").addEventListener("click", addZonesLayer);
|
||||||
document.getElementById("zonesEditTypes").addEventListener("click", addZonesDialog);
|
|
||||||
document.getElementById("zonesNewTypeButton").addEventListener("click", addZonesType);
|
|
||||||
document.getElementById("zonesExport").addEventListener("click", downloadZonesData);
|
document.getElementById("zonesExport").addEventListener("click", downloadZonesData);
|
||||||
document.getElementById("zonesRemove").addEventListener("click", toggleEraseMode);
|
document.getElementById("zonesRemove").addEventListener("click", toggleEraseMode);
|
||||||
|
|
||||||
|
|
@ -54,14 +52,6 @@ function editZones() {
|
||||||
if (el.classList.contains("zoneName")) zone.attr("data-description", el.value);
|
if (el.classList.contains("zoneName")) zone.attr("data-description", el.value);
|
||||||
else if (el.classList.contains("zoneType")) zone.attr("data-type", el.value);
|
else if (el.classList.contains("zoneType")) zone.attr("data-type", el.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
function refreshZonesEditor() {
|
|
||||||
updateSVG();
|
|
||||||
zonesEditorAddLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSVG() {
|
|
||||||
const value = document.getElementById("zonesFilterType").value;
|
|
||||||
|
|
||||||
// update type filter with a list of used types
|
// update type filter with a list of used types
|
||||||
function updateFilters() {
|
function updateFilters() {
|
||||||
|
|
@ -92,7 +82,6 @@ function editZones() {
|
||||||
const rural = d3.sum(c.map(i => pack.cells.pop[i])) * populationRate;
|
const rural = d3.sum(c.map(i => pack.cells.pop[i])) * populationRate;
|
||||||
const urban = d3.sum(c.map(i => pack.cells.burg[i]).map(b => pack.burgs[b].population)) * populationRate * urbanization;
|
const urban = d3.sum(c.map(i => pack.cells.burg[i]).map(b => pack.burgs[b].population)) * populationRate * urbanization;
|
||||||
const population = rural + urban;
|
const population = rural + urban;
|
||||||
const zoneTypeList = getZoneTypesList(this.id, this.dataset.type);
|
|
||||||
const populationTip = `Total population: ${si(population)}; Rural population: ${si(rural)}; Urban population: ${si(urban)}. Click to change`;
|
const populationTip = `Total population: ${si(population)}; Rural population: ${si(rural)}; Urban population: ${si(urban)}. Click to change`;
|
||||||
const inactive = zoneEl.style.display === "none";
|
const inactive = zoneEl.style.display === "none";
|
||||||
const focused = defs.select("#fog #focus" + zoneEl.id).size();
|
const focused = defs.select("#fog #focus" + zoneEl.id).size();
|
||||||
|
|
@ -108,7 +97,6 @@ function editZones() {
|
||||||
<div data-tip="Zone area" class="biomeArea hide">${si(area) + unit}</div>
|
<div data-tip="Zone 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>
|
||||||
<div data-tip="${populationTip}" class="culturePopulation hide">${si(population)}</div>
|
<div data-tip="${populationTip}" class="culturePopulation hide">${si(population)}</div>
|
||||||
${zoneTypeList}
|
|
||||||
<span data-tip="Drag to raise or lower the zone" class="icon-resize-vertical hide"></span>
|
<span data-tip="Drag to raise or lower the zone" class="icon-resize-vertical hide"></span>
|
||||||
<span data-tip="Toggle zone focus" class="icon-pin ${focused ? "" : " inactive"} hide ${c.length ? "" : " placeholder"}"></span>
|
<span data-tip="Toggle zone focus" class="icon-pin ${focused ? "" : " inactive"} hide ${c.length ? "" : " placeholder"}"></span>
|
||||||
<span data-tip="Toggle zone visibility" class="icon-eye ${inactive ? " inactive" : ""} hide ${c.length ? "" : " placeholder"}"></span>
|
<span data-tip="Toggle zone visibility" class="icon-eye ${inactive ? " inactive" : ""} hide ${c.length ? "" : " placeholder"}"></span>
|
||||||
|
|
@ -139,6 +127,8 @@ function editZones() {
|
||||||
$("#zonesEditor").dialog({width: fitContent()});
|
$("#zonesEditor").dialog({width: fitContent()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterZonesByType() {}
|
||||||
|
|
||||||
function zoneHighlightOn(event) {
|
function zoneHighlightOn(event) {
|
||||||
const zone = event.target.dataset.id;
|
const zone = event.target.dataset.id;
|
||||||
zones.select("#" + zone).style("outline", "1px solid red");
|
zones.select("#" + zone).style("outline", "1px solid red");
|
||||||
|
|
@ -375,11 +365,6 @@ function editZones() {
|
||||||
zonesEditorAddLines();
|
zonesEditorAddLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleFilterTable() {
|
|
||||||
this.classList.toggle("pressed");
|
|
||||||
zonesEditorAddLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
function addZonesLayer() {
|
function addZonesLayer() {
|
||||||
const id = getNextId("zone");
|
const id = getNextId("zone");
|
||||||
|
|
@ -487,66 +472,6 @@ function editZones() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function zonesTypesAddLines() {
|
|
||||||
const zoneTypeListBody = document.getElementById("zonesTypesBodySection");
|
|
||||||
|
|
||||||
let lines = "";
|
|
||||||
zoneTypes.forEach(function(z, i) {
|
|
||||||
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="statePopulation">${count}</span>`;
|
|
||||||
if (i > 5) {
|
|
||||||
let id="removeZoneType" + i;
|
|
||||||
lines += `<span data-tip="Remove zone type" class="icon-trash-empty" id="${id}"></span>`;
|
|
||||||
}
|
|
||||||
lines += '</div>';
|
|
||||||
});
|
|
||||||
zoneTypeListBody.innerHTML = lines;
|
|
||||||
zonesTypesFooterNumber.innerHTML = zoneTypes.length;
|
|
||||||
|
|
||||||
for (let i=0; i<zoneTypes.length; i++) {
|
|
||||||
let d = document.getElementById("removeZoneType" + i);
|
|
||||||
if (d) {
|
|
||||||
d.addEventListener("click", function() { removeZoneType(zoneTypes[i]); });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addZonesDialog() {
|
|
||||||
$("#zonesTypes").dialog({
|
|
||||||
title: "Add zones and types",
|
|
||||||
width: fitContent(),
|
|
||||||
position: {my: "center", at: "center", of: "svg"},
|
|
||||||
});
|
|
||||||
zonesTypesAddLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
function addZonesType() {
|
|
||||||
let zoneType = zonesNewTypeInput.value;
|
|
||||||
if (!zoneTypes.includes(zoneType)) { zoneTypes.push(zoneType); }
|
|
||||||
zonesNewTypeInput.value = "";
|
|
||||||
zonesTypesAddLines();
|
|
||||||
zonesTypesFooterNumber.innerHTML = zoneTypes.length;
|
|
||||||
zonesEditorAddLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeZoneType(zoneType) {
|
|
||||||
zones.selectAll("g").each(function () {
|
|
||||||
if (this.dataset.type === zoneType) {
|
|
||||||
this.dataset.type = zoneTypes[0];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i=0; i<zoneTypes.length; i++) {
|
|
||||||
if (zoneTypes[i] === zoneType) {
|
|
||||||
zoneTypes.splice(i, 1);
|
|
||||||
zonesTypesAddLines();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function zoneRemove(zone) {
|
function zoneRemove(zone) {
|
||||||
zones.select("#" + zone).remove();
|
zones.select("#" + zone).remove();
|
||||||
unfog("focusZone" + zone);
|
unfog("focusZone" + zone);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue