This commit is contained in:
Azgaar 2020-03-31 00:39:28 +03:00
parent 74ea22fc87
commit 498ab097f9
4 changed files with 76 additions and 31 deletions

View file

@ -97,7 +97,7 @@ function editBiomes() {
<div data-tip="Biome area" class="biomeArea hide">${si(area) + unit}</div> <div data-tip="Biome 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="biomePopulation hide">${si(population)}</div> <div data-tip="${populationTip}" class="biomePopulation hide">${si(population)}</div>
<span data-tip="Open Wikipedia articale about the biome" class="icon-info-circled pointer hide"></span> <span data-tip="Open Wikipedia article about the biome" class="icon-info-circled pointer hide"></span>
${i>12 && !b.cells[i] ? '<span data-tip="Remove the custom biome" class="icon-trash-empty hide"></span>' : ''} ${i>12 && !b.cells[i] ? '<span data-tip="Remove the custom biome" class="icon-trash-empty hide"></span>' : ''}
</div>`; </div>`;
} }

View file

@ -298,18 +298,27 @@ function editCultures() {
function cultureRemove() { function cultureRemove() {
if (customization === 4) return; if (customization === 4) return;
const culture = +this.parentNode.dataset.id; const culture = +this.parentNode.dataset.id;
cults.select("#culture"+culture).remove();
debug.select("#cultureCenter"+culture).remove();
pack.burgs.filter(b => b.culture == culture).forEach(b => b.culture = 0); alertMessage.innerHTML = "Are you sure you want to remove the culture? <br>This action cannot be reverted";
pack.states.forEach((s, i) => {if(s.culture === culture) s.culture = 0;}); $("#alert").dialog({resizable: false, title: "Remove culture",
pack.cells.culture.forEach((c, i) => {if(c === culture) pack.cells.culture[i] = 0;}); buttons: {
pack.cultures[culture].removed = true; Remove: function() {
cults.select("#culture"+culture).remove();
debug.select("#cultureCenter"+culture).remove();
const origin = pack.cultures[culture].origin; pack.burgs.filter(b => b.culture == culture).forEach(b => b.culture = 0);
pack.cultures.forEach(c => {if(c.origin === culture) c.origin = origin;}); pack.states.forEach((s, i) => {if(s.culture === culture) s.culture = 0;});
pack.cells.culture.forEach((c, i) => {if(c === culture) pack.cells.culture[i] = 0;});
pack.cultures[culture].removed = true;
refreshCulturesEditor(); const origin = pack.cultures[culture].origin;
pack.cultures.forEach(c => {if(c.origin === culture) c.origin = origin;});
refreshCulturesEditor();
$(this).dialog("close");
},
Cancel: function() {$(this).dialog("close");}
}
});
} }
function drawCultureCenters() { function drawCultureCenters() {

View file

@ -39,7 +39,7 @@ function editProvinces() {
if (cl.contains("name")) editProvinceName(p); else if (cl.contains("name")) editProvinceName(p); else
if (cl.contains("icon-coa")) provinceOpenCOA(ev, p); else if (cl.contains("icon-coa")) provinceOpenCOA(ev, 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")) declareProvinceIndependence(p); else if (cl.contains("icon-flag-empty")) triggerIndependencePromps(p); else
if (cl.contains("culturePopulation")) changePopulation(p); else if (cl.contains("culturePopulation")) changePopulation(p); else
if (cl.contains("icon-pin")) focusOn(p, cl); else if (cl.contains("icon-pin")) focusOn(p, cl); else
if (cl.contains("icon-trash-empty")) removeProvince(p); if (cl.contains("icon-trash-empty")) removeProvince(p);
@ -211,6 +211,19 @@ function editProvinces() {
zoomTo(x, y, 8, 2000); zoomTo(x, y, 8, 2000);
} }
function triggerIndependencePromps(p) {
alertMessage.innerHTML = "Are you sure you want to declare province independence? <br>It will turn province into a new state";
$("#alert").dialog({resizable: false, title: "Declare independence",
buttons: {
Declare: function() {
declareProvinceIndependence(p);
$(this).dialog("close");
},
Cancel: function() {$(this).dialog("close");}
}
});
}
function declareProvinceIndependence(p) { function declareProvinceIndependence(p) {
const states = pack.states, provinces = pack.provinces, cells = pack.cells; const states = pack.states, provinces = pack.provinces, cells = pack.cells;
const oldState = pack.provinces[p].state; const oldState = pack.provinces[p].state;
@ -352,17 +365,29 @@ function editProvinces() {
} }
function removeProvince(p) { function removeProvince(p) {
pack.cells.province.forEach((province, i) => {if(province === p) pack.cells.province[i] = 0;});
const state = pack.provinces[p].state;
if (pack.states[state].provinces.includes(p)) pack.states[state].provinces.splice(pack.states[state].provinces.indexOf(p), 1);
pack.provinces[p].removed = true;
unfocus(p);
const g = provs.select("#provincesBody"); alertMessage.innerHTML = `Are you sure you want to remove the province? <br>This action cannot be reverted`;
g.select("#province"+p).remove(); $("#alert").dialog({resizable: false, title: "Remove province",
g.select("#province-gap"+p).remove(); buttons: {
if (!layerIsOn("toggleBorders")) toggleBorders(); else drawBorders(); Remove: function() {
refreshProvincesEditor(); pack.cells.province.forEach((province, i) => {if(province === p) pack.cells.province[i] = 0;});
const state = pack.provinces[p].state;
if (pack.states[state].provinces.includes(p)) pack.states[state].provinces.splice(pack.states[state].provinces.indexOf(p), 1);
pack.provinces[p].removed = true;
unfocus(p);
const g = provs.select("#provincesBody");
g.select("#province"+p).remove();
g.select("#province-gap"+p).remove();
if (!layerIsOn("toggleBorders")) toggleBorders(); else drawBorders();
refreshProvincesEditor();
$(this).dialog("close");
},
Cancel: function() {$(this).dialog("close");}
}
});
} }
function editProvinceName(province) { function editProvinceName(province) {
@ -804,7 +829,7 @@ function editProvinces() {
} }
function removeAllProvinces() { function removeAllProvinces() {
alertMessage.innerHTML = `Are you sure you want to remove all provinces?`; alertMessage.innerHTML = `Are you sure you want to remove all provinces? <br>This action cannot be reverted`;
$("#alert").dialog({resizable: false, title: "Remove all provinces", $("#alert").dialog({resizable: false, title: "Remove all provinces",
buttons: { buttons: {
Remove: function() { Remove: function() {

View file

@ -293,15 +293,26 @@ function editReligions() {
function religionRemove() { function religionRemove() {
if (customization) return; if (customization) return;
const religion = +this.parentNode.dataset.id; const religion = +this.parentNode.dataset.id;
relig.select("#religion"+religion).remove();
debug.select("#religionsCenter"+religion).remove();
pack.cells.religion.forEach((r, i) => {if(r === religion) pack.cells.religion[i] = 0;}); alertMessage.innerHTML = "Are you sure you want to remove the religion? <br>This action cannot be reverted";
pack.religions[religion].removed = true; $("#alert").dialog({resizable: false, title: "Remove religion",
const origin = pack.religions[religion].origin; buttons: {
pack.religions.forEach(r => {if(r.origin === religion) r.origin = origin;}); Remove: function() {
relig.select("#religion"+religion).remove();
relig.select("#religion-gap"+religion).remove();
debug.select("#religionsCenter"+religion).remove();
refreshReligionsEditor(); pack.cells.religion.forEach((r, i) => {if(r === religion) pack.cells.religion[i] = 0;});
pack.religions[religion].removed = true;
const origin = pack.religions[religion].origin;
pack.religions.forEach(r => {if(r.origin === religion) r.origin = origin;});
refreshReligionsEditor();
$(this).dialog("close");
},
Cancel: function() {$(this).dialog("close");}
}
});
} }
function drawReligionCenters() { function drawReligionCenters() {