aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-03-05 00:52:49 +0100
committer0neGal <mail@0negal.com>2023-03-05 00:52:49 +0100
commita5dd677c6e5e6c2cb3eec7a2edc08d15dfe43c7a (patch)
treee058daee9677f5820d3130f08a34cb9ccfd8442e /src
parent5d86a3daa5f762326055469b6bcd8346e0655056 (diff)
downloadViper-a5dd677c6e5e6c2cb3eec7a2edc08d15dfe43c7a.tar.gz
Viper-a5dd677c6e5e6c2cb3eec7a2edc08d15dfe43c7a.zip
show alert when updating with game running
This also fixes is_running not quite working on Linux
Diffstat (limited to 'src')
-rw-r--r--src/index.js14
-rw-r--r--src/lang/de.json2
-rw-r--r--src/lang/en.json2
-rw-r--r--src/lang/es.json2
-rw-r--r--src/lang/fr.json2
-rw-r--r--src/modules/is_running.js20
-rw-r--r--src/modules/update.js4
7 files changed, 30 insertions, 16 deletions
diff --git a/src/index.js b/src/index.js
index 88e3ed9..d94b6a4 100644
--- a/src/index.js
+++ b/src/index.js
@@ -7,15 +7,19 @@ const { app, ipcMain, BrowserWindow, dialog } = require("electron");
process.chdir(app.getPath("appData"));
const cli = require("./cli");
+const lang = require("./lang");
+
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 win_show = require("./modules/window");
const version = require("./modules/version");
const gamepath = require("./modules/gamepath");
const settings = require("./modules/settings");
const requests = require("./modules/requests");
+const is_running = require("./modules/is_running");
var log = console.log;
@@ -169,7 +173,15 @@ ipcMain.on("setlang", (event, lang) => {
settings.save();
});
-ipcMain.on("update-northstar", () => {update.northstar()})
+ipcMain.on("update-northstar", async () => {
+ console.log(await is_running.game())
+ if (await is_running.game()) {
+ return win_show.alert(lang("general.autoupdates.gamerunning"));
+ }
+
+ update.northstar();
+})
+
ipcMain.on("setpath-cli", () => {gamepath.set()});
ipcMain.on("setpath", (event, value) => {
if (! value) {
diff --git a/src/lang/de.json b/src/lang/de.json
index 8e3a482..2e972d7 100644
--- a/src/lang/de.json
+++ b/src/lang/de.json
@@ -26,7 +26,6 @@
"cli.autoupdates.checking": "Überprüfe Northstar auf Updates...",
"cli.autoupdates.available": "Ein Update für Northstar wurde gefunden!",
- "cli.autoupdates.gamerunning": "Spiel wird ausgeführt, Northstar wird nicht aktualisiert.",
"cli.autoupdates.updatingns": "Updateprozess wird gestartet...",
"cli.autoupdates.noupdate": "Kein Update für Northstar vorhanden.",
@@ -158,6 +157,7 @@
"ns.menu.mods": "Mods",
"ns.menu.release": "Release Notes",
+ "general.autoupdates.gamerunning": "Spiel wird ausgeführt, Northstar wird nicht aktualisiert.",
"general.mods.enabled": "Aktivierte Mods:",
"general.mods.disabled": "Deaktivierte Mods:",
"general.mods.installed": "Installierte Mods:",
diff --git a/src/lang/en.json b/src/lang/en.json
index 3627151..f9f84db 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -26,7 +26,6 @@
"cli.autoupdates.checking": "Checking for Northstar updates...",
"cli.autoupdates.available": "Northstar update available!",
- "cli.autoupdates.gamerunning": "Game is running, refusing to update Northstar",
"cli.autoupdates.updatingns": "Launching update process...",
"cli.autoupdates.noupdate": "No Northstar update available.",
@@ -159,6 +158,7 @@
"ns.menu.mods": "Mods",
"ns.menu.release": "Release Notes",
+ "general.autoupdates.gamerunning": "Game is running, refusing to update Northstar",
"general.mods.enabled": "Enabled mods:",
"general.mods.disabled": "Disabled mods:",
"general.mods.installed": "Installed mods:",
diff --git a/src/lang/es.json b/src/lang/es.json
index 774e2af..bc8a9a9 100644
--- a/src/lang/es.json
+++ b/src/lang/es.json
@@ -28,7 +28,6 @@
"cli.autoupdates.checking": "Buscando actualizaciones de Northstar...",
"cli.autoupdates.available": "¡Actualización de Northsar disponible!",
- "cli.autoupdates.gamerunning": "El juego se está ejecutando, no se puede actualizar Northstar",
"cli.autoupdates.updatingns": "Lanzando proceso de actualización...",
"cli.autoupdates.noupdate": "No hay actualizaciones de Northstar disponibles.",
@@ -159,6 +158,7 @@
"ns.menu.mods": "Modificiaciones",
"ns.menu.release": "Notas de actualización",
+ "general.autoupdates.gamerunning": "El juego se está ejecutando, no se puede actualizar Northstar",
"general.mods.enabled": "Modificaciones habilitadas:",
"general.mods.disabled": "Modificaciones deshabilitadas:",
"general.mods.installed": "Modificiaciones intaladas:",
diff --git a/src/lang/fr.json b/src/lang/fr.json
index 89aa457..2cf3957 100644
--- a/src/lang/fr.json
+++ b/src/lang/fr.json
@@ -26,7 +26,6 @@
"cli.autoupdates.checking": "Vérifications des mises à jour de Northstar...",
"cli.autoupdates.available": "Une mise à jour de Northstar est disponible !",
- "cli.autoupdates.gamerunning": "Le jeu est en cours d'exécution, impossible de lancer la mise à jour.",
"cli.autoupdates.updatingns": "Lancement de la mise à jour...",
"cli.autoupdates.noupdate": "Pas de mise à jour de Northstar disponible.",
@@ -159,6 +158,7 @@
"ns.menu.mods": "Mods",
"ns.menu.release": "Notes de mises à jour",
+ "general.autoupdates.gamerunning": "Le jeu est en cours d'exécution, impossible de lancer la mise à jour.",
"general.mods.enabled": "Mods activés :",
"general.mods.disabled": "Mods désactivés :",
"general.mods.installed": "Mods installés :",
diff --git a/src/modules/is_running.js b/src/modules/is_running.js
index cc91ded..5e0b67e 100644
--- a/src/modules/is_running.js
+++ b/src/modules/is_running.js
@@ -20,7 +20,7 @@ async function check_processes(processes) {
// thing. And it's not much more clunky.
let cmd = (() => {
switch (process.platform) {
- case "linux": return "ps -A";
+ case "linux": return "ps a";
case "win32": return "tasklist";
}
})();
@@ -28,37 +28,39 @@ async function check_processes(processes) {
exec(cmd, (err, stdout) => {
for (let i = 0; i < processes.length; i++) {
if (stdout.includes(processes[i])) {
+ console.log("running")
resolve(true);
break
}
+ console.log("not running")
if (i == processes.length - 1) {resolve(false)}
}
});
});
}
-is_running.game = async () => {
- return await check_processes([
+is_running.game = () => {
+ return check_processes([
"NorthstarLauncher.exe",
"Titanfall2.exe", "Titanfall2-unpacked.exe"
])
}
-is_running.origin = async () => {
- return await check_processes([
+is_running.origin = () => {
+ return check_processes([
"Origin.exe",
])
}
-is_running.titanfall = async () => {
- return await check_processes([
+is_running.titanfall = () => {
+ return check_processes([
"Titanfall2.exe", "Titanfall2-unpacked.exe"
])
}
-is_running.northstar = async () => {
- return await check_processes([
+is_running.northstar = () => {
+ return check_processes([
"NorthstarLauncher.exe",
])
}
diff --git a/src/modules/update.js b/src/modules/update.js
index cfdb42b..2c75cac 100644
--- a/src/modules/update.js
+++ b/src/modules/update.js
@@ -63,7 +63,7 @@ update.northstar_autoupdate = () => {
if (await northstar_update_available()) {
console.log(lang("cli.autoupdates.available"));
if (await is_running.game()) {
- console.log(lang("cli.autoupdates.gamerunning"));
+ console.log(lang("general.autoupdates.gamerunning"));
new Notification({
title: lang("gui.nsupdate.gaming.title"),
body: lang("gui.nsupdate.gaming.body")
@@ -150,7 +150,7 @@ update.viper = (autoinstall) => {
// unzip module does not support excluding files directly.
update.northstar = async () => {
if (await is_running.game()) {
- console.log(lang("cli.autoupdates.gamerunning"));
+ console.log(lang("general.autoupdates.gamerunning"));
return false;
}