From ba64cef4fd5738e5744814bf67dddbd3865132f1 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 16 Sep 2023 00:27:45 +0200 Subject: added button to force kill game --- src/app/main.js | 10 ++++++++++ src/index.js | 4 ++++ src/lang/en.json | 1 + src/modules/kill.js | 14 +++++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/app/main.js b/src/app/main.js index 4e30cd0..b7058ce 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -312,6 +312,9 @@ ipcRenderer.on("is-running", (event, running) => { set_playbtns(lang("general.running")); is_running = running; + + update.setAttribute("onclick", "kill_game()"); + update.innerHTML = "(" + lang("ns.menu.force_quit") + ")"; return; } @@ -320,9 +323,16 @@ ipcRenderer.on("is-running", (event, running) => { set_playbtns(lang("gui.launch")); is_running = running; + + update.setAttribute("onclick", "updateNorthstar()"); + update.innerHTML = "(" + lang("gui.update.check") + ")"; } }) +function kill_game() { + ipcRenderer.send("kill-game"); +} + // Updates the installed mods ipcRenderer.on("mods", (event, mods_obj) => { modsobj = mods_obj; diff --git a/src/index.js b/src/index.js index 301c622..b8a9f97 100644 --- a/src/index.js +++ b/src/index.js @@ -79,8 +79,12 @@ function start() { process.exit(0) } }); + ipcMain.on("minimize", () => {win.minimize()}); ipcMain.on("relaunch", () => {app.relaunch(); app.exit()}); + ipcMain.on("kill-game", () => { + kill.game(); + }); // 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 b3823d7..beeac75 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -159,6 +159,7 @@ "ns.menu.main": "Northstar Launcher", "ns.menu.mods": "Mods", "ns.menu.release": "Release Notes", + "ns.menu.force_quit": "Force quit game", "general.autoupdates.gamerunning": "Game is running, refusing to update Northstar", "general.mods.enabled": "Enabled mods:", diff --git a/src/modules/kill.js b/src/modules/kill.js index e0e93fc..3c93f7b 100644 --- a/src/modules/kill.js +++ b/src/modules/kill.js @@ -6,7 +6,7 @@ async function kill(process_name) { let proc = process_name; let cmd = (() => { switch (process.platform) { - case "linux": return "killall " + proc; + case "linux": return "killall -9 " + proc; case "win32": return "taskkill /IM " + proc + " /F"; } })(); @@ -31,4 +31,16 @@ kill.origin = async () => { return false; } +kill.game = async () => { + let tf2 = await kill("Titanfall2.exe"); + let northstar = await kill("NorthstarLauncher.exe"); + let tf2_unpacked = await kill("Titanfall2-unpacked.exe"); + + if (tf2 || northstar || tf2_unpacked) { + return true; + } + + return false; +} + module.exports = kill; -- cgit v1.2.3