aboutsummaryrefslogtreecommitdiff
path: root/src/app/main.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-01-27 11:54:36 +0100
committer0neGal <mail@0negal.com>2023-01-28 01:18:45 +0100
commit7fea75e8b064e5ca241a044e6efb3a315b6cd882 (patch)
treeb5b1f67676457c8fef9bff31b2a0f21a114bc5f5 /src/app/main.js
parentfeef5a6c98239a2c08433aec1bbc4e5510a79e32 (diff)
downloadViper-7fea75e8b064e5ca241a044e6efb3a315b6cd882.tar.gz
Viper-7fea75e8b064e5ca241a044e6efb3a315b6cd882.zip
initial draft for redesign of the mod list
The current design for the installed mods is not exactly the best. And it has been due for a redesign for quite a while, I'm finally starting work on this.
Diffstat (limited to 'src/app/main.js')
-rw-r--r--src/app/main.js87
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