aboutsummaryrefslogtreecommitdiff
path: root/src/index.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-01-08 16:49:57 +0100
committerGitHub <noreply@github.com>2022-01-08 16:49:57 +0100
commit61384d15d1fb34511cdb78690b5ec4e2f7d7a7c4 (patch)
treeba786f87cdefd22cd54413517fcfb2359f7f3bae /src/index.js
parent5206e9e4051b5c90e11b3aa331b0f6ee5546d25e (diff)
parent8ad3b0522aee4afc0d7494aaf3927c388752b24c (diff)
downloadViper-61384d15d1fb34511cdb78690b5ec4e2f7d7a7c4.tar.gz
Viper-61384d15d1fb34511cdb78690b5ec4e2f7d7a7c4.zip
Merge pull request #19 from 0neGal/mod-support
Adds mod support, removing, installing and toggling mods, both CLI and GUI
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/index.js b/src/index.js
index 53781dd..09aa626 100644
--- a/src/index.js
+++ b/src/index.js
@@ -38,6 +38,12 @@ function start() {
ipcMain.on("ns-updated", () => {win.webContents.send("ns-updated")})
ipcMain.on("ns-updating", () => {win.webContents.send("ns-updating")})
ipcMain.on("winLog", (event, ...args) => {win.webContents.send("log", ...args)})
+ ipcMain.on("winAlert", (event, ...args) => {win.webContents.send("alert", ...args)})
+ ipcMain.on("guigetmods", (event, ...args) => {win.webContents.send("mods", utils.mods.list())})
+
+ win.webContents.once("dom-ready", () => {
+ win.webContents.send("mods", utils.mods.list());
+ });
if (utils.settings.autoupdate) {utils.updatevp(false)}
@@ -48,9 +54,21 @@ function start() {
ipcMain.on("updatenow", () => {
autoUpdater.quitAndInstall();
})
-
}
+ipcMain.on("installmod", () => {
+ if (cli.hasArgs()) {
+ utils.mods.install(cli.param("installmod"))
+ } else {
+ dialog.showOpenDialog({properties: ["openFile"]}).then(res => {
+ utils.mods.install(res.filePaths[0]);
+ }).catch(err => {console.error(err)})
+ }
+})
+
+ipcMain.on("removemod", (event, mod) => {utils.mods.remove(mod)})
+ipcMain.on("togglemod", (event, mod) => {utils.mods.toggle(mod)})
+
ipcMain.on("launch", (event) => {utils.launch()})
ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)})
ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")})
@@ -64,6 +82,7 @@ ipcMain.on("setpath", (event, value) => {
win.show();
}
});
+
ipcMain.on("newpath", (event, newpath) => {
if (newpath === false && !win.isVisible()) {
win.webContents.send("nopathselected");
@@ -91,6 +110,28 @@ ipcMain.on("versioncli", () => {
cli.exit();
})
+ipcMain.on("getmods", (event) => {
+ let mods = utils.mods.list();
+ if (mods.all.length > 0) {
+ console.log(`${utils.lang("general.mods.installed")} ${mods.all.length}`)
+ console.log(`${utils.lang("general.mods.enabled")} ${mods.enabled.length}`)
+ for (let i = 0; i < mods.enabled.length; i++) {
+ console.log(` ${mods.enabled[i].Name} ${mods.enabled[i].Version}`)
+ }
+
+ if (mods.disabled.length > 0) {
+ console.log(`${utils.lang("general.mods.disabled")} ${mods.disabled.length}`)
+ for (let i = 0; i < mods.disabled.length; i++) {
+ console.log(` ${mods.disabled[i].Name} ${mods.disabled[i].Version}`)
+ }
+ }
+ cli.exit(0);
+ } else {
+ console.log("No mods installed");
+ cli.exit(0);
+ }
+})
+
process.chdir(app.getPath("appData"));
if (cli.hasArgs()) {