aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-06-12 16:25:01 +0200
committerGitHub <noreply@github.com>2022-06-12 16:25:01 +0200
commitd78c28b6b07de0a4a43a484a4c8baf558596b335 (patch)
treed14f2216ce5f9f71de19caecf9308c7c8bc7c079 /src
parent461ad2c4183f47c089f307e21acc0c2316874243 (diff)
parent0d81e16ccee3ca8afe5a0310fdbe6d708a1424ce (diff)
downloadViper-d78c28b6b07de0a4a43a484a4c8baf558596b335.tar.gz
Viper-d78c28b6b07de0a4a43a484a4c8baf558596b335.zip
Merge pull request #133 from pcbmaster/main
feat: Option to close Origin when Viper exits
Diffstat (limited to 'src')
-rw-r--r--src/app/index.html12
-rw-r--r--src/app/main.js1
-rw-r--r--src/index.js18
-rw-r--r--src/lang/en.json3
-rw-r--r--src/lang/es.json3
-rw-r--r--src/lang/fr.json3
-rw-r--r--src/utils.js70
7 files changed, 97 insertions, 13 deletions
diff --git a/src/app/index.html b/src/app/index.html
index 2305e4c..0255dd6 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -107,6 +107,18 @@
<input type="text">
</div>
</div>
+ <h2>%%gui.settings.title.misc%%</h2>
+ <div class="option" name="originkill">
+ <div class="text">
+ %%gui.settings.originkill.title%%
+ <div class="desc">
+ %%gui.settings.originkill.desc%%
+ </div>
+ </div>
+ <div class="actions">
+ <button class="switch off"></button>
+ </div>
+ </div>
</div>
</div>
diff --git a/src/app/main.js b/src/app/main.js
index 647e5cd..9fb3191 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -14,6 +14,7 @@ var settings = {
autolang: true,
forcedlang: "en",
autoupdate: true,
+ originkill: false,
zip: "/northstar.zip",
lang: navigator.language,
excludes: [
diff --git a/src/index.js b/src/index.js
index 96976b7..2c03529 100644
--- a/src/index.js
+++ b/src/index.js
@@ -33,7 +33,7 @@ function start() {
nodeIntegration: true,
contextIsolation: false,
},
- });
+ });
// when --debug is added it'll open the dev tools
if (cli.hasParam("debug")) {win.openDevTools()}
@@ -46,9 +46,21 @@ function start() {
win.webContents.send(channel, data);
}; send = win.send;
- ipcMain.on("exit", () => {process.exit(0)});
+ ipcMain.on("exit", () => {
+ if (utils.settings.originkill) {
+ utils.isOriginRunning().then((running) => {
+ if (running) {
+ utils.killOrigin().then(process.exit(0))
+ } else {
+ process.exit(0)
+ }
+ })
+ } else {
+ process.exit(0)
+ }
+ });
ipcMain.on("minimize", () => {win.minimize()});
- ipcMain.on("relaunch", () => {app.relaunch();app.exit()});
+ ipcMain.on("relaunch", () => {app.relaunch(); app.exit()});
// passthrough to renderer from main
ipcMain.on("win-log", (event, ...args) => {send("log", ...args)});
diff --git a/src/lang/en.json b/src/lang/en.json
index 34c4619..8cece10 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -91,6 +91,7 @@
"gui.settings.title.ns": "Northstar",
"gui.settings.title.language": "Language",
"gui.settings.title.updates": "Updates",
+ "gui.settings.title.misc": "Miscellaneous",
"gui.settings.nsargs.title": "Launch options",
"gui.settings.nsargs.desc": "Here you can add launch options for Northstar/Titanfall.",
"gui.settings.autolang.title": "Auto-Detect Language",
@@ -103,6 +104,8 @@
"gui.settings.nsupdate.desc": "Viper will automatically keep Northstar up-to-date, however it can still manually be updated through the Northstar page.",
"gui.settings.excludes.title": "Retain files on update",
"gui.settings.excludes.desc": "When Northstar is updated, files specified here will not be overwritten by files from the new Northstar update, unless you know what you're changing, you should probably not change anything here. Each file is separated with a space.",
+ "gui.settings.originkill.title": "Automatically quit Origin",
+ "gui.settings.originkill.desc": "When Viper exits, automatically quit Origin as well.",
"gui.update.downloading": "Downloading...",
"gui.update.extracting": "Extracting update...",
diff --git a/src/lang/es.json b/src/lang/es.json
index 4efa765..c341143 100644
--- a/src/lang/es.json
+++ b/src/lang/es.json
@@ -90,6 +90,7 @@
"gui.settings.discard": "Descartar",
"gui.settings.title.ns": "Northstar",
"gui.settings.title.updates": "Actualizaciones",
+ "gui.settings.title.misc": "Misceláneos",
"gui.settings.nsargs.title": "Opciones de lanzamiento",
"gui.settings.nsargs.desc": "Aqui puedes añadir opciones de lanzamiento para Northstar/Titanfall.",
"gui.settings.autoupdate.title": "Actualizaciones automáticas de Viper",
@@ -98,6 +99,8 @@
"gui.settings.nsupdate.desc": "Viper mantendrá Northstar actualizado automáticamente, sin embargo, todavía se puede actualizar manualmente a través de la sección de Northstar.",
"gui.settings.excludes.title": "Conservar archivos en la actualización",
"gui.settings.excludes.desc": "Cuando se actualice Northstar, los archivos especificados aquí no se sobrescribirán con archivos de la nueva actualización de Northstar. A menos que sepa lo que está cambiando, probablemente no debería cambiar nada aquí. Cada archivo se debe separar con un espacio.",
+ "gui.settings.originkill.title": "Cerrar Origin automáticamente",
+ "gui.settings.originkill.desc": "Cuando Viper se cierra, cerrar automáticamente Origin también.",
"gui.settings.title.language": "Idioma",
"gui.settings.autolang.title": "Detectar automáticamente el idioma",
"gui.settings.autolang.desc": "Cuando está habilitado, Viper intenta detectar automáticamente el idioma de su sistema, cuando está deshabilitado, puede cambiar manualmente el idioma a continuación.",
diff --git a/src/lang/fr.json b/src/lang/fr.json
index 3fba39f..1fde982 100644
--- a/src/lang/fr.json
+++ b/src/lang/fr.json
@@ -91,6 +91,7 @@
"gui.settings.title.ns": "Northstar",
"gui.settings.title.language": "Langue",
"gui.settings.title.updates": "Mises à jour",
+ "gui.settings.title.misc": "Divers",
"gui.settings.nsargs.title": "Options de lancement",
"gui.settings.nsargs.desc": "Vous pouvez ajouter ici des options de démarrage pour Northstar/Titanfall.",
"gui.settings.autolang.title": "Auto-détection de la langue",
@@ -103,6 +104,8 @@
"gui.settings.nsupdate.desc": "Viper tient automatiquement Northstar à jour (n'empêche pas de le mettre à jour manuellement via sa page dédiée).",
"gui.settings.excludes.title": "Fichiers à conserver",
"gui.settings.excludes.desc": "Lorsque Northstar est mis à jour, ces fichiers ne seront pas écrasés par ceux provenant de la mise à jour; les noms de fichiers sont séparés par un espace.",
+ "gui.settings.originkill.title": "Quitter automatiquement Origin",
+ "gui.settings.originkill.desc": "Lorsque Viper est fermé, Origin sera également automatiquement fermé.",
"gui.update.downloading": "Téléchargement de la mise à jour...",
"gui.update.extracting": "Extraction des fichiers...",
diff --git a/src/utils.js b/src/utils.js
index b69a9a2..6114ef1 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -29,6 +29,7 @@ var settings = {
autolang: true,
forcedlang: "en",
autoupdate: true,
+ originkill: false,
nsargs: "-multiple",
zip: "/northstar.zip",
@@ -101,6 +102,47 @@ async function isGameRunning() {
});
}
+// checks if any origin processes are running
+async function isOriginRunning() {
+ return new Promise(resolve => {
+ let procs = ["Origin.exe", "OriginClientService.exe"];
+ let cmd = (() => {
+ switch (process.platform) {
+ case "linux": return "ps -A";
+ case "win32": return "tasklist";
+ }
+ })();
+
+ exec(cmd, (err, stdout) => {
+ procs.forEach(proc => {
+ if (stdout.includes(proc)) {
+ resolve(true);
+ return;
+ }
+ resolve(false);
+ });
+ });
+ });
+}
+
+// kill origin processes
+async function killOrigin() {
+ return new Promise(resolve => {
+ let proc = "Origin.exe"; //I'm pretty sure we only have to kill this one
+ let cmd = (() => {
+ switch (process.platform) {
+ case "linux": return "killall " + proc;
+ case "win32": return "taskkill /IM " + proc + " /F";
+ }
+ })();
+
+ exec(cmd, (err, stdout) => {
+ // just try and fail silently if we don't find it w/e
+ resolve(true);
+ });
+ });
+}
+
// Handles auto updating Northstar.
//
// It uses isGameRunning() to ensure it doesn't run while the game is
@@ -121,7 +163,7 @@ function handleNorthstarUpdating() {
if (await isGameRunning()) {
console.log(lang("cli.autoupdates.gamerunning"));
new Notification({
- title: lang("gui.nsupdate.gaming.title"),
+ title: lang("gui.nsupdate.gaming.title"),
body: lang("gui.nsupdate.gaming.body")
}).show();
} else {
@@ -133,7 +175,7 @@ function handleNorthstarUpdating() {
}
setTimeout(
- _checkForUpdates,
+ _checkForUpdates,
15 * 60 * 1000
// interval in between each update check
// by default 15 minutes.
@@ -290,7 +332,7 @@ async function update() {
} else {
if (version != "unknown") {
console.log(lang("cli.update.current"), version);
- };
+ };
console.log(lang("cli.update.downloading") + ":", latestAvailableVersion);
ipcMain.emit("ns-update-event", "cli.update.downloading");
}
@@ -616,7 +658,7 @@ const mods = {
if (fs.statSync(mod).isDirectory()) {
winLog(lang("gui.mods.installing"));
files = fs.readdirSync(mod);
- if (fs.existsSync(path.join(mod, "mod.json")) &&
+ if (fs.existsSync(path.join(mod, "mod.json")) &&
fs.statSync(path.join(mod, "mod.json")).isFile()) {
if (fs.existsSync(path.join(modpath, modname))) {
@@ -836,19 +878,27 @@ setInterval(() => {
module.exports = {
mods,
- lang,
winLog,
- launch,
+
update,
- setpath,
updatevp,
- settings,
- saveSettings,
getNSVersion,
getTF2Version,
+ handleNorthstarUpdating,
+
+ launch,
+ killOrigin,
isGameRunning,
+ isOriginRunning,
+
+
+ settings,
+ saveSettings,
+
+ setpath,
gamepathExists,
- handleNorthstarUpdating,
+
+ lang,
setlang: (lang) => {
settings.lang = lang;
saveSettings();