diff options
author | 0neGal <mail@0negal.com> | 2022-05-30 22:48:39 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2022-05-30 23:02:50 +0200 |
commit | 1c06ab53f1cf2228e1034a66538f3a31a14e3743 (patch) | |
tree | e90234803990e3562d6e3c522fed721a25e7baef /src/index.js | |
parent | 451f1709cbdf0caa20c01ec533b96832ba9aa822 (diff) | |
download | Viper-1c06ab53f1cf2228e1034a66538f3a31a14e3743.tar.gz Viper-1c06ab53f1cf2228e1034a66538f3a31a14e3743.zip |
refactored event names
Quite a lot of them aren't in the same syntax/style, and it's quite bad
to look at, this should fix them all without causing issues.
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/index.js b/src/index.js index 37ea11e..96976b7 100644 --- a/src/index.js +++ b/src/index.js @@ -51,18 +51,18 @@ function start() { ipcMain.on("relaunch", () => {app.relaunch();app.exit()}); // passthrough to renderer from main - ipcMain.on("winLog", (event, ...args) => {send("log", ...args)}); - ipcMain.on("winAlert", (event, ...args) => {send("alert", ...args)}); + ipcMain.on("win-log", (event, ...args) => {send("log", ...args)}); + ipcMain.on("win-alert", (event, ...args) => {send("alert", ...args)}); // mod states - ipcMain.on("failedmod", (event, modname) => {send("failedmod", modname)}); - ipcMain.on("removedmod", (event, modname) => {send("removedmod", modname)}); - ipcMain.on("guigetmods", (event, ...args) => {send("mods", utils.mods.list())}); - ipcMain.on("installedmod", (event, modname) => {send("installedmod", modname)}); + ipcMain.on("failed-mod", (event, modname) => {send("failed-mod", modname)}); + ipcMain.on("removed-mod", (event, modname) => {send("removed-mod", modname)}); + ipcMain.on("gui-getmods", (event, ...args) => {send("mods", utils.mods.list())}); + ipcMain.on("installed-mod", (event, modname) => {send("installed-mod", modname)}); // install calls - ipcMain.on("installfrompath", (event, path) => {utils.mods.install(path)}); - ipcMain.on("installfromurl", (event, url) => {utils.mods.installFromURL(url)}); + ipcMain.on("install-from-path", (event, path) => {utils.mods.install(path)}); + ipcMain.on("install-from-url", (event, url) => {utils.mods.installFromURL(url)}); win.webContents.on("dom-ready", () => { send("mods", utils.mods.list()); @@ -70,14 +70,14 @@ function start() { // ensures gamepath still exists and is valid on startup let gamepathlost = false; - ipcMain.on("gamepathlost", (event, ...args) => { + ipcMain.on("gamepath-lost", (event, ...args) => { if (! gamepathlost) { gamepathlost = true; - send("gamepathlost"); + send("gamepath-lost"); } }); - ipcMain.on("savesettings", (event, obj) => {utils.saveSettings(obj)}); + ipcMain.on("save-settings", (event, obj) => {utils.saveSettings(obj)}); // allows renderer to check for updates ipcMain.on("ns-update-event", (event) => {send("ns-update-event", event)}); @@ -99,19 +99,19 @@ function start() { } autoUpdater.on("update-downloaded", () => { - send("updateavailable"); + send("update-available"); }); // updates and restarts Viper, if user says yes to do so. // otherwise it'll do it on the next start up. - ipcMain.on("updatenow", () => { + ipcMain.on("update-now", () => { autoUpdater.quitAndInstall(); }) } // General events used to handle utils.js stuff without requiring the // module inside the file that sent the event. { -ipcMain.on("installmod", () => { +ipcMain.on("install-mod", () => { if (cli.hasArgs()) { utils.mods.install(cli.param("installmod")); } else { @@ -119,22 +119,22 @@ ipcMain.on("installmod", () => { if (res.filePaths.length != 0) { utils.mods.install(res.filePaths[0]); } else { - send("setbuttons", true); + send("set-buttons", true); } }).catch(err => {error(err)}); } }) -ipcMain.on("removemod", (event, mod) => {utils.mods.remove(mod)}); -ipcMain.on("togglemod", (event, mod) => {utils.mods.toggle(mod)}); +ipcMain.on("remove-mod", (event, mod) => {utils.mods.remove(mod)}); +ipcMain.on("toggle-mod", (event, mod) => {utils.mods.toggle(mod)}); -ipcMain.on("launch", () => {utils.launch()}); -ipcMain.on("launchVanilla", () => {utils.launch("vanilla")}); +ipcMain.on("launch-ns", () => {utils.launch()}); +ipcMain.on("launch-vanilla", () => {utils.launch("vanilla")}); ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)}); ipcMain.on("update", () => {utils.update()}) -ipcMain.on("setpathcli", () => {utils.setpath()}); +ipcMain.on("setpath-cli", () => {utils.setpath()}); ipcMain.on("setpath", (event, value) => { if (! value) { if (! win.isVisible()) { @@ -157,10 +157,10 @@ function sendVersionsInfo() { } // sends the version info back to the renderer -ipcMain.on("getversion", () => {sendVersionsInfo()}); +ipcMain.on("get-version", () => {sendVersionsInfo()}); // prints out version info for the CLI -ipcMain.on("versioncli", () => { +ipcMain.on("version-cli", () => { log("Viper: v" + require("../package.json").version); log("Northstar: " + utils.getNSVersion()); log("Node: " + process.version); @@ -168,6 +168,7 @@ ipcMain.on("versioncli", () => { cli.exit(); }) +// sends installed mods info to renderer ipcMain.on("getmods", () => { let mods = utils.mods.list(); if (mods.all.length > 0) { @@ -191,17 +192,18 @@ ipcMain.on("getmods", () => { }) // } +// allows renderer to set a new renderer ipcMain.on("newpath", (event, newpath) => { - if (newpath === false && !win.isVisible()) { - win.send("nopathselected"); + if (newpath === false && ! win.isVisible()) { + win.send("no-path-selected"); } else { _sendVersionsInfo(); if (!win.isVisible()) { win.show(); } } -}); ipcMain.on("wrongpath", () => { - win.send("wrongpath"); +}); ipcMain.on("wrong-path", () => { + win.send("wrong-path"); }); // ensures PWD/CWD is the config folder where viper.json is located |