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

@ -153,6 +153,7 @@ function addListeners() {
else if (classList.contains("statePopulation")) changePopulation(stateId);
else if (classList.contains("icon-pin")) toggleFog(stateId, classList);
else if (classList.contains("icon-trash-empty")) stateRemovePrompt(stateId);
else if (classList.contains("icon-lock") || classList.contains("icon-lock-open")) updateLockStatus(stateId, classList);
});
$body.on("input", function (ev) {
@ -288,6 +289,7 @@ function statesEditorAddLines() {
<span data-tip="Cells count" class="icon-check-empty ${hidden} show hide"></span>
<div data-tip="Cells count" class="stateCells ${hidden} show hide">${s.cells}</div>
<span data-tip="Toggle state focus" class="icon-pin ${focused ? "" : " inactive"} hide"></span>
<span data-tip="Lock the state" class="icon-lock${s.lock ? '' : '-open'} hide"></span>
<span data-tip="Remove the state" class="icon-trash-empty hide"></span>
</div>`;
}
@ -1362,3 +1364,17 @@ function closeStatesEditor() {
debug.selectAll(".highlight").remove();
$body.innerHTML = "";
}
function updateLockStatus(stateId, classList) {
const s = pack.states[stateId];
s.lock = !s.lock;
if (s.lock) {
classList.remove("icon-lock-open");
classList.add("icon-lock");
}
else {
classList.remove("icon-lock");
classList.add("icon-lock-open");
}
}