From 72f85aa2297f5c46d029f1e25193aa98ced884c3 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Thu, 12 May 2022 01:34:07 +0200 Subject: initial draft for supporting dependencies This should allow you to install packages that have dependencies, however maybe not with the best UI/UX experience, as currently there's only an English localization, and we also install dependencies even if the dependency is already installed. --- src/lang/en.json | 1 + 1 file changed, 1 insertion(+) (limited to 'src/lang') diff --git a/src/lang/en.json b/src/lang/en.json index ee932a2..024b44a 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -68,6 +68,7 @@ "gui.mods.installing": "Installing mod...", "gui.mods.installedmod": "Installed mod!", "gui.mods.dragdrop": "Drag and drop a mod to install", + "gui.mods.confirmdependencies": "This package has dependencies, shown below, clicking \"Ok\" will install the package and the dependencies.\n\n", "gui.browser.info": "Info", "gui.browser.madeby": "by", -- cgit v1.2.3 From 71e4fd2600d015c4cf978cb448640efeabff3371 Mon Sep 17 00:00:00 2001 From: Delta <31860825+AA-Delta@users.noreply.github.com> Date: Thu, 12 May 2022 08:49:40 -0500 Subject: "gui.mods.confirmdependencies" "es" localization #122 --- src/lang/es.json | 1 + 1 file changed, 1 insertion(+) (limited to 'src/lang') diff --git a/src/lang/es.json b/src/lang/es.json index dbccad8..c2871f1 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -68,6 +68,7 @@ "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.confirmdependencies": "Este paquete tiene dependencias, se muestran abajo. Presionar \"Ok\" instalará el paquete y las dependencias.\n\n", "gui.browser.info": "Información", "gui.browser.madeby": "por", -- cgit v1.2.3 From 0b893f9f2b01196b583222df072ae51631457649 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 16 May 2022 20:09:43 +0200 Subject: a lot of stuff, but mainly a "Load more..." button In the past when more than 50 packages was loaded it'd simply display a "Maximum packages loaded" message, and it wasn't actually 50, as it just took the first 50 packages loaded, whether or not they were filtered out, so now that's fixed and a "Load more..." button has been added. With that comes some changes to the lang strings for "gui.browser.endoflist" and a new one "gui.browser.loadmore". I also fixed the filtered packages issue also occurring in searches. This will overall allow a user to more easily find the maximum amount of packages without loading literally over a hundred packages at once, not good for performance... --- src/app/browser.js | 89 +++++++++++++++++++++++++++++++++++++++++++++++++----- src/app/main.css | 4 +++ src/lang/en.json | 3 +- 3 files changed, 87 insertions(+), 9 deletions(-) (limited to 'src/lang') diff --git a/src/app/browser.js b/src/app/browser.js index 5c943ba..0646ad1 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -2,9 +2,21 @@ const Fuse = require("fuse.js"); var fuse; var packages = []; +var packagecount = 0; + var Browser = { maxentries: 50, filters: { + getpkgs: () => { + let pkgs = []; + for (let i in packages) { + if (! Browser.filters.isfiltered(packages[i].categories)) { + pkgs.push(packages[i]); + } + } + + return pkgs; + }, get: () => { let filtered = []; let unfiltered = []; @@ -81,6 +93,8 @@ var Browser = { }, loadfront: async () => { Browser.loading(); + + packagecount = 0; if (packages.length < 1) { packages = await (await fetch("https://northstar.thunderstore.io/api/v1/package/")).json(); @@ -90,8 +104,15 @@ var Browser = { }) } - for (let i in packages) { - new BrowserElFromObj(packages[i]); + let pkgs = Browser.filters.getpkgs(); + for (let i in pkgs) { + if (packagecount >= Browser.maxentries) { + Browser.endoflist(); + break + } + + new BrowserElFromObj(pkgs[i]); + packagecount++; } }, loading: (string) => { @@ -107,9 +128,31 @@ var Browser = { browserEntries.innerHTML = `
${lang('gui.browser.loading')}
`; } }, - endoflist: () => { - if (browserEntries.querySelector(".message")) {return} - browserEntries.innerHTML += `
${lang('gui.browser.endoflist')}
` + endoflist: (isEnd) => { + let pkgs = []; + let filtered = Browser.filters.getpkgs(); + for (let i = 0; i < filtered.length; i++) { + if ([packagecount + i]) { + pkgs.push(filtered[packagecount + i]); + } else { + break + } + } + + if (browserEntries.querySelector(".message")) { + browserEntries.querySelector(".message").remove(); + } + + if (pkgs.length == 0 || isEnd) { + browserEntries.innerHTML += `
${lang('gui.browser.endoflist')}
` + return + } + + browserEntries.innerHTML += `
` + loadmore.addEventListener("click", () => { + Browser.loadpkgs(pkgs); + Browser.endoflist(pkgs); + }) }, search: (string) => { Browser.loading(); @@ -120,8 +163,14 @@ var Browser = { return } + packagecount = 0; + + let count = 0; for (let i = 0; i < res.length; i++) { + if (count >= Browser.maxentries) {break} + if (Browser.filters.isfiltered(res[i].item.categories)) {continue} new BrowserElFromObj(res[i].item); + count++; } }, setbutton: (mod, string) => { @@ -157,6 +206,33 @@ var Browser = { } }, 1501) } + }, + loadpkgs: (pkgs, clear) => { + if (clear) {packagecount = 0} + + if (browserEntries.querySelector(".message")) { + browserEntries.querySelector(".message").remove(); + } + + let count = 0; + for (let i in pkgs) { + if (count >= Browser.maxentries) { + if (pkgs[i] === undefined) { + Browser.endoflist(true); + } + + Browser.endoflist(); + console.log(pkgs) + break + } + + try { + new BrowserElFromObj(pkgs[i]) + }catch(e) {} + + count++; + packagecount++; + } } } @@ -179,9 +255,6 @@ function BrowserElFromObj(obj) { function BrowserEl(properties) { if (Browser.filters.isfiltered(properties.categories)) {return} - let entries = browser.querySelectorAll(".el").length; - if (entries == Browser.maxentries) {Browser.endoflist();return} - properties = { title: "No name", version: "1.0.0", diff --git a/src/app/main.css b/src/app/main.css index 7b54ec7..d7f8284 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -245,6 +245,10 @@ button { font-weight: 700; } +.popup .message #loadmore { + background: rgb(var(--blue2)); +} + .popup .el .description {font-size: 0.8em} .popup .el button { background: rgb(var(--blue)); diff --git a/src/lang/en.json b/src/lang/en.json index 024b44a..345a83c 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -77,7 +77,8 @@ "gui.browser.install": "Install", "gui.browser.reinstall": "Re-Install", "gui.browser.loading": "Loading mods...", - "gui.browser.endoflist": "Maximum packages has been loaded.
Use the search for finding other packages!", + "gui.browser.loadmore": "Load more...", + "gui.browser.endoflist": "All packages have been loaded.", "gui.browser.noresults": "No results...", "gui.browser.filter.mods": "Mods", "gui.browser.filter.skins": "Skins", -- cgit v1.2.3 From bb5446be8164176219784290f18751c6f35c4047 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 17 May 2022 01:11:25 +0200 Subject: added external link button and changed string "Info" -> "View", along with a button in the previewer to open the mod page in the browser if you so choose. --- src/app/browser.js | 7 ++++++- src/app/icons/external.png | Bin 0 -> 9764 bytes src/app/index.html | 5 ++++- src/app/main.css | 13 +++++++++---- src/lang/en.json | 1 + 5 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 src/app/icons/external.png (limited to 'src/lang') diff --git a/src/app/browser.js b/src/app/browser.js index 5a5a752..138aef8 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -244,6 +244,10 @@ var Browser = { } } +function openExternal(url) { + require("electron").shell.openExternal(url); +} + var view = document.querySelector(".popup#preview webview"); var Preview = { show: () => { @@ -255,6 +259,7 @@ var Preview = { set: (url, autoshow) => { if (autoshow != false) {Preview.show()} view.src = url; + document.querySelector("#preview #external").setAttribute("onclick", `openExternal("${url}")`); } } @@ -340,7 +345,7 @@ function BrowserEl(properties) {
${properties.title}
${properties.description}
- + diff --git a/src/app/icons/external.png b/src/app/icons/external.png new file mode 100644 index 0000000..0b4f99e Binary files /dev/null and b/src/app/icons/external.png differ diff --git a/src/app/index.html b/src/app/index.html index b146ba3..f67a7a8 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -134,10 +134,13 @@ @@ -240,4 +241,4 @@ - +< diff --git a/src/app/launcher.js b/src/app/launcher.js index 51d3a63..f426775 100644 --- a/src/app/launcher.js +++ b/src/app/launcher.js @@ -1,5 +1,9 @@ const markdown = require("marked").parse; +var servercount; +var playercount; +var masterserver; + // Changes the main page // This is the tabs in the sidebar function page(page) { @@ -107,3 +111,39 @@ function showNsSection(section) { break; } } + +async function loadServers() { + serverstatus.classList.add("checking"); + + try { + let servers = await (await fetch("https://northstar.tf/client/servers/")).json(); + masterserver = true; + }catch (err) { + playercount = 0; + servercount = 0; + masterserver = false; + } + + serverstatus.classList.remove("checking"); + + if (servercount == 0) {masterserver = false} + + if (masterserver) { + serverstatus.classList.add("up"); + // servercount and playercount don't actually get set anywhere, + // the reason for this is, while writing this code, the master + // server is down so I don't have anyway to test the code... + // + // it'll be added whenever the masterserver comes online again. + serverstatus.innerHTML = `${servercount} ${lang("gui.server.servers")} - ${playercount} ${lang("gui.server.players")}`; + } else { + serverstatus.classList.add("down"); + serverstatus.innerHTML = lang("gui.server.offline"); + + } +}; loadServers() + +// Refreshes every 5 minutes +setInterval(() => { + loadServers(); +}, 300000) diff --git a/src/lang/en.json b/src/lang/en.json index 2c068ac..045517d 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -113,6 +113,10 @@ "gui.nsupdate.gaming.title": "Northstar update available!", "gui.nsupdate.gaming.body": "An update for Northstar is available.\nYou can force its installation after closing the game.", + "gui.server.servers": "servers", + "gui.server.players": "players", + "gui.server.offline": "Masterserver is Offline", + "gui.launch": "Launch", "gui.launchvanilla": "Vanilla", "gui.launchnorthstar": "Northstar", -- cgit v1.2.3 From 6e7b66060e8655e013b74140b30f41f6d5ee52e8 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 30 May 2022 18:15:13 +0200 Subject: support for singular players While it's unlikely we'll ever get down to 1 player, it's best to be on the safe side :p --- src/app/launcher.js | 12 ++++++------ src/lang/en.json | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/lang') diff --git a/src/app/launcher.js b/src/app/launcher.js index 719048e..569d0fe 100644 --- a/src/app/launcher.js +++ b/src/app/launcher.js @@ -135,14 +135,14 @@ async function loadServers() { if (servercount == 0 || ! servercount || ! playercount) {masterserver = false} + let playerstr = lang("gui.server.players"); + if (playercount == 1) { + playerstr = lang("gui.server.player"); + } + if (masterserver) { serverstatus.classList.add("up"); - // servercount and playercount don't actually get set anywhere, - // the reason for this is, while writing this code, the master - // server is down so I don't have anyway to test the code... - // - // it'll be added whenever the masterserver comes online again. - serverstatus.innerHTML = `${servercount} ${lang("gui.server.servers")} - ${playercount} ${lang("gui.server.players")}`; + serverstatus.innerHTML = `${servercount} ${lang("gui.server.servers")} - ${playercount} ${playerstr}`; } else { serverstatus.classList.add("down"); serverstatus.innerHTML = lang("gui.server.offline"); diff --git a/src/lang/en.json b/src/lang/en.json index 045517d..34c4619 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -113,8 +113,9 @@ "gui.nsupdate.gaming.title": "Northstar update available!", "gui.nsupdate.gaming.body": "An update for Northstar is available.\nYou can force its installation after closing the game.", - "gui.server.servers": "servers", + "gui.server.player": "player", "gui.server.players": "players", + "gui.server.servers": "servers", "gui.server.offline": "Masterserver is Offline", "gui.launch": "Launch", -- cgit v1.2.3 From a52f7ccbf5da1e62b7ff71b08d032663153be885 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Mon, 30 May 2022 18:24:08 +0200 Subject: [feat] add missing French translations --- src/lang/fr.json | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/lang') diff --git a/src/lang/fr.json b/src/lang/fr.json index 1f37948..3fba39f 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -113,6 +113,11 @@ "gui.nsupdate.gaming.title": "Mise à jour Northstar disponible !", "gui.nsupdate.gaming.body": "Une mise à jour pour Northstar est disponible.\nVous pourrez l'installer après avoir fermé le jeu.", + "gui.server.player": "joueur", + "gui.server.players": "joueurs", + "gui.server.servers": "serveurs", + "gui.server.offline": "Le serveur maître est hors-ligne", + "gui.launch": "Jouer", "gui.launchvanilla": "Vanilla", "gui.launchnorthstar": "Northstar", -- cgit v1.2.3 From 03e5208f6ed208f174b6579df0d6c372f9a26a31 Mon Sep 17 00:00:00 2001 From: Delta <31860825+AA-Delta@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:16:24 -0500 Subject: Update es.json #130 --- src/lang/es.json | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/lang') diff --git a/src/lang/es.json b/src/lang/es.json index 8128440..4efa765 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -130,6 +130,11 @@ "gui.toast.desc.malformed": "tiene una estructura de carpetas incorrecta, si usted es el desarrollador, debe corregir esto.", "gui.toast.desc.failed": "Se produjo un error desconocido al intentar instalar la modificación. Esto puede ser culpa del autor de la modificación, y también puede ser culpa de Viper.", + "gui.server.player": "jugador", + "gui.server.players": "jugadores", + "gui.server.servers": "servidores", + "gui.server.offline": "El servidor Master está desconectado", + "viper.menu.main": "Viper", "viper.menu.release": "Notas de la versión", "viper.menu.info": "Extras", -- cgit v1.2.3 From f9e51cfb04de5316a555d42aa6e23ec445c66f73 Mon Sep 17 00:00:00 2001 From: B Date: Thu, 2 Jun 2022 03:00:06 -0600 Subject: added setting for auto-killing origin, functionality working --- .gitignore | 1 + src/app/index.html | 12 +++ src/index.js | 75 ++++++++++------- src/lang/en.json | 3 + src/utils.js | 239 +++++++++++++++++++++++++++-------------------------- 5 files changed, 182 insertions(+), 148 deletions(-) (limited to 'src/lang') diff --git a/.gitignore b/.gitignore index 1eae0cf..ec12b74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ dist/ node_modules/ +.vscode/ \ No newline at end of file diff --git a/src/app/index.html b/src/app/index.html index 2305e4c..0255dd6 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -107,6 +107,18 @@ +

%%gui.settings.title.misc%%

+
+
+ %%gui.settings.originkill.title%% +
+ %%gui.settings.originkill.desc%% +
+
+
+ +
+
diff --git a/src/index.js b/src/index.js index 96976b7..ddaa928 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ const { app, ipcMain, BrowserWindow, dialog } = require("electron"); const utils = require("./utils"); const cli = require("./cli"); const requests = require("./extras/requests"); +const { settings } = require("./utils"); var log = console.log; @@ -33,10 +34,10 @@ function start() { nodeIntegration: true, contextIsolation: false, }, - }); + }); // when --debug is added it'll open the dev tools - if (cli.hasParam("debug")) {win.openDevTools()} + if (cli.hasParam("debug")) { win.openDevTools() } // general setup win.removeMenu(); @@ -46,23 +47,35 @@ function start() { win.webContents.send(channel, data); }; send = win.send; - ipcMain.on("exit", () => {process.exit(0)}); - ipcMain.on("minimize", () => {win.minimize()}); - ipcMain.on("relaunch", () => {app.relaunch();app.exit()}); + ipcMain.on("exit", () => { + if (settings.originkill) { + utils.isOriginRunning().then((running) => { + if (running) { + utils.killOrigin().then(process.exit(0)) + } else { + process.exit(0) + } + }) + } else { + process.exit(0) + } + }); + ipcMain.on("minimize", () => { win.minimize() }); + ipcMain.on("relaunch", () => { app.relaunch(); app.exit() }); // passthrough to renderer from main - ipcMain.on("win-log", (event, ...args) => {send("log", ...args)}); - ipcMain.on("win-alert", (event, ...args) => {send("alert", ...args)}); + ipcMain.on("win-log", (event, ...args) => { send("log", ...args) }); + ipcMain.on("win-alert", (event, ...args) => { send("alert", ...args) }); // mod states - ipcMain.on("failed-mod", (event, modname) => {send("failed-mod", modname)}); - ipcMain.on("removed-mod", (event, modname) => {send("removed-mod", modname)}); - ipcMain.on("gui-getmods", (event, ...args) => {send("mods", utils.mods.list())}); - ipcMain.on("installed-mod", (event, modname) => {send("installed-mod", modname)}); + ipcMain.on("failed-mod", (event, modname) => { send("failed-mod", modname) }); + ipcMain.on("removed-mod", (event, modname) => { send("removed-mod", modname) }); + ipcMain.on("gui-getmods", (event, ...args) => { send("mods", utils.mods.list()) }); + ipcMain.on("installed-mod", (event, modname) => { send("installed-mod", modname) }); // install calls - ipcMain.on("install-from-path", (event, path) => {utils.mods.install(path)}); - ipcMain.on("install-from-url", (event, url) => {utils.mods.installFromURL(url)}); + ipcMain.on("install-from-path", (event, path) => { utils.mods.install(path) }); + ipcMain.on("install-from-url", (event, url) => { utils.mods.installFromURL(url) }); win.webContents.on("dom-ready", () => { send("mods", utils.mods.list()); @@ -71,18 +84,18 @@ function start() { // ensures gamepath still exists and is valid on startup let gamepathlost = false; ipcMain.on("gamepath-lost", (event, ...args) => { - if (! gamepathlost) { + if (!gamepathlost) { gamepathlost = true; send("gamepath-lost"); } }); - ipcMain.on("save-settings", (event, obj) => {utils.saveSettings(obj)}); + ipcMain.on("save-settings", (event, obj) => { utils.saveSettings(obj) }); // allows renderer to check for updates - ipcMain.on("ns-update-event", (event) => {send("ns-update-event", event)}); + ipcMain.on("ns-update-event", (event) => { send("ns-update-event", event) }); ipcMain.on("can-autoupdate", () => { - if (! autoUpdater.isUpdaterActive() || cli.hasParam("no-vp-updates")) { + if (!autoUpdater.isUpdaterActive() || cli.hasParam("no-vp-updates")) { send("cant-autoupdate"); } }) @@ -115,34 +128,34 @@ ipcMain.on("install-mod", () => { if (cli.hasArgs()) { utils.mods.install(cli.param("installmod")); } else { - dialog.showOpenDialog({properties: ["openFile"]}).then(res => { + dialog.showOpenDialog({ properties: ["openFile"] }).then(res => { if (res.filePaths.length != 0) { utils.mods.install(res.filePaths[0]); } else { send("set-buttons", true); } - }).catch(err => {error(err)}); + }).catch(err => { error(err) }); } }) -ipcMain.on("remove-mod", (event, mod) => {utils.mods.remove(mod)}); -ipcMain.on("toggle-mod", (event, mod) => {utils.mods.toggle(mod)}); +ipcMain.on("remove-mod", (event, mod) => { utils.mods.remove(mod) }); +ipcMain.on("toggle-mod", (event, mod) => { utils.mods.toggle(mod) }); -ipcMain.on("launch-ns", () => {utils.launch()}); -ipcMain.on("launch-vanilla", () => {utils.launch("vanilla")}); +ipcMain.on("launch-ns", () => { utils.launch() }); +ipcMain.on("launch-vanilla", () => { utils.launch("vanilla") }); -ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)}); +ipcMain.on("setlang", (event, lang) => { utils.setlang(lang) }); -ipcMain.on("update", () => {utils.update()}) -ipcMain.on("setpath-cli", () => {utils.setpath()}); +ipcMain.on("update", () => { utils.update() }) +ipcMain.on("setpath-cli", () => { utils.setpath() }); ipcMain.on("setpath", (event, value) => { - if (! value) { - if (! win.isVisible()) { + if (!value) { + if (!win.isVisible()) { utils.setpath(win); } else { utils.setpath(win, true); } - } else if (! win.isVisible()) { + } else if (!win.isVisible()) { win.show(); } }); @@ -157,7 +170,7 @@ function sendVersionsInfo() { } // sends the version info back to the renderer -ipcMain.on("get-version", () => {sendVersionsInfo()}); +ipcMain.on("get-version", () => { sendVersionsInfo() }); // prints out version info for the CLI ipcMain.on("version-cli", () => { @@ -194,7 +207,7 @@ ipcMain.on("getmods", () => { // allows renderer to set a new renderer ipcMain.on("newpath", (event, newpath) => { - if (newpath === false && ! win.isVisible()) { + if (newpath === false && !win.isVisible()) { win.send("no-path-selected"); } else { _sendVersionsInfo(); diff --git a/src/lang/en.json b/src/lang/en.json index 34c4619..3ae6ff1 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -91,6 +91,7 @@ "gui.settings.title.ns": "Northstar", "gui.settings.title.language": "Language", "gui.settings.title.updates": "Updates", + "gui.settings.title.misc": "Miscellaneous", "gui.settings.nsargs.title": "Launch options", "gui.settings.nsargs.desc": "Here you can add launch options for Northstar/Titanfall.", "gui.settings.autolang.title": "Auto-Detect Language", @@ -103,6 +104,8 @@ "gui.settings.nsupdate.desc": "Viper will automatically keep Northstar up-to-date, however it can still manually be updated through the Northstar page.", "gui.settings.excludes.title": "Retain files on update", "gui.settings.excludes.desc": "When Northstar is updated, files specified here will not be overwritten by files from the new Northstar update, unless you know what you're changing, you should probably not change anything here. Each file is separated with a space.", + "gui.settings.originkill.title": "Automatically quit Origin", + "gui.settings.originkill.desc": "When Viper exits, automatically quit Origin client too. Mirrors behavior of launching the game through Steam.", "gui.update.downloading": "Downloading...", "gui.update.extracting": "Extracting update...", diff --git a/src/utils.js b/src/utils.js index 061c3f1..2e81bdf 100644 --- a/src/utils.js +++ b/src/utils.js @@ -37,7 +37,9 @@ var settings = { excludes: [ "ns_startup_args.txt", "ns_startup_args_dedi.txt" - ] + ], + + originkill: false } // Logs into the dev tools of the renderer @@ -58,11 +60,11 @@ if (fs.existsSync("viper.json")) { // Validates viper.json try { json = JSON.parse(conf); - }catch (e) { + } catch (e) { invalidsettings = true; } - settings = {...settings, ...json}; + settings = { ...settings, ...json }; settings.zip = path.join(settings.gamepath + "/northstar.zip"); let args = path.join(settings.gamepath, "ns_startup_args.txt"); @@ -95,7 +97,7 @@ async function isGameRunning() { break } - if (i == procs.length - 1) {resolve(false)} + if (i == procs.length - 1) { resolve(false) } } }); }); @@ -103,44 +105,44 @@ async function isGameRunning() { //Check if origin client is running async function isOriginRunning() { - return new Promise(resolve => { - let procs = ["origin.exe"]; //check this, probably not right - let cmd = (() => { - switch (process.platform) { - case "linux": return "ps -A"; - case "win32": return "tasklist"; - } - })(); - - exec(cmd, (err, stdout) => { - procs.forEach( proc => { - if (stdout.includes(proc)) { - resolve(true); - return; - } - resolve(false); - }); + return new Promise(resolve => { + let procs = ["Origin.exe", "OriginClientService.exe"]; + let cmd = (() => { + switch (process.platform) { + case "linux": return "ps -A"; + case "win32": return "tasklist"; + } + })(); + + exec(cmd, (err, stdout) => { + procs.forEach(proc => { + if (stdout.includes(proc)) { + resolve(true); + return; + } + resolve(false); + }); + }); }); - }); } //Kill origin client async function killOrigin() { - return Promise(resolve => { - let proc = "origin.exe" ; //need to match above - let cmd = (() => { - switch (process.platform) { - case "linux": return "killall " + proc; - case "win32": return "taskkill /IM " + proc + " /F"; - } - })(); - - exec(cmd, (err, stdout) => { - //do some checking here maybe? idk we're going to be exiting so maybe we should - //just try and fail silently if we don't find shit - resolve(true); + return new Promise(resolve => { + let proc = "Origin.exe"; //I'm pretty sure we only have to kill this one + let cmd = (() => { + switch (process.platform) { + case "linux": return "killall " + proc; + case "win32": return "taskkill /IM " + proc + " /F"; + } + })(); + + exec(cmd, (err, stdout) => { + //do some checking here maybe? idk we're going to be exiting so maybe we should + //just try and fail silently if we don't find shit + resolve(true); + }); }); - }); } // Handles auto updating Northstar. @@ -148,7 +150,7 @@ async function killOrigin() { // It uses isGameRunning() to ensure it doesn't run while the game is // running, as that may have all kinds of issues. function handleNorthstarUpdating() { - if (! settings.nsupdate || ! fs.existsSync("viper.json") || settings.gamepath.length === 0) { + if (!settings.nsupdate || !fs.existsSync("viper.json") || settings.gamepath.length === 0) { return; } @@ -163,7 +165,7 @@ function handleNorthstarUpdating() { if (await isGameRunning()) { console.log(lang("cli.autoupdates.gamerunning")); new Notification({ - title: lang("gui.nsupdate.gaming.title"), + title: lang("gui.nsupdate.gaming.title"), body: lang("gui.nsupdate.gaming.body") }).show(); } else { @@ -175,7 +177,7 @@ function handleNorthstarUpdating() { } setTimeout( - _checkForUpdates, + _checkForUpdates, 15 * 60 * 1000 // interval in between each update check // by default 15 minutes. @@ -201,10 +203,10 @@ async function setpath(win, forcedialog) { modpath = path.join(settings.gamepath, "R2Northstar/mods"); } - if (! win) { // CLI + if (!win) { // CLI setGamepath(cli.param("setpath")); } else { // GUI - if (! forcedialog) { + if (!forcedialog) { function setGamepath(folder, forcedialog) { settings.gamepath = folder; settings.zip = path.join(settings.gamepath + "/northstar.zip"); @@ -223,12 +225,12 @@ async function setpath(win, forcedialog) { } // Fallback to manual selection - dialog.showOpenDialog({properties: ["openDirectory"]}).then(res => { + dialog.showOpenDialog({ properties: ["openDirectory"] }).then(res => { if (res.canceled) { ipcMain.emit("newpath", null, false); return; } - if (! fs.existsSync(path.join(res.filePaths[0], "Titanfall2.exe"))) { + if (!fs.existsSync(path.join(res.filePaths[0], "Titanfall2.exe"))) { ipcMain.emit("wrong-path"); return; } @@ -237,7 +239,7 @@ async function setpath(win, forcedialog) { cli.exit(); return; - }).catch(err => {console.error(err)}) + }).catch(err => { console.error(err) }) } } @@ -248,15 +250,15 @@ async function setpath(win, forcedialog) { // You can also pass a settings object to the function and it'll try and // merge it together with the already existing settings function saveSettings(obj = {}) { - if (invalidsettings) {return false} + if (invalidsettings) { return false } - settings = {...settings, ...obj}; + settings = { ...settings, ...obj }; if (fs.existsSync(settings.gamepath)) { fs.writeFileSync(path.join(settings.gamepath, "ns_startup_args.txt"), settings.nsargs); } - fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({...settings, ...obj})); + fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({ ...settings, ...obj })); } // Returns the current Northstar version @@ -313,7 +315,7 @@ restoreExcludedFiles(); // .excluded, then rename them back after the extraction. The // unzip module does not support excluding files directly. async function update() { - if (! gamepathExists()) {return} + if (!gamepathExists()) { return } ipcMain.emit("ns-update-event", "cli.update.checking"); console.log(lang("cli.update.checking")); @@ -332,7 +334,7 @@ async function update() { } else { if (version != "unknown") { console.log(lang("cli.update.current"), version); - }; + }; console.log(lang("cli.update.downloading") + ":", latestAvailableVersion); ipcMain.emit("ns-update-event", "cli.update.downloading"); } @@ -365,19 +367,19 @@ async function update() { console.log(lang("cli.update.downloaddone")); // Extracts the zip, this is the part where we're actually // installing Northstar. - fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath})) - .on("finish", () => { - fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), latestAvailableVersion); - ipcMain.emit("get-version"); - - restoreExcludedFiles(); - - ipcMain.emit("gui-getmods"); - ipcMain.emit("ns-update-event", "cli.update.uptodate.short"); - winLog(lang("gui.update.finished")); - console.log(lang("cli.update.finished")); - cli.exit(); - }) + fs.createReadStream(settings.zip).pipe(unzip.Extract({ path: settings.gamepath })) + .on("finish", () => { + fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), latestAvailableVersion); + ipcMain.emit("get-version"); + + restoreExcludedFiles(); + + ipcMain.emit("gui-getmods"); + ipcMain.emit("ns-update-event", "cli.update.uptodate.short"); + winLog(lang("gui.update.finished")); + console.log(lang("cli.update.finished")); + cli.exit(); + }) }) }) } @@ -390,7 +392,7 @@ async function update() { function updatevp(autoinstall) { const { autoUpdater } = require("electron-updater"); - if (! autoUpdater.isUpdaterActive()) { + if (!autoUpdater.isUpdaterActive()) { if (settings.nsupdate) { handleNorthstarUpdating(); } @@ -403,7 +405,7 @@ function updatevp(autoinstall) { }); } - autoUpdater.on("error", (info) => {cli.exit(1)}); + autoUpdater.on("error", (info) => { cli.exit(1) }); autoUpdater.on("update-not-available", (info) => { // only check for NS updates if Viper itself has no updates and // if NS auto updates is enabled. @@ -429,7 +431,7 @@ function launch(version) { } process.chdir(settings.gamepath); - switch(version) { + switch (version) { case "vanilla": console.log(lang("general.launching"), "Vanilla..."); run(path.join(settings.gamepath + "/Titanfall2.exe")); @@ -471,8 +473,8 @@ const mods = { let enabled = []; let disabled = []; - if (! fs.existsSync(modpath)) { - fs.mkdirSync(path.join(modpath), {recursive: true}); + if (!fs.existsSync(modpath)) { + fs.mkdirSync(path.join(modpath), { recursive: true }); return { enabled: [], disabled: [], @@ -491,9 +493,10 @@ const mods = { Version: "unknown", Name: "unknown", FolderName: file, - ...mod} + ...mod + } - obj.Disabled = ! mods.modfile().get(obj.Name); + obj.Disabled = !mods.modfile().get(obj.Name); let manifestfile = path.join(modpath, file, "manifest.json"); if (fs.existsSync(manifestfile)) { @@ -542,7 +545,7 @@ const mods = { for (let i = 0; i < list.length; i++) { if (list[i].Name == mod) { return list[i]; - } else {continue} + } else { continue } } return false; @@ -556,11 +559,11 @@ const mods = { let modpath = path.join(settings.gamepath, "R2Northstar/mods"); let file = path.join(modpath, "..", "enabledmods.json"); - if (! fs.existsSync(modpath)) { - fs.mkdirSync(path.join(modpath), {recursive: true}); + if (!fs.existsSync(modpath)) { + fs.mkdirSync(path.join(modpath), { recursive: true }); } - if (! fs.existsSync(file)) { + if (!fs.existsSync(file)) { fs.writeFileSync(file, "{}"); } @@ -587,7 +590,7 @@ const mods = { toggle: (mod) => { let data = JSON.parse(repair(fs.readFileSync(file, "utf8"))); if (data[mod] != undefined) { - data[mod] = ! data[mod]; + data[mod] = !data[mod]; } else { data[mod] = false; } @@ -653,19 +656,19 @@ const mods = { return true; } - if (! fs.existsSync(mod)) {return notamod()} + if (!fs.existsSync(mod)) { return notamod() } if (fs.statSync(mod).isDirectory()) { winLog(lang("gui.mods.installing")); files = fs.readdirSync(mod); - if (fs.existsSync(path.join(mod, "mod.json")) && + if (fs.existsSync(path.join(mod, "mod.json")) && fs.statSync(path.join(mod, "mod.json")).isFile()) { if (fs.existsSync(path.join(modpath, modname))) { - fs.rmSync(path.join(modpath, modname), {recursive: true}); + fs.rmSync(path.join(modpath, modname), { recursive: true }); } let copydest = path.join(modpath, modname); - if (typeof destname == "string") {copydest = path.join(modpath, destname)} + if (typeof destname == "string") { copydest = path.join(modpath, destname) } copy(mod, copydest); copy(manifestfile, path.join(copydest, "manifest.json")); @@ -679,7 +682,7 @@ const mods = { fs.statSync(path.join(mod, files[i], "mod.json")).isFile()) { mods.install(path.join(mod, files[i])); - if (mods.install(path.join(mod, files[i]))) {return true}; + if (mods.install(path.join(mod, files[i]))) { return true }; } } } @@ -692,52 +695,52 @@ const mods = { winLog(lang("gui.mods.extracting")); let cache = path.join(app.getPath("userData"), "Archives"); if (fs.existsSync(cache)) { - fs.rmSync(cache, {recursive: true}); - fs.mkdirSync(path.join(cache, "mods"), {recursive: true}); + fs.rmSync(cache, { recursive: true }); + fs.mkdirSync(path.join(cache, "mods"), { recursive: true }); } else { - fs.mkdirSync(path.join(cache, "mods"), {recursive: true}); + fs.mkdirSync(path.join(cache, "mods"), { recursive: true }); } try { 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) + 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("failed-mod"); - return notamod(); + if (files.length == 0) { + ipcMain.emit("failed-mod"); + 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()} + } catch (err) { return notamod() } } }, @@ -751,7 +754,7 @@ const mods = { let modlocation = path.join(tmp, "/mod.zip"); if (fs.existsSync(tmp)) { - if (! fs.statSync(tmp).isDirectory()) { + if (!fs.statSync(tmp).isDirectory()) { fs.rmSync(tmp); } } else { @@ -794,12 +797,12 @@ const mods = { } let disabled = path.join(modpath, "disabled"); - if (! fs.existsSync(disabled)) { + if (!fs.existsSync(disabled)) { fs.mkdirSync(disabled); } let modName = mods.get(mod).FolderName; - if (! modName) { + if (!modName) { console.log("error: " + lang("cli.mods.cantfind")); cli.exit(1); return; @@ -817,7 +820,7 @@ const mods = { manifestname = require(path.join(modPath, "manifest.json")).name; } - fs.rmSync(modPath, {recursive: true}); + fs.rmSync(modPath, { recursive: true }); console.log(lang("cli.mods.removed")); cli.exit(); ipcMain.emit("gui-getmods"); @@ -856,7 +859,7 @@ const mods = { } mods.modfile().toggle(mod); - if (! fork) { + if (!fork) { console.log(lang("cli.mods.toggled")); cli.exit(); } @@ -889,6 +892,8 @@ module.exports = { getNSVersion, getTF2Version, isGameRunning, + isOriginRunning, + killOrigin, gamepathExists, handleNorthstarUpdating, setlang: (lang) => { -- cgit v1.2.3 From 59aa33289cebd63432904ac69fa7d9f4f2bc1b9c Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 7 Jun 2022 17:23:33 +0200 Subject: minor changes Mostly syntax, but also a few fixes with how the settings system work, and also a change in localization strings. --- .gitignore | 3 ++- src/app/main.js | 1 + src/index.js | 7 +++---- src/lang/en.json | 2 +- src/utils.js | 31 ++++++++++++++++++------------- 5 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src/lang') diff --git a/.gitignore b/.gitignore index ec12b74..32e527a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.vscode/ + dist/ node_modules/ -.vscode/ \ No newline at end of file diff --git a/src/app/main.js b/src/app/main.js index 647e5cd..9fb3191 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -14,6 +14,7 @@ var settings = { autolang: true, forcedlang: "en", autoupdate: true, + originkill: false, zip: "/northstar.zip", lang: navigator.language, excludes: [ diff --git a/src/index.js b/src/index.js index a566b57..2c03529 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,6 @@ const { app, ipcMain, BrowserWindow, dialog } = require("electron"); const utils = require("./utils"); const cli = require("./cli"); const requests = require("./extras/requests"); -const { settings } = require("./utils"); var log = console.log; @@ -48,7 +47,7 @@ function start() { }; send = win.send; ipcMain.on("exit", () => { - if (settings.originkill) { + if (utils.settings.originkill) { utils.isOriginRunning().then((running) => { if (running) { utils.killOrigin().then(process.exit(0)) @@ -60,8 +59,8 @@ function start() { process.exit(0) } }); - ipcMain.on("minimize", () => { win.minimize() }); - ipcMain.on("relaunch", () => { app.relaunch(); app.exit() }); + ipcMain.on("minimize", () => {win.minimize()}); + ipcMain.on("relaunch", () => {app.relaunch(); app.exit()}); // passthrough to renderer from main ipcMain.on("win-log", (event, ...args) => {send("log", ...args)}); diff --git a/src/lang/en.json b/src/lang/en.json index 3ae6ff1..72711b8 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -105,7 +105,7 @@ "gui.settings.excludes.title": "Retain files on update", "gui.settings.excludes.desc": "When Northstar is updated, files specified here will not be overwritten by files from the new Northstar update, unless you know what you're changing, you should probably not change anything here. Each file is separated with a space.", "gui.settings.originkill.title": "Automatically quit Origin", - "gui.settings.originkill.desc": "When Viper exits, automatically quit Origin client too. Mirrors behavior of launching the game through Steam.", + "gui.settings.originkill.desc": "When Viper exits, automatically quit Origin client too.", "gui.update.downloading": "Downloading...", "gui.update.extracting": "Extracting update...", diff --git a/src/utils.js b/src/utils.js index 2fea3ea..6114ef1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -29,6 +29,7 @@ var settings = { autolang: true, forcedlang: "en", autoupdate: true, + originkill: false, nsargs: "-multiple", zip: "/northstar.zip", @@ -37,9 +38,7 @@ var settings = { excludes: [ "ns_startup_args.txt", "ns_startup_args_dedi.txt" - ], - - originkill: false + ] } // Logs into the dev tools of the renderer @@ -103,7 +102,7 @@ async function isGameRunning() { }); } -//Check if origin client is running +// checks if any origin processes are running async function isOriginRunning() { return new Promise(resolve => { let procs = ["Origin.exe", "OriginClientService.exe"]; @@ -126,7 +125,7 @@ async function isOriginRunning() { }); } -//Kill origin client +// kill origin processes async function killOrigin() { return new Promise(resolve => { let proc = "Origin.exe"; //I'm pretty sure we only have to kill this one @@ -138,7 +137,7 @@ async function killOrigin() { })(); exec(cmd, (err, stdout) => { - //just try and fail silently if we don't find it w/e + // just try and fail silently if we don't find it w/e resolve(true); }); }); @@ -879,21 +878,27 @@ setInterval(() => { module.exports = { mods, - lang, winLog, - launch, + update, - setpath, updatevp, - settings, - saveSettings, getNSVersion, getTF2Version, + handleNorthstarUpdating, + + launch, + killOrigin, isGameRunning, isOriginRunning, - killOrigin, + + + settings, + saveSettings, + + setpath, gamepathExists, - handleNorthstarUpdating, + + lang, setlang: (lang) => { settings.lang = lang; saveSettings(); -- cgit v1.2.3 From 0e2ae4648f5a53e7a5597c04d0829b6d870abaca Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 7 Jun 2022 17:28:16 +0200 Subject: very very minor change in localization string --- src/lang/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lang') diff --git a/src/lang/en.json b/src/lang/en.json index 72711b8..8cece10 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -105,7 +105,7 @@ "gui.settings.excludes.title": "Retain files on update", "gui.settings.excludes.desc": "When Northstar is updated, files specified here will not be overwritten by files from the new Northstar update, unless you know what you're changing, you should probably not change anything here. Each file is separated with a space.", "gui.settings.originkill.title": "Automatically quit Origin", - "gui.settings.originkill.desc": "When Viper exits, automatically quit Origin client too.", + "gui.settings.originkill.desc": "When Viper exits, automatically quit Origin as well.", "gui.update.downloading": "Downloading...", "gui.update.extracting": "Extracting update...", -- cgit v1.2.3 From 320e7bd9f14becd6655623e3dfa9d7cd75422869 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 9 Jun 2022 22:26:00 +0000 Subject: [feat] add missing french translations --- src/lang/fr.json | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/lang') diff --git a/src/lang/fr.json b/src/lang/fr.json index 3fba39f..1fde982 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -91,6 +91,7 @@ "gui.settings.title.ns": "Northstar", "gui.settings.title.language": "Langue", "gui.settings.title.updates": "Mises à jour", + "gui.settings.title.misc": "Divers", "gui.settings.nsargs.title": "Options de lancement", "gui.settings.nsargs.desc": "Vous pouvez ajouter ici des options de démarrage pour Northstar/Titanfall.", "gui.settings.autolang.title": "Auto-détection de la langue", @@ -103,6 +104,8 @@ "gui.settings.nsupdate.desc": "Viper tient automatiquement Northstar à jour (n'empêche pas de le mettre à jour manuellement via sa page dédiée).", "gui.settings.excludes.title": "Fichiers à conserver", "gui.settings.excludes.desc": "Lorsque Northstar est mis à jour, ces fichiers ne seront pas écrasés par ceux provenant de la mise à jour; les noms de fichiers sont séparés par un espace.", + "gui.settings.originkill.title": "Quitter automatiquement Origin", + "gui.settings.originkill.desc": "Lorsque Viper est fermé, Origin sera également automatiquement fermé.", "gui.update.downloading": "Téléchargement de la mise à jour...", "gui.update.extracting": "Extraction des fichiers...", -- cgit v1.2.3 From 0d81e16ccee3ca8afe5a0310fdbe6d708a1424ce Mon Sep 17 00:00:00 2001 From: Delta <31860825+AA-Delta@users.noreply.github.com> Date: Sun, 12 Jun 2022 18:22:31 +0200 Subject: spanish originkill localizations --- src/lang/es.json | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/lang') diff --git a/src/lang/es.json b/src/lang/es.json index 4efa765..c341143 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -90,6 +90,7 @@ "gui.settings.discard": "Descartar", "gui.settings.title.ns": "Northstar", "gui.settings.title.updates": "Actualizaciones", + "gui.settings.title.misc": "Misceláneos", "gui.settings.nsargs.title": "Opciones de lanzamiento", "gui.settings.nsargs.desc": "Aqui puedes añadir opciones de lanzamiento para Northstar/Titanfall.", "gui.settings.autoupdate.title": "Actualizaciones automáticas de Viper", @@ -98,6 +99,8 @@ "gui.settings.nsupdate.desc": "Viper mantendrá Northstar actualizado automáticamente, sin embargo, todavía se puede actualizar manualmente a través de la sección de Northstar.", "gui.settings.excludes.title": "Conservar archivos en la actualización", "gui.settings.excludes.desc": "Cuando se actualice Northstar, los archivos especificados aquí no se sobrescribirán con archivos de la nueva actualización de Northstar. A menos que sepa lo que está cambiando, probablemente no debería cambiar nada aquí. Cada archivo se debe separar con un espacio.", + "gui.settings.originkill.title": "Cerrar Origin automáticamente", + "gui.settings.originkill.desc": "Cuando Viper se cierra, cerrar automáticamente Origin también.", "gui.settings.title.language": "Idioma", "gui.settings.autolang.title": "Detectar automáticamente el idioma", "gui.settings.autolang.desc": "Cuando está habilitado, Viper intenta detectar automáticamente el idioma de su sistema, cuando está deshabilitado, puede cambiar manualmente el idioma a continuación.", -- cgit v1.2.3