aboutsummaryrefslogtreecommitdiff
path: root/src/utils.js
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/utils.js
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/utils.js')
-rw-r--r--src/utils.js23
1 files changed, 17 insertions, 6 deletions
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,