diff options
author | 0neGal <mail@0negal.com> | 2023-03-05 00:25:07 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-03-05 00:38:53 +0100 |
commit | 5d86a3daa5f762326055469b6bcd8346e0655056 (patch) | |
tree | 110fb1395fac1510dc3bf70f39f073df555445ff /src/index.js | |
parent | 4536aad2c4f19d32569d84a7082e8636a2be6985 (diff) | |
download | Viper-5d86a3daa5f762326055469b6bcd8346e0655056.tar.gz Viper-5d86a3daa5f762326055469b6bcd8346e0655056.zip |
modularized many functions and got rid of utils.js
Notably, winLog() and winAlert() are now win.log() and win.alert()
inside modules/window.js.
updateViper(), updateNorthstar and handleNorthstarUpdating() are now
update.viper(), update.northstar() and update.northstar_autoupdate(),
inside modules/update.js
isGameRunning() and isOriginRunning() are now is_running.origin() and
is_running.game() inside modules/is_running.js, along with a
.titanfall() and .northstar() for more specificity. Not used anywhere
right now, but may in the future be used.
setpath() and gamepathExists() are now gamepath.set() and
gamepath.exists() inside modules/gamepath.js
killOrigin() are now kill.origin() inside modules/kill.js
setlang() is now just inlined into the only event where it's used.
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/index.js b/src/index.js index 991717b..88e3ed9 100644 --- a/src/index.js +++ b/src/index.js @@ -6,11 +6,14 @@ const { app, ipcMain, BrowserWindow, dialog } = require("electron"); // ensures PWD/CWD is the config folder where viper.json is located process.chdir(app.getPath("appData")); -const utils = require("./utils"); const cli = require("./cli"); const json = require("./modules/json"); +const kill = require("./modules/kill"); const mods = require("./modules/mods"); +const update = require("./modules/update"); +const launch = require("./modules/launch"); const version = require("./modules/version"); +const gamepath = require("./modules/gamepath"); const settings = require("./modules/settings"); const requests = require("./modules/requests"); @@ -61,7 +64,7 @@ function start() { if (settings.originkill) { utils.isOriginRunning().then((running) => { if (running) { - utils.killOrigin().then(process.exit(0)) + kill.origin().then(process.exit(0)) } else { process.exit(0) } @@ -120,12 +123,12 @@ function start() { // start auto-update process if (settings.autoupdate) { if (cli.hasParam("no-vp-updates")) { - utils.handleNorthstarUpdating(); + update.northstar_autoupdate(); } else { - utils.updateViper(false) + update.viper(false) } } else { - utils.handleNorthstarUpdating(); + update.northstar_autoupdate(); } autoUpdater.on("update-downloaded", () => { @@ -158,19 +161,22 @@ ipcMain.on("install-mod", () => { ipcMain.on("remove-mod", (event, mod) => {mods.remove(mod)}); ipcMain.on("toggle-mod", (event, mod) => {mods.toggle(mod)}); -ipcMain.on("launch-ns", () => {utils.launch()}); -ipcMain.on("launch-vanilla", () => {utils.launch("vanilla")}); +ipcMain.on("launch-ns", () => {launch()}); +ipcMain.on("launch-vanilla", () => {launch("vanilla")}); -ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)}); +ipcMain.on("setlang", (event, lang) => { + settings.lang = lang; + settings.save(); +}); -ipcMain.on("update-northstar", () => {utils.updateNorthstar()}) -ipcMain.on("setpath-cli", () => {utils.setpath()}); +ipcMain.on("update-northstar", () => {update.northstar()}) +ipcMain.on("setpath-cli", () => {gamepath.set()}); ipcMain.on("setpath", (event, value) => { if (! value) { if (! win.isVisible()) { - utils.setpath(win); + gamepath.set(win); } else { - utils.setpath(win, true); + gamepath.set(win, true); } } else if (! win.isVisible()) { win.show(); @@ -240,7 +246,7 @@ ipcMain.on("newpath", (event, newpath) => { // starts the GUI or CLI if (cli.hasArgs()) { if (cli.hasParam("update-viper")) { - utils.updateViper(true); + update.viper(true); } else { cli.init(); } |