mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
lock all burgs - optimization
This commit is contained in:
parent
f3d3538ff5
commit
18acadfd80
2 changed files with 16 additions and 37 deletions
|
|
@ -3287,7 +3287,7 @@
|
||||||
<button id="addNewBurg" data-tip="Add a new burg. Hold Shift to add multiple" class="icon-plus"></button>
|
<button id="addNewBurg" data-tip="Add a new burg. Hold Shift to add multiple" class="icon-plus"></button>
|
||||||
<button id="burgsExport" data-tip="Save burgs-related data as a text file (.csv)" class="icon-download"></button>
|
<button id="burgsExport" data-tip="Save burgs-related data as a text file (.csv)" class="icon-download"></button>
|
||||||
<button id="burgNamesImport" data-tip="Rename burgs in bulk" class="icon-upload"></button>
|
<button id="burgNamesImport" data-tip="Rename burgs in bulk" class="icon-upload"></button>
|
||||||
<button id="burgsLockAll" data-tip="Lock / Unlock all burgs" class="icon-lock"></button>
|
<button id="burgsLockAll" data-tip="Lock or unlock all burgs" class="icon-lock"></button>
|
||||||
<button id="burgsRemoveAll" data-tip="Remove all unlocked burgs except for capitals. To remove a capital remove its state first" class="icon-trash"></button>
|
<button id="burgsRemoveAll" data-tip="Remove all unlocked burgs except for capitals. To remove a capital remove its state first" class="icon-trash"></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ function overviewBurgs() {
|
||||||
|
|
||||||
const body = document.getElementById("burgsBody");
|
const body = document.getElementById("burgsBody");
|
||||||
updateFilter();
|
updateFilter();
|
||||||
|
updateLockAllIcon();
|
||||||
burgsOverviewAddLines();
|
burgsOverviewAddLines();
|
||||||
setLockIcon();
|
|
||||||
$("#burgsOverview").dialog();
|
$("#burgsOverview").dialog();
|
||||||
|
|
||||||
if (modules.overviewBurgs) return;
|
if (modules.overviewBurgs) return;
|
||||||
|
|
@ -34,8 +34,7 @@ function overviewBurgs() {
|
||||||
document.getElementById("burgsListToLoad").addEventListener("change", function () {
|
document.getElementById("burgsListToLoad").addEventListener("change", function () {
|
||||||
uploadFile(this, importBurgNames);
|
uploadFile(this, importBurgNames);
|
||||||
});
|
});
|
||||||
document.getElementById("burgsLockAll").addEventListener("click", setLockBurgs);
|
document.getElementById("burgsLockAll").addEventListener("click", toggleLockAll);
|
||||||
document.getElementById("burgsLockAll").addEventListener("click", setLockIcon);
|
|
||||||
document.getElementById("burgsRemoveAll").addEventListener("click", triggerAllBurgsRemove);
|
document.getElementById("burgsRemoveAll").addEventListener("click", triggerAllBurgsRemove);
|
||||||
document.getElementById("burgsInvertLock").addEventListener("click", invertLock);
|
document.getElementById("burgsInvertLock").addEventListener("click", invertLock);
|
||||||
|
|
||||||
|
|
@ -565,41 +564,21 @@ function overviewBurgs() {
|
||||||
pack.burgs = pack.burgs.map(burg => ({...burg, lock: !burg.lock}));
|
pack.burgs = pack.burgs.map(burg => ({...burg, lock: !burg.lock}));
|
||||||
burgsOverviewAddLines();
|
burgsOverviewAddLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
function lockAllBurgs() {
|
function toggleLockAll() {
|
||||||
pack.burgs.forEach(burg => {
|
const activeBurgs = pack.burgs.filter(b => b.i && !b.removed);
|
||||||
burg.lock = true;
|
const allLocked = activeBurgs.every(burg => burg.lock);
|
||||||
});
|
|
||||||
|
pack.burgs.forEach(burg => {
|
||||||
|
burg.lock = !allLocked;
|
||||||
|
});
|
||||||
|
|
||||||
burgsOverviewAddLines();
|
burgsOverviewAddLines();
|
||||||
|
document.getElementById("burgsLockAll").className = allLocked ? "icon-lock" : "icon-lock-open";
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlockAllBurgs() {
|
function updateLockAllIcon() {
|
||||||
pack.burgs.forEach(burg => {
|
|
||||||
burg.lock = false;
|
|
||||||
});
|
|
||||||
burgsOverviewAddLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setLockBurgs() {
|
|
||||||
const allLocked = pack.burgs.every(({lock, i, removed}) => lock || !i || removed);
|
const allLocked = pack.burgs.every(({lock, i, removed}) => lock || !i || removed);
|
||||||
|
document.getElementById("burgsLockAll").className = allLocked ? "icon-lock-open" : "icon-lock";
|
||||||
if (allLocked) {
|
|
||||||
unlockAllBurgs();
|
|
||||||
} else {
|
|
||||||
lockAllBurgs();
|
|
||||||
}
|
|
||||||
setLockIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setLockIcon() {
|
|
||||||
const allLocked = pack.burgs.every(({lock, i, removed}) => lock || !i || removed);
|
|
||||||
|
|
||||||
if (allLocked) {
|
|
||||||
burgsLockAll.classList.remove("icon-lock");
|
|
||||||
burgsLockAll.classList.add("icon-lock-open");
|
|
||||||
} else {
|
|
||||||
burgsLockAll.classList.add("icon-lock");
|
|
||||||
burgsLockAll.classList.remove("icon-lock-open");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue