From e2d7efc2f00eae07dd5228f9c963533358edd56d Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Thu, 30 Dec 2021 00:03:04 +0100 Subject: [feat] exporting utils.getInstalledVersion method --- src/utils.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/utils.js') diff --git a/src/utils.js b/src/utils.js index 7e9dbac..b5767da 100644 --- a/src/utils.js +++ b/src/utils.js @@ -146,4 +146,5 @@ module.exports = { settings.lang = lang; saveSettings(); }, + getInstalledVersion } -- cgit v1.2.3 From 40bba8b31cfbef319553920d9fa678ffc1a99597 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Thu, 30 Dec 2021 03:43:37 +0100 Subject: version now refreshes, fixed and renamed stuff The version now refreshes when you update/install Northstar, I renamed vpVersion/nsVersion to just vpversion/nsversion and getInstalledVersion() to getNSVersion(), removed uses of getElementById() with just the ID. I also added English localization. The versions text color is now bound by a CSS variable (we may use it in the future again). I'm also not sure what the point of `style="white-space: nowrap;"` was, as I don't see much of a difference? Rather instead use `` in the lang file if needed. Besides that I did tiny code cleanup. --- src/app/index.html | 6 +++--- src/app/main.css | 5 +++-- src/app/main.js | 6 +++--- src/index.js | 2 +- src/lang/en.json | 2 ++ src/utils.js | 11 +++++------ 6 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src/utils.js') diff --git a/src/app/index.html b/src/app/index.html index 4c31255..80f7701 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -7,10 +7,10 @@
-
%%gui.welcome%%
+
%%gui.welcome%%
-
-
+
+
diff --git a/src/app/main.css b/src/app/main.css index c86e08d..cd6c001 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -1,6 +1,7 @@ :root { --background: #4C515B; --foreground: #DDE2EB; + --subforeground: #AFAFAF; --btnforeground: var(--foreground); } @@ -72,5 +73,5 @@ button:active { .versions { height: 15px; font-size: 12px; - color: #afafaf; -} \ No newline at end of file + color: var(--subforeground); +} diff --git a/src/app/main.js b/src/app/main.js index 765b143..59b28f2 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -35,9 +35,9 @@ ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = newpath; }) -ipcRenderer.on("version", (_, payload) => { - document.getElementById("vpVersion").innerText = "Viper version:" + payload.vp; - document.getElementById("nsVersion").innerText = "Northstar version: " + payload.ns; +ipcRenderer.on("version", (event, versions) => { + vpversion.innerText = lang("gui.versions.viper") + ": " + versions.vp; + nsversion.innerText = lang("gui.versions.northstar") + ": " + versions.ns; }); ipcRenderer.send("getversion"); diff --git a/src/index.js b/src/index.js index 51449af..660d3a0 100644 --- a/src/index.js +++ b/src/index.js @@ -48,7 +48,7 @@ ipcMain.on("setpathcli", (event) => {utils.setpath()}); ipcMain.on("getversion", () => { win.webContents.send("version", { - ns: utils.getInstalledVersion(), + ns: utils.getNSVersion(), vp: "v" + require("../package.json").version }); }); diff --git a/src/lang/en.json b/src/lang/en.json index e88079e..a89f848 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -17,6 +17,8 @@ "cli.launch.linuxerror": "Launching the game is not currently supported on Linux", "gui.welcome": "Welcome to Viper!", + "gui.versions.viper": "Viper version", + "gui.versions.northstar": "Northstar version", "gui.exit": "Exit", "gui.update": "Update", "gui.setpath": "Game Path", diff --git a/src/utils.js b/src/utils.js index b5767da..277c729 100644 --- a/src/utils.js +++ b/src/utils.js @@ -52,8 +52,8 @@ function saveSettings() { fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify(settings)); } -function getInstalledVersion() { - const versionFilePath = path.join(settings.gamepath, "ns_version.txt"); +function getNSVersion() { + var versionFilePath = path.join(settings.gamepath, "ns_version.txt"); if (fs.existsSync(versionFilePath)) { return fs.readFileSync(versionFilePath, "utf8"); @@ -72,7 +72,7 @@ function update() { } console.log(lang("cli.update.checking")); - const version = getInstalledVersion(); + var version = getNSVersion(); request({ json: true, @@ -101,8 +101,7 @@ function update() { console.log(lang("cli.update.finished")); fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), tag); - - events.emit("updated"); + ipcMain.emit("getversion"); for (let i = 0; i < settings.excludes.length; i++) { let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]); @@ -142,9 +141,9 @@ module.exports = { update, setpath, settings, + getNSVersion, setlang: (lang) => { settings.lang = lang; saveSettings(); }, - getInstalledVersion } -- cgit v1.2.3