From 26f14a674e828eb1b4bf44d7bc977a950002db29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Feb 2022 16:07:46 +0000 Subject: Bump follow-redirects from 1.14.7 to 1.14.8 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 92141bf..c5516b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "GPL-3.0-or-later", "dependencies": { "electron-updater": "^4.6.1", - "follow-redirects": "^1.14.7", + "follow-redirects": "^1.14.8", "fs-extra": "^10.0.0", "fuse.js": "^6.5.3", "marked": "^4.0.10", @@ -1452,9 +1452,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.14.7", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", - "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", + "version": "1.14.8", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", + "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==", "funding": [ { "type": "individual", @@ -4361,9 +4361,9 @@ } }, "follow-redirects": { - "version": "1.14.7", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", - "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" + "version": "1.14.8", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", + "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==" }, "fs-extra": { "version": "10.0.0", diff --git a/package.json b/package.json index f53b62a..c5b54c4 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "homepage": "https://github.com/0neGal/viper#readme", "dependencies": { "electron-updater": "^4.6.1", - "follow-redirects": "^1.14.7", + "follow-redirects": "^1.14.8", "fs-extra": "^10.0.0", "fuse.js": "^6.5.3", "marked": "^4.0.10", -- cgit v1.2.3 From dd987883014e2b6edf5c065eb62aa059533efa72 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 15 Feb 2022 17:50:59 +0100 Subject: bumped version number to 1.2.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c5516b5..e357551 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "viper", - "version": "1.2.1", + "version": "1.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "viper", - "version": "1.2.1", + "version": "1.2.2", "license": "GPL-3.0-or-later", "dependencies": { "electron-updater": "^4.6.1", diff --git a/package.json b/package.json index c5b54c4..e6288ff 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "viper", "productName": "Viper", - "version": "1.2.1", + "version": "1.2.2", "description": "Launcher+Updater for TF|2 Northstar", "main": "src/index.js", "build": { -- cgit v1.2.3 From c38abb7e16b8e59fb12f78df75f0de30e10946db Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 15 Feb 2022 18:48:14 +0100 Subject: updated download links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5650c12..9d425d0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@


-
+
Overview | Releases

@@ -15,9 +15,9 @@ Downloads are available on the [releases page](https://github.com/0neGal/viper/r Please note that some versions will update themselves automatically when a new release is available (just like Origin or Steam) and some will NOT, so choose it accordingly. Only the AppImage and Windows Setup/Installer can auto-update. -**Windows:** [`Viper Setup [x.y.z].exe`](https://github.com/0neGal/viper/releases/download/v1.2.1/Viper-Setup-1.2.1.exe) (auto-updates, and is recommanded), [`Viper [x.y.z].exe`](https://github.com/0neGal/viper/releases/download/v1.2.1/Viper-1.2.1.exe) (single executable, no fuss) +**Windows:** [`Viper Setup [x.y.z].exe`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-Setup-1.2.2.exe) (auto-updates, and is recommanded), [`Viper [x.y.z].exe`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-1.2.2.exe) (single executable, no fuss) -**Linux:** [`.AppImage`](https://github.com/0neGal/viper/releases/download/v1.2.1/Viper-1.2.1.AppImage) (auto-updates), [`.deb`](https://github.com/0neGal/viper/releases/download/v1.2.1/viper-1.2.1_amd64.deb), [`.rpm`](https://github.com/0neGal/viper/releases/download/v1.2.1/Viper-1.2.1.x86_64.rpm), [`.tar.gz`](https://github.com/0neGal/viper/releases/download/v1.2.1/Viper-1.2.1.tar.gz) +**Linux:** [`.AppImage`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-1.2.2.AppImage) (auto-updates), [`.deb`](https://github.com/0neGal/viper/releases/download/v1.2.2/viper-1.2.2_amd64.deb), [`.rpm`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-1.2.2.x86_64.rpm), [`.tar.gz`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-1.2.2.tar.gz) ## What can it do specifically? -- cgit v1.2.3 From ee7dab5b056e254bff828a9b9f6d77be2287b935 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Thu, 17 Feb 2022 23:07:18 +0100 Subject: fixed buttons not re-enabling when closing install If you closed the file selection window after clicking the "Install Mod" button it would improperly try to install "nothing", and therefore never re-enable the buttons, this is now fixed. --- src/app/main.js | 2 ++ src/index.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/main.js b/src/app/main.js index 169f86f..7c71c9d 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -78,6 +78,8 @@ function setButtons(state) { disablearray(document.querySelectorAll("#browser #browserEntries .text button")) } +ipcRenderer.on("setbuttons", (event, state) => {setButtons(state)}) + // Frontend part of updating Northstar ipcRenderer.on("ns-update-event", (event, key) => { document.getElementById("update").innerText = `(${lang(key)})`; diff --git a/src/index.js b/src/index.js index a06cf69..344ac6c 100644 --- a/src/index.js +++ b/src/index.js @@ -76,7 +76,11 @@ ipcMain.on("installmod", () => { utils.mods.install(cli.param("installmod")) } else { dialog.showOpenDialog({properties: ["openFile"]}).then(res => { - utils.mods.install(res.filePaths[0]); + if (res.filePaths.length != 0) { + utils.mods.install(res.filePaths[0]); + } else { + win.webContents.send("setbuttons", true); + } }).catch(err => {console.error(err)}) } }) -- cgit v1.2.3 From 78a83334f42294fdc0e36c2c44e1fbff7369fd7c Mon Sep 17 00:00:00 2001 From: 0neGal Date: Fri, 18 Feb 2022 22:13:08 +0100 Subject: basic drag and drop support Since apparently dragleave and dragenter don't quite work as intended we have to resort to this obscure method which should work just fine on the user's end. --- src/app/icons/download.png | Bin 0 -> 2200 bytes src/app/index.html | 6 +++++ src/app/main.css | 58 ++++++++++++++++++++++++++++++++++++++++++++- src/app/main.js | 33 +++++++++++++++++++++++++- src/index.js | 2 ++ src/lang/en.json | 1 + 6 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 src/app/icons/download.png diff --git a/src/app/icons/download.png b/src/app/icons/download.png new file mode 100644 index 0000000..189c50d Binary files /dev/null and b/src/app/icons/download.png differ diff --git a/src/app/index.html b/src/app/index.html index 8222416..b5fc8cb 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -14,6 +14,12 @@
+
+
+
+
%%gui.mods.dragdrop%%
+
+
diff --git a/src/app/main.css b/src/app/main.css index a532490..dcc4e8a 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -38,11 +38,15 @@ body { margin: 0; overflow: hidden; - user-select: none; } body, button, input {font-family: "Roboto", sans-serif} +body, button, img, a { + -webkit-user-drag: none; + user-select: none; +} + button {outline: none} b, strong {font-weight: 700} body, input, button {font-weight: 500} @@ -612,6 +616,58 @@ code { font-weight: 600; } +#dragUI { + top: 0; + left: 0; + right: 0; + bottom: 0; + color: white; + opacity: 0.0; + position: fixed; + z-index: 1000000; + pointer-events: none; + background: var(--bg); + backdrop-filter: blur(15px); + transition: 0.1s ease-in-out; +} + +#dragUI.shown { + opacity: 1.0; + pointer-events: all; +} + +#dragUI #dragitems { + --size: 25vw; + top: 50%; + left: 50%; + opacity: 0.6; + position: absolute; + text-align: center; + width: var(--size); + height: var(--size); + margin-top: calc(var(--size) / 2 * -1); + margin-left: calc(var(--size) / 2 * -1); +} + +#dragUI #dragitems #icon { + width: 100%; + height: 100%; + filter: invert(1); + transform: scale(0.45); + background-size: cover; + background-image: url("icons/download.png"); + transition: 0.1s ease-in-out; +} + +#dragUI.shown #dragitems #icon { + transform: scale(0.5); +} + +#dragUI #dragitems #text { + top: -5vw; + position: relative; +} + /* drag control */ #bgHolder, diff --git a/src/app/main.js b/src/app/main.js index 7c71c9d..97937a9 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -158,12 +158,18 @@ function selected(all) { } } -// Tells the main process to install a mod +// Tells the main process to install a mod through the file selector function installmod() { setButtons(false); ipcRenderer.send("installmod") } +// Tells the main process to directly install a mod from this path +function installFromPath(path) { + setButtons(false); + ipcRenderer.send("installfrompath", path) +} + // Tells the main process to install a mod from a URL function installFromURL(url) { setButtons(false); @@ -244,6 +250,31 @@ ipcRenderer.on("wrongpath", () => { setlang(); +let dragtimer; +document.addEventListener("dragover", (e) => { + e.preventDefault(); + e.stopPropagation(); + dragUI.classList.add("shown"); + + clearTimeout(dragtimer); + dragtimer = setTimeout(() => { + dragUI.classList.remove("shown"); + }, 5000) +}); + +document.addEventListener("mouseover", (e) => { + clearTimeout(dragtimer); + dragUI.classList.remove("shown"); +}); + +document.addEventListener("drop", (e) => { + event.preventDefault(); + event.stopPropagation(); + + dragUI.classList.remove("shown"); + installFromPath(event.dataTransfer.files[0].path) +}); + document.body.addEventListener("click", event => { if (event.target.tagName.toLowerCase() === "a" && event.target.protocol != "file:") { event.preventDefault(); diff --git a/src/index.js b/src/index.js index 344ac6c..e44b549 100644 --- a/src/index.js +++ b/src/index.js @@ -43,6 +43,7 @@ function start() { ipcMain.on("exit", () => {process.exit(0)}) ipcMain.on("minimize", () => {win.minimize()}) + ipcMain.on("installfrompath", (event, path) => {utils.mods.install(path)}) ipcMain.on("installfromurl", (event, url) => {utils.mods.installFromURL(url)}) ipcMain.on("winLog", (event, ...args) => {win.webContents.send("log", ...args)}); ipcMain.on("winAlert", (event, ...args) => {win.webContents.send("alert", ...args)}); @@ -173,6 +174,7 @@ if (cli.hasArgs()) { cli.init(); } } else { + app.disableHardwareAcceleration(); app.on("ready", () => { app.setPath("userData", path.join(app.getPath("cache"), app.name)); start(); diff --git a/src/lang/en.json b/src/lang/en.json index 27630ec..45bf7c0 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -62,6 +62,7 @@ "gui.mods.extracting": "Extracting mod...", "gui.mods.installing": "Installing mod...", "gui.mods.installedmod": "Installed mod!", + "gui.mods.dragdrop": "Drag and drop a mod to install", "gui.browser.info": "Info", "gui.browser.madeby": "by", -- cgit v1.2.3 From d271a1c74cce1ef75672a1ff2888862ee1fc393c Mon Sep 17 00:00:00 2001 From: 0neGal Date: Fri, 18 Feb 2022 22:23:06 +0100 Subject: fix being able to upload any file Usually utils.js would default to simply unzipping whatever was uploaded if it wasn't a folder, now we check if it has "zip" as the extension, case insensitive. If not simply report back the file wasn't a mod. As opposed to the obscure error you got before this. --- src/utils.js | 62 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/utils.js b/src/utils.js index 1448007..2ea91cd 100644 --- a/src/utils.js +++ b/src/utils.js @@ -544,40 +544,44 @@ const mods = { } try { - fs.createReadStream(mod).pipe(unzip.Extract({path: cache})) - .on("finish", () => { - setTimeout(() => { - let manifest = path.join(cache, "manifest.json"); - if (fs.existsSync(manifest)) { - files = fs.readdirSync(path.join(cache, "mods")); - if (fs.existsSync(path.join(cache, "mods/mod.json"))) { - if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest, true)) { - return true; - } - } else { - for (let i = 0; i < files.length; i++) { - let mod = path.join(cache, "mods", files[i]); - if (fs.statSync(mod).isDirectory()) { - setTimeout(() => { - if (mods.install(mod, false, manifest)) {return true}; - }, 1000) + if (mod.replace(/.*\./, "").toLowerCase() == "zip") { + fs.createReadStream(mod).pipe(unzip.Extract({path: cache})) + .on("finish", () => { + setTimeout(() => { + let manifest = path.join(cache, "manifest.json"); + if (fs.existsSync(manifest)) { + files = fs.readdirSync(path.join(cache, "mods")); + if (fs.existsSync(path.join(cache, "mods/mod.json"))) { + if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest, true)) { + return true; + } + } else { + for (let i = 0; i < files.length; i++) { + let mod = path.join(cache, "mods", files[i]); + if (fs.statSync(mod).isDirectory()) { + setTimeout(() => { + if (mods.install(mod, false, manifest)) {return true}; + }, 1000) + } } - } - if (files.length == 0) { - ipcMain.emit("failedmod"); - return notamod(); + if (files.length == 0) { + ipcMain.emit("failedmod"); + return notamod(); + } } - } - return notamod(); - } + return notamod(); + } - if (mods.install(cache)) { - installed(); - } else {return notamod()} - }, 1000) - }); + if (mods.install(cache)) { + installed(); + } else {return notamod()} + }, 1000) + }); + } else { + return notamod(); + } }catch(err) {return notamod()} } }, -- cgit v1.2.3 From 6289ee5b03eaf27c188eb68c9f8375ec6fc8ec2f Mon Sep 17 00:00:00 2001 From: 0neGal Date: Fri, 18 Feb 2022 23:21:49 +0100 Subject: fix hardware acceleration being disabled This was due to me testing something, not actually supposed to be in release builds... --- src/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.js b/src/index.js index e44b549..95115b4 100644 --- a/src/index.js +++ b/src/index.js @@ -174,7 +174,6 @@ if (cli.hasArgs()) { cli.init(); } } else { - app.disableHardwareAcceleration(); app.on("ready", () => { app.setPath("userData", path.join(app.getPath("cache"), app.name)); start(); -- cgit v1.2.3 From 157739cbdcb82e3fd417a031ac93b2fae719ae4b Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Sat, 19 Feb 2022 11:39:41 +0100 Subject: [feat] french gui.mods.dragdrop key --- src/lang/fr.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lang/fr.json b/src/lang/fr.json index 3bdeec6..14bae37 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -62,6 +62,7 @@ "gui.mods.extracting": "Extraction du mod...", "gui.mods.installing": "Installation du mod...", "gui.mods.installedmod": "Mod installé !", + "gui.mods.dragdrop": "Glissez/déposez un mod pour l'installer", "gui.browser.info": "Info", "gui.browser.madeby": "par", -- cgit v1.2.3 From 766bf76cc2ae84cf90fc474060db4a9842d35b20 Mon Sep 17 00:00:00 2001 From: Delta <31860825+AA-Delta@users.noreply.github.com> Date: Sat, 19 Feb 2022 08:22:40 -0500 Subject: feat: Spanish "gui.mods.dragdrop" key #81 --- src/lang/es.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lang/es.json b/src/lang/es.json index 8beabef..3d92d5a 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -62,6 +62,7 @@ "gui.mods.extracting": "Extrayendo modificación...", "gui.mods.installing": "Instalando modificación...", "gui.mods.installedmod": "¡Modificación instalada!", + "gui.mods.dragdrop": "Arrastra y suelta una modificación para instalarla" "gui.browser.info": "Información", "gui.browser.madeby": "por", -- cgit v1.2.3 From 47f2e089dc94cbb33800313173548cb15f0aeec1 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 19 Feb 2022 21:15:20 +0100 Subject: fix missing comma in es.json --- src/lang/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lang/es.json b/src/lang/es.json index 3d92d5a..450d559 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -62,7 +62,7 @@ "gui.mods.extracting": "Extrayendo modificación...", "gui.mods.installing": "Instalando modificación...", "gui.mods.installedmod": "¡Modificación instalada!", - "gui.mods.dragdrop": "Arrastra y suelta una modificación para instalarla" + "gui.mods.dragdrop": "Arrastra y suelta una modificación para instalarla", "gui.browser.info": "Información", "gui.browser.madeby": "por", -- cgit v1.2.3 From a3741b2934a8c8dffd3f665576f33324e89a4a1b Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 19 Feb 2022 22:05:05 +0100 Subject: updated build scripts/code tests build/langs.js now gives more info and has colors. It also changes it's exit code if an error happened, we then use that in build/publish.sh to catch localization errors before publishing. We also ensure that version numbers are set correctly. Then at last we will make sure $GH_TOKEN is set, and if not, prompt for the token, to make sure you don't build everything then error out when you forgot to put in your token. --- build/langs.js | 24 +++++++++++++++++++++--- build/publish.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100755 build/publish.sh diff --git a/build/langs.js b/build/langs.js index 9e21dff..e870a3c 100644 --- a/build/langs.js +++ b/build/langs.js @@ -1,5 +1,6 @@ const fs = require("fs"); +let problems = false; let lang = require("../src/lang/en.json"); let maintainers = require("../src/lang/maintainers.json"); @@ -9,7 +10,14 @@ langs.forEach((localefile) => { let missing = []; let langmaintainers = maintainers.list[localefile.replace(/\..*$/, "")]; - let locale = require("../src/lang/" + localefile) + let locale = false; + try { + locale = require("../src/lang/" + localefile) + }catch(err) { + console.log(`\x1b[101m!! ${localefile} is not formatted right !!\x1b[0m`); + return + } + for (let i in lang) { if (! locale[i]) { missing.push(i); @@ -17,16 +25,26 @@ langs.forEach((localefile) => { } if (missing.length > 0) { + problems = true; + console.error(`${localefile} is missing:`) for (let i in missing) { - console.log(` ${missing[i]}`) + console.log(`\x1b[31m ${missing[i]}\x1b[0m`) } console.log() - console.log("Maintainers of language: ") + console.log("Maintainers: ") for (let i in langmaintainers) { console.log(` ${langmaintainers[i]}`) } + + console.log("\n") } }) + +if (! problems) { + console.log("\x1b[32mAll localizations are complete and formatted properly.\x1b[0m"); +} else { + process.exit(1); +} diff --git a/build/publish.sh b/build/publish.sh new file mode 100755 index 0000000..c8f7832 --- /dev/null +++ b/build/publish.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +VERSION="v$(jq '.version' package.json -r)" +LOCK1="v$(jq '.version' package-lock.json -r)" +LOCK2="v$(jq '.packages[""].version' package-lock.json -r)" + +REPO="$(jq '.repository.url' package.json -r | sed 's/.*.com\///g')" + +REMOTEVERSION="$(curl --silent "https://api.github.com/repos/0neGal/viper/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" + +[ "$REMOTEVERSION" = "$VERSION" ] && { + echo "A release already exists with the current version number!" + exit 1 +} + +[ "$VERSION" != "$LOCK1" ] && { + echo "Two seperate version numbers in package.json and package-lock.json" + echo " $VERSION, $LOCK1" + exit 1 +} + +[ "$LOCK1" != "$LOCK2" ] && { + echo "Version mismatches in package-lock.json" + echo " $LOCK1, $LOCK2" + exit 1 +} + + +node build/langs.js || { + echo "Please fix localization errors before publishing..." + exit 1 +} + +GH_TOKEN="$GH_TOKEN" + +[ "$GH_TOKEN" = "" ] && { + echo "GH_TOKEN is not set, please type it below:" + read -p "> " GH_TOKEN +} + +npm run publish -- cgit v1.2.3 From 23645e411d9015b5738381323c9151fb075a062f Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 19 Feb 2022 22:07:39 +0100 Subject: bumped version number to 1.2.3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e357551..50ab0c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "viper", - "version": "1.2.2", + "version": "1.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "viper", - "version": "1.2.2", + "version": "1.2.3", "license": "GPL-3.0-or-later", "dependencies": { "electron-updater": "^4.6.1", diff --git a/package.json b/package.json index e6288ff..93f3789 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "viper", "productName": "Viper", - "version": "1.2.2", + "version": "1.2.3", "description": "Launcher+Updater for TF|2 Northstar", "main": "src/index.js", "build": { -- cgit v1.2.3 From 83469ae18e04c3e812c32c4e6a8dc10c9f74ee54 Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Fri, 7 Jan 2022 21:42:21 +0100 Subject: [fix] loading up translation object each time a translation is needed --- src/lang.js | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/lang.js b/src/lang.js index b3cbb43..3e0ca42 100644 --- a/src/lang.js +++ b/src/lang.js @@ -1,35 +1,34 @@ const fs = require("fs"); -var lang = "en"; // Default language +const enLang = JSON.parse(fs.readFileSync(__dirname + `/lang/en.json`, "utf8")); +let lang = "en"; +var langObj = {}; -// Loads fallback/default language strings -var langDef = JSON.parse(fs.readFileSync(__dirname + `/lang/en.json`, "utf8")); -// If settins are set it'll try to set the language to that instead of -// the default, however if it can't find it, it'll still fallback to the -// default language. This might happen as the default language is -// retrieved from the renderer's navigator.language, which may have -// languages we don't support yet. -if (fs.existsSync("viper.json")) { - lang = JSON.parse(fs.readFileSync("viper.json", "utf8")).lang; - if (! lang) {lang = "en"} // Uses fallback, if language isn't set - if (! fs.existsSync(__dirname + `/lang/${lang}.json`)) { - if (fs.existsSync(__dirname + `/lang/${lang.replace(/-.*$/, "")}.json`)) { - lang = lang.replace(/-.*$/, ""); - } else { - lang = "en"; // Uses fallback if language doesn't exist +function _loadTranslation() { + if (fs.existsSync("viper.json")) { + lang = JSON.parse(fs.readFileSync("viper.json", "utf8")).lang; + if (! lang) {lang = "en"} + if (! fs.existsSync(__dirname + `/lang/${lang}.json`)) { + if (fs.existsSync(__dirname + `/lang/${lang.replace(/-.*$/, "")}.json`)) { + lang = lang.replace(/-.*$/, ""); + } else { + lang = "en"; + } } } + langObj = JSON.parse(fs.readFileSync(__dirname + `/lang/${lang}.json`, "utf8")); } -var langObj = JSON.parse(fs.readFileSync(__dirname + `/lang/${lang}.json`, "utf8")); module.exports = (string) => { - if (langObj[string]) { // Returns string from language + _loadTranslation(); + + if (langObj[string]) { return langObj[string]; - } else { // If string doesn't exist - if (langDef[string]) { // Retrieves from default lang instead - return langDef[string]; + } else { + if (enLang[string]) { + return enLang[string]; } else { // If it's not in the default lang either, it returns the // string, this is absolute fallback. -- cgit v1.2.3 From 17947210b3fc9bac6ea2219655c73af07113690e Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Sat, 8 Jan 2022 15:00:38 +0100 Subject: [fix] translation file is only loaded is current context didn't set up lang variable --- src/lang.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lang.js b/src/lang.js index 3e0ca42..8174174 100644 --- a/src/lang.js +++ b/src/lang.js @@ -1,7 +1,7 @@ const fs = require("fs"); const enLang = JSON.parse(fs.readFileSync(__dirname + `/lang/en.json`, "utf8")); -let lang = "en"; +let lang = ""; var langObj = {}; @@ -16,13 +16,16 @@ function _loadTranslation() { lang = "en"; } } + } else { + lang = "en"; } langObj = JSON.parse(fs.readFileSync(__dirname + `/lang/${lang}.json`, "utf8")); } module.exports = (string) => { - _loadTranslation(); + if (lang === "") + _loadTranslation(); if (langObj[string]) { return langObj[string]; -- cgit v1.2.3 From 002d14d8094e950caa72d612e8ddac881c1ea7ff Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 19 Feb 2022 22:57:47 +0100 Subject: updated download links to 1.2.3 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9d425d0..ca98f9e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@


-
+
Overview | Releases

@@ -15,9 +15,9 @@ Downloads are available on the [releases page](https://github.com/0neGal/viper/r Please note that some versions will update themselves automatically when a new release is available (just like Origin or Steam) and some will NOT, so choose it accordingly. Only the AppImage and Windows Setup/Installer can auto-update. -**Windows:** [`Viper Setup [x.y.z].exe`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-Setup-1.2.2.exe) (auto-updates, and is recommanded), [`Viper [x.y.z].exe`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-1.2.2.exe) (single executable, no fuss) +**Windows:** [`Viper Setup [x.y.z].exe`](https://github.com/0neGal/viper/releases/download/v1.2.3/Viper-Setup-1.2.3.exe) (auto-updates, and is recommanded), [`Viper [x.y.z].exe`](https://github.com/0neGal/viper/releases/download/v1.2.3/Viper-1.2.3.exe) (single executable, no fuss) -**Linux:** [`.AppImage`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-1.2.2.AppImage) (auto-updates), [`.deb`](https://github.com/0neGal/viper/releases/download/v1.2.2/viper-1.2.2_amd64.deb), [`.rpm`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-1.2.2.x86_64.rpm), [`.tar.gz`](https://github.com/0neGal/viper/releases/download/v1.2.2/Viper-1.2.2.tar.gz) +**Linux:** [`.AppImage`](https://github.com/0neGal/viper/releases/download/v1.2.3/Viper-1.2.3.AppImage) (auto-updates), [`.deb`](https://github.com/0neGal/viper/releases/download/v1.2.3/viper-1.2.3_amd64.deb), [`.rpm`](https://github.com/0neGal/viper/releases/download/v1.2.3/Viper-1.2.3.x86_64.rpm), [`.tar.gz`](https://github.com/0neGal/viper/releases/download/v1.2.3/Viper-1.2.3.tar.gz) ## What can it do specifically? -- cgit v1.2.3 From 3a2f9fac72d141f6a5e2e56133a5ae77d6972680 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sun, 20 Feb 2022 20:31:50 +0100 Subject: initial work on settings page This only has the actual UI for the settings page in place, no actual functionality has been implemented yet. I made several changes not directly related to the settings page, such as changes the CSS color variables to use RGB, as to easily add an alpha channel to colors. I also changed the way the Browser is toggled in some respects and many other changes that makes it easy to re-use the browser code to create the settings UI --- src/app/browser.js | 4 -- src/app/icons/apply.png | Bin 0 -> 2555 bytes src/app/icons/settings.png | Bin 0 -> 2496 bytes src/app/index.html | 50 ++++++++++++++++- src/app/main.css | 134 +++++++++++++++++++++++++++++++++------------ src/app/main.js | 7 +++ src/app/settings.js | 46 ++++++++++++++++ 7 files changed, 198 insertions(+), 43 deletions(-) create mode 100644 src/app/icons/apply.png create mode 100644 src/app/icons/settings.png create mode 100644 src/app/settings.js diff --git a/src/app/browser.js b/src/app/browser.js index ded12fa..275e16e 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -104,10 +104,6 @@ var Browser = { } } -document.body.addEventListener("keyup", (e) => { - if (e.key == "Escape") {Browser.toggle(false)} -}) - function BrowserElFromObj(obj) { let pkg = {...obj, ...obj.versions[0]}; diff --git a/src/app/icons/apply.png b/src/app/icons/apply.png new file mode 100644 index 0000000..915f809 Binary files /dev/null and b/src/app/icons/apply.png differ diff --git a/src/app/icons/settings.png b/src/app/icons/settings.png new file mode 100644 index 0000000..3f7715a Binary files /dev/null and b/src/app/icons/settings.png differ diff --git a/src/app/index.html b/src/app/index.html index b5fc8cb..5ca9306 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -10,6 +10,7 @@
+
@@ -21,9 +22,51 @@
-
-
-
+
+ + +
diff --git a/src/app/main.css b/src/app/main.css index 09dc4b3..0d4b9ad 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -236,7 +236,14 @@ button { justify-content: space-between; } -.option .actions text {opacity: 0.8} +.option .text {font-weight: 600} +.option .text .desc { + opacity: 0.8; + font-weight: 500; + font-size: 0.9em; + max-width: 400px; + margin-top: calc(var(--padding) / 3); +} .option .actions input { width: 100%; -- cgit v1.2.3 From 132fea11e3599c9c2c9df8a69fd4d093033788ba Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 21 Feb 2022 19:31:33 +0100 Subject: some functionality is now present Albeit only frontend functionality, it doesn't actually save your settings, it simply loads them, and Settings.get(), allows you to convert them to a format that can be used to save settings. --- src/app/index.html | 8 ++++---- src/app/main.js | 2 ++ src/app/settings.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++- src/utils.js | 2 ++ 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/app/index.html b/src/app/index.html index 7a919b1..0bd6694 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -37,7 +37,7 @@

Northstar

-
+
Launch options
@@ -49,7 +49,7 @@

Updates

-
+
Viper Auto-Updates
@@ -60,7 +60,7 @@
-
+
Northstar Auto-Updates
@@ -71,7 +71,7 @@
-
+
Retain files on update
diff --git a/src/app/main.js b/src/app/main.js index db3514b..a781ef1 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -8,7 +8,9 @@ let shouldInstallNorthstar = false; // Base settings var settings = { + nsargs: "", gamepath: "", + nsupdate: true, autoupdate: true, zip: "/northstar.zip", lang: navigator.language, diff --git a/src/app/settings.js b/src/app/settings.js index c9e43ae..e558d61 100644 --- a/src/app/settings.js +++ b/src/app/settings.js @@ -1,6 +1,7 @@ var Settings = { toggle: (state) => { if (state) { + Settings.load(); options.scrollTo(0, 0); overlay.classList.add("shown") options.classList.add("shown") @@ -14,6 +15,7 @@ var Settings = { } } + Settings.load(); options.scrollTo(0, 0); overlay.classList.toggle("shown") options.classList.toggle("shown") @@ -39,8 +41,60 @@ var Settings = { } Settings.reloadSwitches(); + }, + get: () => { + let opts = {}; + let options = document.querySelectorAll(".option"); + + for (let i = 0; i < options.length; i++) { + let optName = options[i].getAttribute("name"); + if (options[i].querySelector(".actions input")) { + let input = options[i].querySelector(".actions input").value; + if (options[i].getAttribute("type")) { + opts[optName] = input.split(" "); + } else { + opts[optName] = input; + } + } else if (options[i].querySelector(".actions .switch")) { + if (options[i].querySelector(".actions .switch.on")) { + opts[optName] = true; + } else { + opts[optName] = false; + } + } + } + + return opts; + }, + load: () => { + let options = document.querySelectorAll(".option"); + + for (let i = 0; i < options.length; i++) { + let optName = options[i].getAttribute("name"); + if (settings[optName] != undefined) { + switch(typeof settings[optName]) { + case "string": + options[i].querySelector(".actions input").value = settings[optName]; + break + case "object": + options[i].querySelector(".actions input").value = settings[optName].join(" "); + break + case "boolean": + let switchDiv = options[i].querySelector(".actions .switch"); + if (settings[optName]) { + switchDiv.classList.add("on"); + switchDiv.classList.remove("off"); + } else { + switchDiv.classList.add("off"); + switchDiv.classList.remove("on"); + } + break + + } + } + } } } Settings.reloadSwitches(); - +Settings.load(); diff --git a/src/utils.js b/src/utils.js index 2ea91cd..b4dd920 100644 --- a/src/utils.js +++ b/src/utils.js @@ -20,8 +20,10 @@ process.chdir(app.getPath("appData")); // Base settings var settings = { + nsargs: "", gamepath: "", lang: "en-US", + nsupdate: true, autoupdate: true, zip: "/northstar.zip", -- cgit v1.2.3 From 848772b53a47eeb6e921e2a186332dbc2a95aadf Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Mon, 21 Feb 2022 21:29:34 +0100 Subject: [fix] updates checking order --- src/utils.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils.js b/src/utils.js index 2ea91cd..336017f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -73,9 +73,9 @@ async function isGameRunning() { // // It uses isGameRunning() to ensure it doesn't run while the game is // running, as that may have all kinds of issues. -northstar_auto_updates: { +function handleNorthstarAutoUpdating() { if (!settings.autoupdate || !fs.existsSync("viper.json") || settings.gamepath.length === 0) { - break northstar_auto_updates; + return; } async function _checkForUpdates() { @@ -306,7 +306,11 @@ function updatevp(autoinstall) { } autoUpdater.on("error", (info) => {cli.exit(1)}); - autoUpdater.on("update-not-available", (info) => {cli.exit()}); + autoUpdater.on("update-not-available", (info) => { + // only check for N* updates if Viper itself has no updates + handleNorthstarAutoUpdating(); + cli.exit(); + }); autoUpdater.checkForUpdatesAndNotify(); } -- cgit v1.2.3 From 815106a3e1214196b25a380d83e826473840f948 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 23 Feb 2022 18:17:56 +0100 Subject: settings page is now fully functional It actually saves settings, loads them properly and everything... --- src/app/index.html | 4 ++-- src/app/settings.js | 5 ++++- src/index.js | 2 ++ src/utils.js | 14 ++++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/index.html b/src/app/index.html index 0bd6694..f605136 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -26,11 +26,11 @@