aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-01-02 03:36:39 +0100
committer0neGal <mail@0negal.com>2022-01-02 03:36:39 +0100
commit9c4b2aa7bfe2a96354f968c23a98213995242380 (patch)
treec2247f0aa5c5678d49d469fd55c2a9758c043b28 /src/app
parent80eeab10e81a32c00c24608be83e7ea75ff9accf (diff)
downloadViper-9c4b2aa7bfe2a96354f968c23a98213995242380.tar.gz
Viper-9c4b2aa7bfe2a96354f968c23a98213995242380.zip
toggling, removing and installing mods works
Mostly, the installing part needs a bit more look at, to support archives and different layouts for the mod. Such as searching through an archive to find the right folder because some mods don't use a proper layout. I also somewhat mitigated the whole issue of JSON files not being formatted properly by the mod developer (please just fix your formatting, I beg you.) by simply assigning the absolute basics, however we can't know the versions of the mods. I am not going to go out of my way to write code which can parse a file that wasn't made to be parsed because whoever wrote it doesn't know what a JSON file is made of. Simply not happening. I also added a few locatiolization related things, along with more info for --mods, so besides the normal counter for "Installed mods" you also have "Enabled mods" and "Disabled mods", very useful. The GUI also has a new added "Disabled" tag to mods that are disabled, however this is a temporary, it looks bad and I don't want it in release, I just needed a way to distinquish when testing. Because you can now also enable and disable mods, mods.list() gives back an Object that goes more or less something like: {all: ..., enabled: ..., disabled: ... }, take your guesses as to what everything means, you might even get it in the first try.
Diffstat (limited to 'src/app')
-rw-r--r--src/app/main.css8
-rw-r--r--src/app/main.js22
2 files changed, 27 insertions, 3 deletions
diff --git a/src/app/main.css b/src/app/main.css
index c6c9bb9..8776ec9 100644
--- a/src/app/main.css
+++ b/src/app/main.css
@@ -47,11 +47,19 @@ nobr {white-space: nowrap}
}
#modsdiv {
+ padding: 1px;
border-radius: var(--padding);
background: var(--boxbackground);
margin: calc(var(--padding) / 3) var(--padding);
}
+.mod {
+ margin: calc(var(--padding) / 3);
+ border-radius: calc(var(--padding) / 2) !important;
+}
+
+.mod.selected {background: var(--background)}
+
.buttons {
text-align: right;
margin-left: auto;
diff --git a/src/app/main.js b/src/app/main.js
index ab80ba9..c500ba3 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -45,6 +45,18 @@ function setButtons(state) {
}
}
+function select(entry) {
+ let entries = document.querySelectorAll("#modsdiv .mod");
+
+ for (let i = 0; i < entries.length; i++) {
+ if (entries[i].innerHTML == entry) {
+ entries[i].classList.add("selected");
+ } else {
+ entries[i].classList.remove("selected");
+ }
+ }
+}
+
ipcRenderer.on("ns-updated", () => {setButtons(true)})
ipcRenderer.on("ns-updating", () => {setButtons(false)})
@@ -55,10 +67,14 @@ ipcRenderer.on("newpath", (event, newpath) => {
ipcRenderer.on("log", (event, msg) => {log(msg)})
ipcRenderer.on("mods", (event, mods) => {
- modcount.innerHTML = `${lang("gui.mods.count")} ${mods.length}`;
+ modcount.innerHTML = `${lang("gui.mods.count")} ${mods.all.length}`;
modsdiv.innerHTML = "";
- for (let i = 0; i < mods.length; i++) {
- modsdiv.innerHTML += `<div class="mod">${mods[i].Name}</div>`;
+ for (let i = 0; i < mods.enabled.length; i++) {
+ modsdiv.innerHTML += `<div onclick="select('${mods.enabled[i].Name}')" class="mod">${mods.enabled[i].Name}</div>`;
+ }
+
+ for (let i = 0; i < mods.disabled.length; i++) {
+ modsdiv.innerHTML += `<div onclick="select('${mods.disabled[i].Name} - Disabled')" class="mod">${mods.disabled[i].Name} - Disabled</div>`;
}
})