aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/is_running.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2024-06-08 18:02:48 +0200
committer0neGal <mail@0negal.com>2024-06-08 18:02:48 +0200
commitdbd8c6b152acc1188d2edd288488aa2da8f6310b (patch)
treeef5a1752e845a274c889ee18207c3a25e8290b23 /src/app/js/is_running.js
parent3904a4492f72ef9a9fd531c0b81f3711541c97e0 (diff)
downloadViper-dbd8c6b152acc1188d2edd288488aa2da8f6310b.tar.gz
Viper-dbd8c6b152acc1188d2edd288488aa2da8f6310b.zip
initial commit to better modularize frontend
Far from done, but this pretty much splits everything inside `src/app/main.js` into separate files.
Diffstat (limited to 'src/app/js/is_running.js')
-rw-r--r--src/app/js/is_running.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/app/js/is_running.js b/src/app/js/is_running.js
new file mode 100644
index 0000000..69efd5b
--- /dev/null
+++ b/src/app/js/is_running.js
@@ -0,0 +1,46 @@
+const lang = require("../../lang");
+
+// is the game running?
+let is_running = false;
+
+// updates play buttons depending on whether the game is running
+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) {
+ set_buttons(false);
+ set_playbtns(lang("general.running"));
+
+ is_running = running;
+
+ // show force quit button in Titanfall tab
+ tfquit.style.display = "inline-block";
+
+ update.setAttribute("onclick", "kill('game')");
+ update.innerHTML = "(" + lang("ns.menu.force_quit") + ")";
+ return;
+ }
+
+ if (is_running != running) {
+ set_buttons(true);
+ set_playbtns(lang("gui.launch"));
+
+ is_running = running;
+
+ // hide force quit button in Titanfall tab
+ tfquit.style.display = "none";
+
+ update.setAttribute("onclick", "update.ns()");
+ update.innerHTML = "(" + lang("gui.update.check") + ")";
+ }
+})
+
+// return whether the game is running
+module.exports = () => {
+ return is_running;
+}