aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/is_running.js
blob: 69efd5bdf161f3240e5b8edfdd723554977e497d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
}