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,6 +298,11 @@ 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;
alertMessage.innerHTML = "Are you sure you want to remove the culture? <br>This action cannot be reverted";
$("#alert").dialog({resizable: false, title: "Remove culture",
buttons: {
Remove: function() {
cults.select("#culture"+culture).remove(); cults.select("#culture"+culture).remove();
debug.select("#cultureCenter"+culture).remove(); debug.select("#cultureCenter"+culture).remove();
@ -308,8 +313,12 @@ function editCultures() {
const origin = pack.cultures[culture].origin; const origin = pack.cultures[culture].origin;
pack.cultures.forEach(c => {if(c.origin === culture) c.origin = origin;}); pack.cultures.forEach(c => {if(c.origin === culture) c.origin = origin;});
refreshCulturesEditor(); 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,6 +365,11 @@ function editProvinces() {
} }
function removeProvince(p) { function removeProvince(p) {
alertMessage.innerHTML = `Are you sure you want to remove the province? <br>This action cannot be reverted`;
$("#alert").dialog({resizable: false, title: "Remove province",
buttons: {
Remove: function() {
pack.cells.province.forEach((province, i) => {if(province === p) pack.cells.province[i] = 0;}); pack.cells.province.forEach((province, i) => {if(province === p) pack.cells.province[i] = 0;});
const state = pack.provinces[p].state; 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); if (pack.states[state].provinces.includes(p)) pack.states[state].provinces.splice(pack.states[state].provinces.indexOf(p), 1);
@ -363,6 +381,13 @@ function editProvinces() {
g.select("#province-gap"+p).remove(); g.select("#province-gap"+p).remove();
if (!layerIsOn("toggleBorders")) toggleBorders(); else drawBorders(); if (!layerIsOn("toggleBorders")) toggleBorders(); else drawBorders();
refreshProvincesEditor(); 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,7 +293,13 @@ function editReligions() {
function religionRemove() { function religionRemove() {
if (customization) return; if (customization) return;
const religion = +this.parentNode.dataset.id; const religion = +this.parentNode.dataset.id;
alertMessage.innerHTML = "Are you sure you want to remove the religion? <br>This action cannot be reverted";
$("#alert").dialog({resizable: false, title: "Remove religion",
buttons: {
Remove: function() {
relig.select("#religion"+religion).remove(); relig.select("#religion"+religion).remove();
relig.select("#religion-gap"+religion).remove();
debug.select("#religionsCenter"+religion).remove(); debug.select("#religionsCenter"+religion).remove();
pack.cells.religion.forEach((r, i) => {if(r === religion) pack.cells.religion[i] = 0;}); pack.cells.religion.forEach((r, i) => {if(r === religion) pack.cells.religion[i] = 0;});
@ -302,6 +308,11 @@ function editReligions() {
pack.religions.forEach(r => {if(r.origin === religion) r.origin = origin;}); pack.religions.forEach(r => {if(r.origin === religion) r.origin = origin;});
refreshReligionsEditor(); refreshReligionsEditor();
$(this).dialog("close");
},
Cancel: function() {$(this).dialog("close");}
}
});
} }
function drawReligionCenters() { function drawReligionCenters() {