From cfec36cbdf00b181e6560be15c6b341842894e00 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 6 May 2023 23:08:10 +0200 Subject: change launch button text if game is running This should've already been a thing, and was a thing for when the game was currently launching, but this functionality seems to have been broken at some point. --- src/app/main.js | 25 +++++++++++++++++++++++++ src/index.js | 4 ++++ src/lang/en.json | 1 + 3 files changed, 30 insertions(+) diff --git a/src/app/main.js b/src/app/main.js index 72e0e09..1dbff40 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -242,6 +242,31 @@ ipcRenderer.on("confirm", (event, data) => { ipcRenderer.send("confirm-closed-" + data.id, confirmed); }) +let is_running = false; +ipcRenderer.on("is-running", (event, running) => { + let set_playbtns = (text) => { + let playbtns = document.querySelectorAll(".playBtn"); + for (let i = 0; i < playbtns.length; i++) { + playbtns[i].innerHTML = text; + } + } + + if (running && is_running != running) { + setButtons(false); + set_playbtns(lang("general.running")); + + is_running = running; + return; + } + + if (is_running != running) { + setButtons(true); + set_playbtns(lang("gui.launch")); + + is_running = running; + } +}) + // Updates the installed mods ipcRenderer.on("mods", (event, mods_obj) => { modsobj = mods_obj; diff --git a/src/index.js b/src/index.js index c6179e0..3d2f65b 100644 --- a/src/index.js +++ b/src/index.js @@ -156,6 +156,10 @@ function start() { ipcMain.on("update-now", () => { autoUpdater.quitAndInstall(); }) + + setInterval(async () => { + send("is-running", await is_running.game()); + }, 1000) } ipcMain.on("install-mod", () => { diff --git a/src/lang/en.json b/src/lang/en.json index 4eabbbd..4f90f32 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -164,6 +164,7 @@ "general.mods.installed": "Installed mods:", "general.missingpath": "Game location could not be found automatically! Please select it manually!", "general.notinstalled": "Northstar is not installed!", + "general.running": "Running", "general.launching": "Launching", "general.invalidconfig": "Your config file is improperly formatted, if it's been manually edited, please validate that everything is typed correctly.\n\nIf you did not manually edit the config file, it is recommended to simply reset the config.\n\nTo reset your config file simply click \"Ok\" below.\n\nMore details:\n", -- cgit v1.2.3