Add the basis for locking everything, code and test the culture locking

This commit is contained in:
Guillaume St-Pierre 2022-12-07 21:01:13 -05:00
parent 0b1a2048a7
commit 520551b14c
7 changed files with 130 additions and 10 deletions

View file

@ -212,6 +212,7 @@ function religionsEditorAddLines() {
<div data-tip="Religion area" class="religionArea hide" style="width: 5em">${si(area) + unit}</div>
<span data-tip="${populationTip}" class="icon-male hide"></span>
<div data-tip="${populationTip}" class="religionPopulation hide pointer">${si(population)}</div>
<span data-tip="Lock religion" class="icon-lock${r.lock ? '' : '-open'} hide"></span>
<span data-tip="Remove religion" class="icon-trash-empty hide"></span>
</div>`;
}
@ -242,6 +243,8 @@ function religionsEditorAddLines() {
$body.querySelectorAll("div > span.icon-arrows-cw").forEach(el => el.on("click", regenerateDeity));
$body.querySelectorAll("div > div.religionPopulation").forEach(el => el.on("click", changePopulation));
$body.querySelectorAll("div > span.icon-trash-empty").forEach(el => el.on("click", religionRemovePrompt));
$body.querySelectorAll("div > span.icon-lock").forEach($el => $el.on("click", updateLockStatus));
$body.querySelectorAll("div > span.icon-lock-open").forEach($el => $el.on("click", updateLockStatus));
if ($body.dataset.type === "percentage") {
$body.dataset.type = "absolute";
@ -755,3 +758,21 @@ function closeReligionsEditor() {
exitReligionsManualAssignment("close");
exitAddReligionMode();
}
function updateLockStatus() {
if (customization) return;
const religionId = +this.parentNode.dataset.id;
const classList = this.classList;
const r = pack.religions[religionId];
r.lock = !r.lock;
if (r.lock) {
classList.remove("icon-lock-open");
classList.add("icon-lock");
}
else {
classList.remove("icon-lock");
classList.add("icon-lock-open");
}
}