Skip to content

Commit

Permalink
add load all mod map button
Browse files Browse the repository at this point in the history
  • Loading branch information
cff29546 committed May 7, 2024
1 parent 8ae1228 commit 4c8538b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions html/pzmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ var UI_HTML = {
</p>`,

map: `
<button id="toggle_all_maps" type="button" onclick="toggleAllMaps()">Load All</button>
<select id="map_selector" onchange="onMapSelect()">
<option value="">(Select Mod Map to Load)</option>
</select>
Expand Down Expand Up @@ -483,6 +484,27 @@ function addMap(name) {
}
}

function toggleAllMaps() {
if (mapui) {
if (mod_maps.length > 0) {
for (pos = 0; pos < mod_maps.length; pos++) {
mod_maps[pos].destroy();
}
mod_maps = [];
document.getElementById("map_btn").classList.remove('active');
updateMapUI();
updateClip();
} else {
let s = document.getElementById('map_selector');
for (let i = 0; i < s.options.length; i++) {
if (s.options[i].value) {
addMap(s.options[i].value);
}
}
}
}
}

function onMapSelect() {
if (mapui) {
let s = document.getElementById('map_selector');
Expand Down Expand Up @@ -1291,6 +1313,14 @@ function toggleModMapUI() {

function updateMapUI() {
if (mapui) {
let btn = document.getElementById("toggle_all_maps");
if (mod_maps.length > 0) {
btn.classList.add('active');
btn.innerText = 'Remove All';
} else {
btn.classList.remove('active');
btn.innerText = 'Load All';
}
d = document.getElementById("map_list");
d.innerHTML = '';
for (let pos = 0; pos < mod_maps.length; pos++) {
Expand Down

0 comments on commit 4c8538b

Please sign in to comment.