From 9d8ceea77b6f172f0c055c0061bc07e6f45c0d2d Mon Sep 17 00:00:00 2001 From: 0neGal Date: Thu, 30 Dec 2021 19:11:59 +0100 Subject: 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. --- src/utils.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/utils.js') 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, -- cgit v1.2.3