aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2021-12-30 19:11:59 +0100
committer0neGal <mail@0negal.com>2021-12-30 19:11:59 +0100
commit9d8ceea77b6f172f0c055c0061bc07e6f45c0d2d (patch)
tree9a0190d3ec76fe9d42ebacd9f64ba2ecec65a2e5 /src
parent6cf3d134060b234c1e4642d4c1701ac308493df8 (diff)
downloadViper-9d8ceea77b6f172f0c055c0061bc07e6f45c0d2d.tar.gz
Viper-9d8ceea77b6f172f0c055c0061bc07e6f45c0d2d.zip
buttons now disable when updating, and app logs
The buttons in the GUI disable whilst you're updating Northstar and potentionally doing other things in the future, I also added a way to log things in the app, albeit it just prints it in the "Welcome to Viper!" part of the app, which is just fine. I also added all the needed language strings for the GUI logs and removed "gui.missinggamepath" as we use it for both the CLI and GUI even tho "general.missinggamepath" exists, and so we now use the general one for both, as the messages are the same.
Diffstat (limited to 'src')
-rw-r--r--src/app/index.html2
-rw-r--r--src/app/main.css3
-rw-r--r--src/app/main.js20
-rw-r--r--src/index.js8
-rw-r--r--src/lang/en.json8
-rw-r--r--src/lang/fr.json3
-rw-r--r--src/utils.js23
7 files changed, 53 insertions, 14 deletions
diff --git a/src/app/index.html b/src/app/index.html
index 426b4c5..dc65d67 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -6,7 +6,7 @@
<body>
<div class="lines">
<div class="line">
- <div class="text">%%gui.welcome%%</div>
+ <div class="text" id="welcome">%%gui.welcome%%</div>
<div class="buttons">
<button id="exit" onclick="exit()">%%gui.exit%%</button>
<button id="update" onclick="update()">%%gui.update%%</button>
diff --git a/src/app/main.css b/src/app/main.css
index f49cc98..b668f55 100644
--- a/src/app/main.css
+++ b/src/app/main.css
@@ -1,4 +1,5 @@
:root {
+ --disabled: #656E7F;
--background: #4C515B;
--foreground: #DDE2EB;
--btnforeground: var(--foreground);
@@ -64,7 +65,9 @@ button:active {
transform: scale(0.95);
}
+
#update {background: #81A1C1}
#setpath {background: #5E81AC}
#northstar {background: #C7777F}
#vanilla, #exit {background: #656E7F}
+button:disabled {background: var(--disabled) !important; opacity: 0.5}
diff --git a/src/app/main.js b/src/app/main.js
index 9bafaa5..809b5c8 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -20,7 +20,7 @@ if (fs.existsSync("viper.json")) {
settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))};
settings.zip = path.join(settings.gamepath + "/northstar.zip");
} else {
- alert(lang("gui.missinggamepath"));
+ alert(lang("general.missinggamepath"));
setpath();
}
@@ -31,10 +31,28 @@ function setpath() {ipcRenderer.send("setpath")}
function launch() {ipcRenderer.send("launch")}
function launchVanilla() {ipcRenderer.send("launchVanilla")}
+function log(msg) {
+ console.log(msg);
+ welcome.innerHTML = msg;
+}
+
+function setButtons(state) {
+ let buttons = document.querySelectorAll("button");
+
+ for (let i = 0; i < buttons.length; i++) {
+ buttons[i].disabled = !state;
+ }
+}
+
+ipcRenderer.on("ns-updated", () => {setButtons(true)})
+ipcRenderer.on("ns-updating", () => {setButtons(false)})
+
ipcRenderer.on("newpath", (event, newpath) => {
settings.gamepath = newpath;
})
+ipcRenderer.on("log", (event, msg) => {log(msg)})
+
setlang();
setInterval(() => {
ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 20);
diff --git a/src/index.js b/src/index.js
index 8343ba9..c99e367 100644
--- a/src/index.js
+++ b/src/index.js
@@ -29,14 +29,18 @@ function start() {
win.removeMenu();
win.loadFile(__dirname + "/app/index.html");
- ipcMain.on("exit", (event) => {process.exit(0)})
- ipcMain.on("setpath", (event) => {utils.setpath(win)})
+ ipcMain.on("exit", () => {process.exit(0)})
+ ipcMain.on("setpath", () => {utils.setpath(win)})
ipcMain.on("setsize", (event, height) => {
win.setSize(width, height);
if (! win.isVisible()) {
win.show();
}
})
+
+ ipcMain.on("ns-updated", () => {win.webContents.send("ns-updated")})
+ ipcMain.on("ns-updating", () => {win.webContents.send("ns-updating")})
+ ipcMain.on("winLog", (event, ...args) => {win.webContents.send("log", ...args)})
}
ipcMain.on("launch", (event) => {utils.launch()})
diff --git a/src/lang/en.json b/src/lang/en.json
index 9aaa778..e30d576 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -9,7 +9,7 @@
"cli.setpath.noarg": "No argument provided for --setpath",
"cli.update.current": "Current version:",
- "cli.update.downloading": "Downloading:",
+ "cli.update.downloading": "Downloading",
"cli.update.checking": "Checking for updates...",
"cli.update.downloaddone": "Download done! Extracting...",
"cli.update.finished": "Installation/Update finished!",
@@ -22,12 +22,16 @@
"gui.update": "Update",
"gui.setpath": "Game Path",
+ "gui.update.downloading": "Downloading...",
+ "gui.update.extracting": "Extracting update...",
+ "gui.update.finished": "Done! Ready to play!",
+ "gui.update.uptodate": "Already up to date!",
+
"gui.launch": "Launch",
"gui.launchvanilla": "Vanilla",
"gui.launchnorthstar": "Northstar",
"gui.selectpath": "Please select the path!",
- "gui.missinggamepath": "Game path is not set!",
"general.launching": "Launching",
diff --git a/src/lang/fr.json b/src/lang/fr.json
index 0dd9f99..c3e7027 100644
--- a/src/lang/fr.json
+++ b/src/lang/fr.json
@@ -8,7 +8,7 @@
"cli.setpath.noarg": "Aucun argument donné à --setpath",
"cli.update.current": "Version actuelle :",
- "cli.update.downloading": "Téléchargement en cours :",
+ "cli.update.downloading": "Téléchargement en cours ",
"cli.update.checking": "Vérification des mises à jour ...",
"cli.update.downloaddone": "Téléchargement terminé ! Extraction des fichiers...",
"cli.update.finished": "Mise à jour terminée !",
@@ -26,7 +26,6 @@
"gui.launchnorthstar": "Northstar",
"gui.selectpath": "Veuillez sélectionner le dossier où se trouve le client Titanfall 2.",
- "gui.missinggamepath": "Le chemin du client n'est pas défini !",
"general.launching": "Lancement",
diff --git a/src/utils.js b/src/utils.js
index 7e9dbac..b4ff04d 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -29,7 +29,7 @@ if (fs.existsSync("viper.json")) {
settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))};
settings.zip = path.join(settings.gamepath + "/northstar.zip");
} else {
- console.log(lang("gui.missinggamepath"));
+ console.log(lang("general.missinggamepath"));
}
function setpath(win) {
@@ -71,6 +71,7 @@ function update() {
}
}
+ ipcMain.emit("ns-updating");
console.log(lang("cli.update.checking"));
const version = getInstalledVersion();
@@ -82,12 +83,17 @@ function update() {
var tag = body["tag_name"];
if (version === tag) {
+ ipcMain.emit("ns-updated");
console.log(lang("cli.update.uptodate"), version);
+
+ winLog(lang("gui.update.uptodate"));
return;
} else {
if (version != "unknown") {
console.log(lang("cli.update.current"), version);
- }; console.log(lang("cli.update.downloading"), tag);
+ }; console.log(lang("cli.update.downloading") + ":", tag);
+
+ winLog(lang("gui.update.downloading"));
}
https.get(body.assets[0].browser_download_url, (res) => {
@@ -95,15 +101,12 @@ function update() {
res.pipe(stream);
stream.on("finish", () => {
stream.close();
+ winLog(lang("gui.update.extracting"));
console.log(lang("cli.update.downloaddone"));
fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath}))
.on("finish", () => {
- console.log(lang("cli.update.finished"));
-
fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), tag);
- events.emit("updated");
-
for (let i = 0; i < settings.excludes.length; i++) {
let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]);
if (fs.existsSync(exclude + ".excluded")) {
@@ -111,6 +114,9 @@ function update() {
}
}
+ ipcMain.emit("ns-updated");
+ winLog(lang("gui.update.finished"));
+ console.log(lang("cli.update.finished"));
cli.exit();
});
})
@@ -137,7 +143,12 @@ function launch(version) {
}
}
+function winLog(msg) {
+ ipcMain.emit("winLog", msg, msg);
+}
+
module.exports = {
+ winLog,
launch,
update,
setpath,