diff options
author | 0neGal <mail@0negal.com> | 2022-04-20 20:22:58 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2022-04-20 20:22:58 +0200 |
commit | 8c437b60104cbf1bed9ebc313e5bc3b9d04162b3 (patch) | |
tree | 938575a1caccfaeedb4972483ff134833ad873a9 | |
parent | a2e1b36c558ed32e7a91b28a21a3843cd82217be (diff) | |
download | Viper-8c437b60104cbf1bed9ebc313e5bc3b9d04162b3.tar.gz Viper-8c437b60104cbf1bed9ebc313e5bc3b9d04162b3.zip |
running status on buttons
When the game is running the buttons will go from saying "Launch" to
"Running" and the buttons will also disable, so you can't run the game
multiple times, avoiding a lot of issues.
-rw-r--r-- | src/app/main.js | 14 | ||||
-rw-r--r-- | src/index.js | 3 | ||||
-rw-r--r-- | src/lang/en.json | 1 | ||||
-rw-r--r-- | src/utils.js | 8 |
4 files changed, 25 insertions, 1 deletions
diff --git a/src/app/main.js b/src/app/main.js index 8894d3f..4918777 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -91,6 +91,20 @@ function setButtons(state) { } ipcRenderer.on("setbuttons", (event, state) => {setButtons(state)}) + +ipcRenderer.on("gamestate", (event, state) => { + setButtons(! state); + + let string = lang("gui.launch"); + if (state) { + string = lang("gui.running"); + } + + let btns = document.querySelectorAll(".playBtnContainer .playBtn"); + btns[0].innerHTML = string; + btns[1].innerHTML = string; +}) + ipcRenderer.on("gamepathlost", (event, state) => { page(0); setButtons(false); diff --git a/src/index.js b/src/index.js index b38b65d..d854ce8 100644 --- a/src/index.js +++ b/src/index.js @@ -53,6 +53,9 @@ function start() { ipcMain.on("installedmod", (event, modname) => {win.webContents.send("installedmod", modname)}); ipcMain.on("guigetmods", (event, ...args) => {win.webContents.send("mods", utils.mods.list())}); + ipcMain.on("gamestarted", (event) => {win.webContents.send("gamestate", true)}); + ipcMain.on("gamestopped", (event) => {win.webContents.send("gamestate", false)}); + let gamepathlost = false; ipcMain.on("gamepathlost", (event, ...args) => { if (! gamepathlost) { diff --git a/src/lang/en.json b/src/lang/en.json index 92aab31..9f2ac40 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -116,6 +116,7 @@ "gui.nsupdate.gaming.body": "An update for Northstar is available.\nYou can force its installation after closing the game.", "gui.launch": "Launch", + "gui.running": "Running", "gui.launchvanilla": "Vanilla", "gui.launchnorthstar": "Northstar", "gui.installnorthstar": "Install", diff --git a/src/utils.js b/src/utils.js index bb5b982..1b880bb 100644 --- a/src/utils.js +++ b/src/utils.js @@ -835,7 +835,7 @@ const mods = { } }; -setInterval(() => { +setInterval(async () => { if (gamepathExists()) { ipcMain.emit("guigetmods"); } else { @@ -845,6 +845,12 @@ setInterval(() => { } } } + + if (await isGameRunning()) { + ipcMain.emit("gamestarted"); + } else { + ipcMain.emit("gamestopped"); + } }, 1500) module.exports = { |