From bce88c1def1b0d8c8f03595c6a84196173304f34 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 28 Dec 2021 16:46:09 +0100 Subject: you can now exclude certain files like, ns_args However, I can't figure out a way to directly exclude it in the unzip package, hence, it just renames the original to ".excluded" when the extraction is done it then renames it back to it's original aka "", overwriting what was extracted, which essentially excludes some files. If there exists an unzip library/package that has options for excluding files we should move to that, but until something as such is found the current way is how we'll do it. --- src/app/main.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/app') diff --git a/src/app/main.js b/src/app/main.js index 17389b2..be13beb 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -6,6 +6,10 @@ var settings = { gamepath: "", file: "viper.json", zip: "/northstar.zip", + excludes: [ + "ns_startup_args.txt", + "ns_startup_args_dedi.txt" + ] } if (fs.existsSync(settings.file)) { -- cgit v1.2.3 From fccb5815decce6257b8f04cb842a40d6d02110e7 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 28 Dec 2021 17:08:00 +0100 Subject: removed settings.file We now just use a fixed string ("viper.json") --- src/app/main.js | 5 ++--- src/utils.js | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/app') diff --git a/src/app/main.js b/src/app/main.js index be13beb..d390962 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -4,7 +4,6 @@ const { ipcRenderer } = require("electron"); var settings = { gamepath: "", - file: "viper.json", zip: "/northstar.zip", excludes: [ "ns_startup_args.txt", @@ -12,8 +11,8 @@ var settings = { ] } -if (fs.existsSync(settings.file)) { - settings = {...settings, ...JSON.parse(fs.readFileSync(settings.file, "utf8"))}; +if (fs.existsSync("viper.json")) { + settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))}; settings.zip = path.join(settings.gamepath + "/northstar.zip"); } else { alert("Game path is not set! Please select the path!"); diff --git a/src/utils.js b/src/utils.js index a5cb461..85ce5ce 100644 --- a/src/utils.js +++ b/src/utils.js @@ -16,7 +16,6 @@ process.chdir(app.getPath("appData")); var settings = { gamepath: "", - file: "viper.json", zip: "/northstar.zip", excludes: [ "ns_startup_args.txt", @@ -24,8 +23,8 @@ var settings = { ] } -if (fs.existsSync(settings.file)) { - settings = {...settings, ...JSON.parse(fs.readFileSync(settings.file, "utf8"))}; +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("Game path is not set! Please select the path."); -- cgit v1.2.3 From c7d3e7480395fa7e5cb0104c8c8efd87ecb6a1a4 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 28 Dec 2021 18:03:06 +0100 Subject: attempt at making localization This may or may not be how we actually do localization in the future, however for now this seems doable. I will obviously need to look at how we detect the language, as I think instead of relying on names like "en-US" just have "en", so we don't have to symlink various editions of English to the same file. But for now this is a draft, and the important part of this is rather how the underlying localization works. --- src/app/index.html | 15 ++++++++------- src/app/lang.js | 10 ++++++++++ src/app/main.js | 4 +++- src/cli.js | 14 ++++++++------ src/lang.js | 19 +++++++++++++++++++ src/lang/en-US.json | 21 +++++++++++++++++++++ 6 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 src/app/lang.js create mode 100644 src/lang.js create mode 100644 src/lang/en-US.json (limited to 'src/app') diff --git a/src/app/index.html b/src/app/index.html index 67d2e5c..1c34360 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -6,22 +6,23 @@
-
Welcome to Viper!
+
%%gui.welcome%%
- - - + + +
-
Launch:
+
%%gui.launch%%:
- - + +
+ diff --git a/src/app/lang.js b/src/app/lang.js new file mode 100644 index 0000000..8cf3d4b --- /dev/null +++ b/src/app/lang.js @@ -0,0 +1,10 @@ +html = document.body.innerHTML.split("%%"); + +for (let i = 0; i < html.length; i++) { + if (html[i][0] != " " && + html[i][html[i].length - 1] != " ") { + html[i] = lang(html[i]) + } +} + +document.body.innerHTML = html.join(""); diff --git a/src/app/main.js b/src/app/main.js index d390962..a3a5676 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -2,6 +2,8 @@ const fs = require("fs"); const path = require("path"); const { ipcRenderer } = require("electron"); +const lang = require("../lang"); + var settings = { gamepath: "", zip: "/northstar.zip", @@ -15,7 +17,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("Game path is not set! Please select the path!"); + alert(lang("gui.missinggamepath")); setpath(); } diff --git a/src/cli.js b/src/cli.js index e5fe042..8593117 100644 --- a/src/cli.js +++ b/src/cli.js @@ -5,6 +5,7 @@ const Emitter = require("events"); const events = new Emitter(); const cli = app.commandLine; +const lang = require("./lang"); function hasArgs() { if (cli.hasSwitch("cli") || @@ -24,12 +25,12 @@ function exit(code) { async function init() { if (cli.hasSwitch("help")) { console.log(`options: - --help shows this help message - --debug opens the dev/debug tools + --help ${lang("cli.help.help")} + --debug ${lang("cli.help.debug")} - --cli forces the CLI to enable - --update updates Northstar from your set game path - --setpath sets your game path`) + --cli ${lang("cli.help.cli")} + --update ${lang("cli.help.update")} + --setpath ${lang("cli.help.setpath")}`) // In the future --setpath should be able to understand // relative paths, instead of just absolute ones. exit(); @@ -43,7 +44,8 @@ async function init() { if (cli.getSwitchValue("setpath") != "") { ipcMain.emit("setpathcli", cli.getSwitchValue("setpath")); } else { - console.error("error: No argumment provided for --setpath"); + console.error(`error: ${lang("cli.setpath.noarg")}`); + exit(1); } } diff --git a/src/lang.js b/src/lang.js new file mode 100644 index 0000000..4e4e481 --- /dev/null +++ b/src/lang.js @@ -0,0 +1,19 @@ +const fs = require("fs"); + +var lang = "en-US"; +if (fs.existsSync("viper.json")) { + lang = JSON.parse(fs.readFileSync("viper.json", "utf8")).lang; + if (! fs.existsSync(__dirname + `/lang/${lang}.json`)) { + lang = "en-US"; + } +} + +var langObj = JSON.parse(fs.readFileSync(__dirname + `/lang/${lang}.json`, "utf8")); + +module.exports = (string) => { + if (langObj[string]) { + return langObj[string]; + } else { + return string + } +} diff --git a/src/lang/en-US.json b/src/lang/en-US.json new file mode 100644 index 0000000..2322369 --- /dev/null +++ b/src/lang/en-US.json @@ -0,0 +1,21 @@ +{ + "cli.help.help": "shows this help message", + "cli.help.debug": "opens the dev/debug tools", + "cli.help.cli": "forces the CLI to enable", + "cli.help.update": "updates Northstar from your set game path", + "cli.help.setpath": "sets your game path", + + "cli.setpath.noarg": "No argument provided for --setpath", + + + "gui.welcome": "Welcome to Viper!", + "gui.exit": "Exit", + "gui.update": "Update", + "gui.setpath": "Game Path", + + "gui.launch": "Launch", + "gui.launchvanilla": "Vanilla", + "gui.launchnorthstar": "Northstar", + + "gui.missinggamepath": "Game path is not set! Please select the path!" +} -- cgit v1.2.3 From aefef2040280ae9e4292c39df65f2b378128aa07 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 29 Dec 2021 00:39:52 +0100 Subject: uses navigator.language to determine language --- src/app/main.js | 3 +++ src/index.js | 1 + src/utils.js | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/app') diff --git a/src/app/main.js b/src/app/main.js index a3a5676..579f785 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -7,12 +7,15 @@ const lang = require("../lang"); var settings = { gamepath: "", zip: "/northstar.zip", + lang: navigator.language, excludes: [ "ns_startup_args.txt", "ns_startup_args_dedi.txt" ] } +ipcRenderer.send("setlang", settings.lang); + if (fs.existsSync("viper.json")) { settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))}; settings.zip = path.join(settings.gamepath + "/northstar.zip"); diff --git a/src/index.js b/src/index.js index 4e64414..fead15b 100644 --- a/src/index.js +++ b/src/index.js @@ -33,6 +33,7 @@ function start() { } ipcMain.on("launch", (event) => {utils.launch()}) +ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)}) ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")}) ipcMain.on("update", (event) => {utils.update()}) diff --git a/src/utils.js b/src/utils.js index 85ce5ce..ec15554 100644 --- a/src/utils.js +++ b/src/utils.js @@ -16,6 +16,7 @@ process.chdir(app.getPath("appData")); var settings = { gamepath: "", + lang: "en-US", zip: "/northstar.zip", excludes: [ "ns_startup_args.txt", @@ -30,7 +31,6 @@ if (fs.existsSync("viper.json")) { console.log("Game path is not set! Please select the path."); } - function setpath(win) { if (! win) { settings.gamepath = cli.param("setpath"); @@ -110,4 +110,8 @@ module.exports = { update, setpath, settings, + setlang: (lang) => { + settings.lang = lang; + saveSettings(); + }, } -- cgit v1.2.3 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/app/index.html | 8 +++++++- src/app/main.css | 6 ++++++ src/index.js | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/app') diff --git a/src/app/index.html b/src/app/index.html index 1c34360..a73422f 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -6,7 +6,13 @@
-
%%gui.welcome%%
+
+
%%gui.welcome%%
+
+
Viper version: x.x.x
+
Northstar version: x.x.x
+
+
diff --git a/src/app/main.css b/src/app/main.css index 854c47a..f3cd7c5 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -61,3 +61,9 @@ button:active { #setpath {background: #5E81AC} #northstar {background: #C7777F} #vanilla, #exit {background: #656E7F} + +.versions { + height: 15px; + font-size: 12px; + color: #afafaf; +} \ No newline at end of file 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 474f2ae54000463a0a2dfc84ad678a7620cc3d44 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 29 Dec 2021 22:59:47 +0100 Subject: proper responsiveness for all languages This should more or less ensure everything remains responsive even if the language is one with very long strings. --- src/app/index.html | 2 +- src/app/lang.js | 16 +++++++++------- src/app/main.css | 5 +++++ src/app/main.js | 5 +++++ src/index.js | 12 +++++++++--- 5 files changed, 29 insertions(+), 11 deletions(-) (limited to 'src/app') diff --git a/src/app/index.html b/src/app/index.html index 1c34360..426b4c5 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -22,7 +22,7 @@
- + diff --git a/src/app/lang.js b/src/app/lang.js index 8cf3d4b..5cc9708 100644 --- a/src/app/lang.js +++ b/src/app/lang.js @@ -1,10 +1,12 @@ -html = document.body.innerHTML.split("%%"); +function setlang() { + html = document.body.innerHTML.split("%%"); -for (let i = 0; i < html.length; i++) { - if (html[i][0] != " " && - html[i][html[i].length - 1] != " ") { - html[i] = lang(html[i]) + for (let i = 0; i < html.length; i++) { + if (html[i][0] != " " && + html[i][html[i].length - 1] != " ") { + html[i] = lang(html[i]) + } } -} -document.body.innerHTML = html.join(""); + document.body.innerHTML = html.join(""); +} diff --git a/src/app/main.css b/src/app/main.css index 854c47a..c9c62fb 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -34,10 +34,14 @@ body, button, input { } .buttons { + text-align: right; margin-left: auto; margin-right: 7px; } +.text {max-width: 38vw} +.buttons {max-width: 55vw} + button, .text { border: none; outline: none; @@ -47,6 +51,7 @@ button, .text { } button { + margin-bottom: 10px; color: var(--btnforeground); -webkit-app-region: no-drag; } diff --git a/src/app/main.js b/src/app/main.js index 579f785..0118b0c 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; }) + +setlang(); +setInterval(() => { + ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 25); +}, 150) diff --git a/src/index.js b/src/index.js index fead15b..74f776c 100644 --- a/src/index.js +++ b/src/index.js @@ -9,9 +9,10 @@ const utils = require("./utils"); const cli = require("./cli"); function start() { + let width = 115; win = new BrowserWindow({ width: 600, - height: 115, + height: width, show: false, title: "Viper", resizable: false, @@ -26,10 +27,15 @@ function start() { win.removeMenu(); win.loadFile(__dirname + "/app/index.html"); - win.webContents.once("dom-ready", () => {win.show()}); - ipcMain.on("setpath", (event) => {utils.setpath(win)}) ipcMain.on("exit", (event) => {process.exit(0)}) + ipcMain.on("setpath", (event) => {utils.setpath(win)}) + ipcMain.on("setsize", (event, height) => { + win.setSize(width, height); + if (! win.isVisible()) { + win.show(); + } + }) } ipcMain.on("launch", (event) => {utils.launch()}) -- cgit v1.2.3 From ebe304c7894ffb19b1f6d5db3fb77961101412ff Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 29 Dec 2021 23:06:32 +0100 Subject: make sure doesn't get deprecated --- src/app/main.css | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/app') diff --git a/src/app/main.css b/src/app/main.css index c9c62fb..f49cc98 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -28,6 +28,8 @@ body, button, input { font-family: "Roboto Mono", monospace; } +nobr {white-space: nowrap} + .line { display: flex; margin-top: 15px; -- cgit v1.2.3 From c4f2a15a05ed8821009f88be8a93d71ed1da3d81 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 29 Dec 2021 23:45:03 +0100 Subject: fix incorrect padding --- src/app/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app') diff --git a/src/app/main.js b/src/app/main.js index 0118b0c..9bafaa5 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -37,5 +37,5 @@ ipcRenderer.on("newpath", (event, newpath) => { setlang(); setInterval(() => { - ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 25); + ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 20); }, 150) -- cgit v1.2.3 From d402e6236b6d0523a1dfce0c9203f1cbeb907e4f Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Thu, 30 Dec 2021 00:03:53 +0100 Subject: [feat] adding div ids to version indicators --- src/app/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/app') diff --git a/src/app/index.html b/src/app/index.html index a73422f..c486f28 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
+
Viper version: x.x.x
+
Northstar version: x.x.x
-- 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/app') 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/app') 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 74cb566e5ea97f62121fbd7b2cc170b94d36f0bb Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Thu, 30 Dec 2021 00:24:57 +0100 Subject: [fix] displaying welcome message on one line --- src/app/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app') diff --git a/src/app/index.html b/src/app/index.html index 3eadd96..6e31f0c 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -7,7 +7,7 @@
-
%%gui.welcome%%
+
%%gui.welcome%%
Viper version: x.x.x
Northstar version: x.x.x
-- cgit v1.2.3