aboutsummaryrefslogtreecommitdiff
path: root/src/app/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/main.js')
-rw-r--r--src/app/main.js71
1 files changed, 46 insertions, 25 deletions
diff --git a/src/app/main.js b/src/app/main.js
index c365cf4..893572a 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -1,6 +1,6 @@
const fs = require("fs");
const path = require("path");
-const { ipcRenderer } = require("electron");
+const { ipcRenderer, shell } = require("electron");
const lang = require("../lang");
let shouldInstallNorthstar = false;
@@ -36,10 +36,9 @@ if (fs.existsSync("viper.json")) {
function exit() {ipcRenderer.send("exit")}
function update() {ipcRenderer.send("update")}
-/**
- * Reports to the main thread about game path status.
- * @param {boolean} value is game path loaded
- */
+// Reports to the main process about game path status.
+// @param {boolean} value is game path loaded
+
function setpath(value = false) {
ipcRenderer.send("setpath", value);
}
@@ -56,16 +55,26 @@ function launchVanilla() {ipcRenderer.send("launchVanilla")}
function log(msg) {
console.log(msg);
- welcome.innerHTML = msg;
+ // welcome.innerHTML = msg;
}
function setButtons(state) {
- let buttons = document.querySelectorAll("button");
+ playNsBtn.disabled = !state;
+}
- for (let i = 0; i < buttons.length; i++) {
- buttons[i].disabled = !state;
+ipcRenderer.on("ns-update-event", (event, key) => {
+ document.getElementById("update").innerText = `(${lang(key)})`;
+ console.log(key);
+ switch(key) {
+ case "cli.update.uptodate.short":
+ setButtons(true);
+ playNsBtn.innerText = lang("gui.launch");
+ break;
+ default:
+ setButtons(false);
+ break;
}
-}
+});
let lastselected = "";
function select(entry) {
@@ -100,7 +109,12 @@ function selected(all) {
return {
remove: () => {
- if (selected == "allmods") {
+
+ if (selected.match(/^Northstar\./)) {
+ if (! confirm(lang("gui.mods.required.confirm"))) {
+ return;
+ }
+ } else if (selected == "allmods") {
if (! confirm(lang("gui.mods.removeall.confirm"))) {
return;
}
@@ -109,6 +123,16 @@ function selected(all) {
ipcRenderer.send("removemod", selected)
},
toggle: () => {
+ if (selected.match(/^Northstar\./)) {
+ if (! confirm(lang("gui.mods.required.confirm"))) {
+ return;
+ }
+ } else if (selected == "allmods") {
+ if (! confirm(lang("gui.mods.toggleall.confirm"))) {
+ return;
+ }
+ }
+
ipcRenderer.send("togglemod", selected)
}
}
@@ -118,13 +142,6 @@ function installmod() {
ipcRenderer.send("installmod")
}
-ipcRenderer.on("ns-updated", () => {
- setButtons(true);
- northstar.disabled = false;
- updateBtn.innerText = lang("gui.update");
-})
-ipcRenderer.on("ns-updating", () => {setButtons(false)})
-
ipcRenderer.on("newpath", (event, newpath) => {
settings.gamepath = newpath;
})
@@ -153,8 +170,9 @@ ipcRenderer.on("mods", (event, mods) => {
})
ipcRenderer.on("version", (event, versions) => {
- vpversion.innerText = lang("gui.versions.viper") + ": " + versions.vp;
- nsversion.innerText = lang("gui.versions.northstar") + ": " + versions.ns;
+ vpversion.innerText = versions.vp;
+ nsversion.innerText = versions.ns;
+ tf2Version.innerText = versions.tf2;
if (versions.ns == "unknown") {
let buttons = document.querySelectorAll(".modbtns button");
@@ -164,9 +182,8 @@ ipcRenderer.on("version", (event, versions) => {
}
// Since Northstar is not installed, we cannot launch it
- northstar.disabled = true;
shouldInstallNorthstar = true;
- updateBtn.innerText = lang("gui.installnorthstar");
+ playNsBtn.innerText = lang("gui.installnorthstar");
}
}); ipcRenderer.send("getversion");
@@ -187,6 +204,10 @@ ipcRenderer.on("wrongpath", () => {
});
setlang();
-setInterval(() => {
- ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 20);
-}, 150);
+
+document.body.addEventListener("click", event => {
+ if (event.target.tagName.toLowerCase() === "a" && event.target.protocol != "file:") {
+ event.preventDefault();
+ shell.openExternal(event.target.href);
+ }
+});