From b430d92573619ffce82362cc2a682addc6c958ab Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Wed, 29 Dec 2021 12:10:40 +0100 Subject: [feat] adding version indicators on the UI --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index fead15b..3520914 100644 --- a/src/index.js +++ b/src/index.js @@ -11,7 +11,7 @@ const cli = require("./cli"); function start() { win = new BrowserWindow({ width: 600, - height: 115, + height: 130, show: false, title: "Viper", resizable: false, -- cgit v1.2.3 From 93482ac6169a62854e360fde92abf7640389361b Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Thu, 30 Dec 2021 00:04:55 +0100 Subject: [feat] displaying installed northstar version --- src/app/main.js | 5 +++++ src/index.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/index.js') diff --git a/src/app/main.js b/src/app/main.js index 579f785..684cb5a 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -34,3 +34,8 @@ function launchVanilla() {ipcRenderer.send("launchVanilla")} ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = newpath; }) + +ipcRenderer.on('versionInfo', (_, payload) => { + document.getElementById('nsVersion').innerText = `Northstar version: ${payload.ns}` +}); +ipcRenderer.send('getVersionInfo'); diff --git a/src/index.js b/src/index.js index 3520914..c20e8e0 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ const fs = require("fs"); const path = require("path"); -const { app, dialog, ipcMain, BrowserWindow } = require("electron"); +const { app, dialog, ipcMain, BrowserWindow, ipcRenderer } = require("electron"); const Emitter = require("events"); const events = new Emitter(); @@ -37,7 +37,13 @@ ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)}) ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")}) ipcMain.on("update", (event) => {utils.update()}) -ipcMain.on("setpathcli", (event) => {utils.setpath()}) +ipcMain.on("setpathcli", (event) => {utils.setpath()}); + +ipcMain.on('getVersionInfo', () => { + win.webContents.send('versionInfo', { + ns: utils.getInstalledVersion() + }); +}); process.chdir(app.getPath("appData")); -- cgit v1.2.3 From 9df37da13c5eeba92ceeed7a5e9ffbaed976a615 Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Thu, 30 Dec 2021 00:12:05 +0100 Subject: [feat] displaying viper version --- src/app/main.js | 3 ++- src/index.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/index.js') diff --git a/src/app/main.js b/src/app/main.js index 684cb5a..a059671 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -36,6 +36,7 @@ ipcRenderer.on("newpath", (event, newpath) => { }) ipcRenderer.on('versionInfo', (_, payload) => { - document.getElementById('nsVersion').innerText = `Northstar version: ${payload.ns}` + document.getElementById('vpVersion').innerText = `Viper version: ${payload.vp}`; + document.getElementById('nsVersion').innerText = `Northstar version: ${payload.ns}`; }); ipcRenderer.send('getVersionInfo'); diff --git a/src/index.js b/src/index.js index c20e8e0..56b0df4 100644 --- a/src/index.js +++ b/src/index.js @@ -41,7 +41,8 @@ ipcMain.on("setpathcli", (event) => {utils.setpath()}); ipcMain.on('getVersionInfo', () => { win.webContents.send('versionInfo', { - ns: utils.getInstalledVersion() + ns: utils.getInstalledVersion(), + vp: 'v' + require('../package.json').version }); }); -- cgit v1.2.3 From e199d2b6bbe48d51704156607c9e91d82ed2747f Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 29 Dec 2021 23:47:49 +0100 Subject: replaced single quotes, renamed a few things Simply code style changes, also removed the content of the version divs since they'll be replaced anyway. --- src/app/index.html | 4 ++-- src/app/main.js | 8 ++++---- src/index.js | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/index.js') diff --git a/src/app/index.html b/src/app/index.html index 6e31f0c..4c31255 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -9,8 +9,8 @@
%%gui.welcome%%
-
Viper version: x.x.x
-
Northstar version: x.x.x
+
+
diff --git a/src/app/main.js b/src/app/main.js index ab41af6..765b143 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -35,11 +35,11 @@ ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = newpath; }) -ipcRenderer.on('versionInfo', (_, payload) => { - document.getElementById('vpVersion').innerText = `Viper version: ${payload.vp}`; - document.getElementById('nsVersion').innerText = `Northstar version: ${payload.ns}`; +ipcRenderer.on("version", (_, payload) => { + document.getElementById("vpVersion").innerText = "Viper version:" + payload.vp; + document.getElementById("nsVersion").innerText = "Northstar version: " + payload.ns; }); -ipcRenderer.send('getVersionInfo'); +ipcRenderer.send("getversion"); setlang(); setInterval(() => { diff --git a/src/index.js b/src/index.js index b41971d..51449af 100644 --- a/src/index.js +++ b/src/index.js @@ -17,7 +17,7 @@ function start() { title: "Viper", resizable: false, titleBarStyle: "hidden", - icon: path.join(__dirname, 'assets/icons/512x512.png'), + icon: path.join(__dirname, "assets/icons/512x512.png"), webPreferences: { nodeIntegration: true, contextIsolation: false, @@ -46,10 +46,10 @@ ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")}) ipcMain.on("update", (event) => {utils.update()}) ipcMain.on("setpathcli", (event) => {utils.setpath()}); -ipcMain.on('getVersionInfo', () => { - win.webContents.send('versionInfo', { +ipcMain.on("getversion", () => { + win.webContents.send("version", { ns: utils.getInstalledVersion(), - vp: 'v' + require('../package.json').version + vp: "v" + require("../package.json").version }); }); -- 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/index.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 From 4a0ce8d918007a3ed39bd15c28fc1c7931080271 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Thu, 30 Dec 2021 03:55:32 +0100 Subject: added northstar version to --version --- src/cli.js | 7 +------ src/index.js | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/index.js') diff --git a/src/cli.js b/src/cli.js index 6696d36..f7d2141 100644 --- a/src/cli.js +++ b/src/cli.js @@ -39,12 +39,7 @@ async function init() { } if (cli.hasSwitch("update")) {ipcMain.emit("update")} - if (cli.hasSwitch("version")) { - console.log("Viper: v" + require("../package.json").version); - console.log("Node: " + process.version); - console.log("Electron: v" + process.versions.electron); - exit(); - } + if (cli.hasSwitch("version")) {ipcMain.emit("versioncli")} if (cli.hasSwitch("setpath")) { if (cli.getSwitchValue("setpath") != "") { diff --git a/src/index.js b/src/index.js index 660d3a0..063e4df 100644 --- a/src/index.js +++ b/src/index.js @@ -53,6 +53,14 @@ ipcMain.on("getversion", () => { }); }); +ipcMain.on("versioncli", () => { + console.log("Viper: v" + require("../package.json").version); + console.log("Northstar: " + utils.getNSVersion()); + console.log("Node: " + process.version); + console.log("Electron: v" + process.versions.electron); + cli.exit(); +}) + process.chdir(app.getPath("appData")); if (cli.hasArgs()) { -- cgit v1.2.3