aboutsummaryrefslogtreecommitdiff
path: root/src/utils.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-01-03 00:43:45 +0100
committer0neGal <mail@0negal.com>2022-01-03 00:43:45 +0100
commitbf7bd0993714f20fd0ab360de956378113e1d9c2 (patch)
tree9ba692562f64ed86151617756cfd214e57c8b25d /src/utils.js
parent9c4b2aa7bfe2a96354f968c23a98213995242380 (diff)
downloadViper-bf7bd0993714f20fd0ab360de956378113e1d9c2.tar.gz
Viper-bf7bd0993714f20fd0ab360de956378113e1d9c2.zip
fully working GUI functionality
Smoothly updates and works flawlessly, the only thing that really needs improvements is the design and on top of that installing mods from a Zip file over folder.
Diffstat (limited to 'src/utils.js')
-rw-r--r--src/utils.js38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/utils.js b/src/utils.js
index 88e5f3a..ef8b586 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -117,6 +117,7 @@ function update() {
}
}
+ ipcMain.emit("guigetmods");
ipcMain.emit("ns-updated");
winLog(lang("gui.update.finished"));
console.log(lang("cli.update.finished"));
@@ -194,7 +195,7 @@ const mods = {
disabled.push({...require(path.join(disabledPath, file, "mod.json")), FolderName: file, Disabled: true})
}catch(err) {
console.log("error: " + lang("cli.mods.improperjson"), file)
- disabled.push({Name: file, FolderName: file, Version: "unknown", Disabled: false})
+ disabled.push({Name: file, FolderName: file, Version: "unknown", Disabled: true})
}
}
}
@@ -220,15 +221,13 @@ const mods = {
install: (mod) => {
if (fs.statSync(mod).isDirectory()) {
if (fs.statSync(path.join(mod, "mod.json"))) {
- copy(mod, path.join(modpath, mod.replace(/^.*(\\|\/|\:)/, "")), {
+ copy.sync(mod, path.join(modpath, mod.replace(/^.*(\\|\/|\:)/, "")), {
mode: true,
cover: true,
utimes: true,
- }, (err) => {
- if(err) {console.log("error:", err)};
- console.log();
});
cli.exit();
+ ipcMain.emit("guigetmods");
return
} else {
console.log("error: " + lang("cli.mods.notamod"))
@@ -240,19 +239,47 @@ const mods = {
fs.createReadStream(mod).pipe(unzip.Extract({path: modpath}))
.on("finish", () => {
cli.exit();
+ ipcMain.emit("guigetmods");
});
},
remove: (mod) => {
+ if (mod == "allmods") {
+ let modlist = mods.list().all;
+ for (let i = 0; i < modlist.length; i++) {
+ mods.remove(modlist[i].Name)
+ }
+ return
+ }
+
+ let disabled = path.join(modpath, "disabled");
+ if (! fs.existsSync(disabled)) {
+ fs.mkdirSync(disabled)
+ }
+
let modName = mods.get(mod).FolderName;
let modPath = path.join(modpath, modName);
+
+ if (mods.get(mod).Disabled) {
+ modPath = path.join(disabled, modName);
+ }
+
if (fs.statSync(modPath).isDirectory()) {
fs.rmSync(modPath, {recursive: true});
cli.exit();
+ ipcMain.emit("guigetmods");
} else {
cli.exit(1);
}
},
toggle: (mod) => {
+ if (mod == "allmods") {
+ let modlist = mods.list().all;
+ for (let i = 0; i < modlist.length; i++) {
+ mods.toggle(modlist[i].Name)
+ }
+ return
+ }
+
let disabled = path.join(modpath, "disabled");
if (! fs.existsSync(disabled)) {
fs.mkdirSync(disabled)
@@ -268,6 +295,7 @@ const mods = {
}
fs.moveSync(modPath, dest)
+ ipcMain.emit("guigetmods");
}
};