diff options
Diffstat (limited to 'src/app/main.js')
-rw-r--r-- | src/app/main.js | 87 |
1 files changed, 4 insertions, 83 deletions
diff --git a/src/app/main.js b/src/app/main.js index 50160d0..5ac07de 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -157,69 +157,6 @@ ipcRenderer.on("unknown-error", (event, err) => { console.error(err.stack) }) -let lastselected = ""; -function select(entry) { - let entries = document.querySelectorAll("#modsdiv .mod .modtext"); - - for (let i = 0; i < entries.length; i++) { - if (entries[i].innerHTML == entry) { - lastselected = entry; - entries[i].parentElement.classList.add("selected"); - } else { - entries[i].parentElement.classList.remove("selected"); - } - } -} - -// Mod selection -function selected(all) { - let selected = ""; - if (all) { - selected = "allmods" - } else { - selected = document.querySelector(".mod.selected .modtext"); - if (selected != null) { - selected = selected.innerHTML; - } else { - alert(lang("gui.mods.nothingselected")); - return { - remove: () => {}, - toggle: () => {}, - } - } - } - - return { - remove: () => { - - if (selected.match(/^Northstar\./)) { - if (! confirm(lang("gui.mods.required.confirm"))) { - return; - } - } else if (selected == "allmods") { - if (! confirm(lang("gui.mods.removeall.confirm"))) { - return; - } - } - - ipcRenderer.send("remove-mod", selected); - }, - toggle: () => { - if (selected.match(/^Northstar\./)) { - if (! confirm(lang("gui.mods.required.confirm"))) { - return; - } - } else if (selected == "allmods") { - if (! confirm(lang("gui.mods.toggleall.confirm"))) { - return; - } - } - - ipcRenderer.send("toggle-mod", selected); - } - } -} - let installqueue = []; // Tells the main process to install a mod through the file selector @@ -302,27 +239,11 @@ ipcRenderer.on("log", (event, msg) => {log(msg)}) ipcRenderer.on("alert", (event, msg) => {alert(msg)}) // Updates the installed mods -ipcRenderer.on("mods", (event, mods) => { - modsobj = mods; - if (! mods) {return} - - modcount.innerHTML = `${lang("gui.mods.count")} ${mods.all.length}`; - modsdiv.innerHTML = ""; - - let newmod = (name, disabled) => { - if (disabled) { - disabled = `<span class="disabled">${lang("gui.mods.disabledtag")}</span>` - } else { - disabled = "" - } - - modsdiv.innerHTML += `<div onclick="select('${name}')" class="mod"><span class="modtext">${name}</span>${disabled}</div>`; - } - - for (let i = 0; i < mods.enabled.length; i++) {newmod(mods.enabled[i].Name)} - for (let i = 0; i < mods.disabled.length; i++) {newmod(mods.disabled[i].Name, " - Disabled")} +ipcRenderer.on("mods", (event, mods_obj) => { + modsobj = mods_obj; + if (! mods_obj) {return} - select(lastselected); + mods.load(mods_obj); }) // Updates version numbers |