diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/gamepath.js | 16 | ||||
-rw-r--r-- | src/modules/mods.js | 8 | ||||
-rw-r--r-- | src/modules/packages.js | 1 | ||||
-rw-r--r-- | src/modules/protocol.js | 39 | ||||
-rw-r--r-- | src/modules/update.js | 25 |
5 files changed, 84 insertions, 5 deletions
diff --git a/src/modules/gamepath.js b/src/modules/gamepath.js index 5a5f922..65676a4 100644 --- a/src/modules/gamepath.js +++ b/src/modules/gamepath.js @@ -45,18 +45,20 @@ ipcMain.on("wrong-path", () => { }) ipcMain.on("found-missing-perms", async (e, selected_gamepath) => { + gamepath.setting = true; await win().alert(lang("gui.gamepath.found_missing_perms") + selected_gamepath); ipcMain.emit("setpath", null, false, true); }) ipcMain.on("missing-perms", async (e, selected_gamepath) => { + gamepath.setting = true; await win().alert(lang("gui.gamepath.missing_perms") + selected_gamepath); ipcMain.emit("setpath"); }) ipcMain.on("gamepath-lost-perms", async (e, selected_gamepath) => { - if (! gamepath.setting) { - gamepath.setting = true; + if (! gamepath.setting && gamepath.lost_perms != selected_gamepath) { + gamepath.lost_perms = selected_gamepath; await win().alert(lang("gui.gamepath.lost_perms") + selected_gamepath); ipcMain.emit("setpath"); } @@ -80,17 +82,21 @@ gamepath.exists = (folder) => { // returns false if the user doesn't have read/write permissions to the // selected gamepath, if no gamepath is set, then this will always // return `false`, handle that correctly! -gamepath.has_perms = (folder) => { +gamepath.has_perms = (folder = settings().gamepath) => { if (! gamepath.exists(folder)) { return false; } try { fs.accessSync( - folder || settings().gamepath, + folder, fs.constants.R_OK | fs.constants.W_OK ) + let test_file_path = path.join(folder, ".viper_test"); + fs.writeFileSync(test_file_path, ""); + fs.unlinkSync(test_file_path); + return true; } catch (err) { return false; @@ -163,6 +169,8 @@ gamepath.set = async (win, force_dialog) => { return gamepath.setting = false; } + delete gamepath.lost_perms; + if (! fs.existsSync(path.join(res.filePaths[0], "Titanfall2.exe"))) { ipcMain.emit("wrong-path"); return gamepath.setting = false; diff --git a/src/modules/mods.js b/src/modules/mods.js index 6214098..aecb5e3 100644 --- a/src/modules/mods.js +++ b/src/modules/mods.js @@ -729,9 +729,17 @@ mods.toggle = (mod, fork) => { } // toggles all mods, thereby inverting the current enabled states + // + // this skips core mods, as there's generally little use to have + // this affect them if (mod == "allmods") { let modlist = mods.list().all; // get list of all mods for (let i = 0; i < modlist.length; i++) { // run through list + // skip core mods + if (modlist[i].name.toLowerCase().match(/^northstar\./)) { + continue; + } + mods.toggle(modlist[i].name, true); // enable mod } diff --git a/src/modules/packages.js b/src/modules/packages.js index 8df6665..125705a 100644 --- a/src/modules/packages.js +++ b/src/modules/packages.js @@ -194,6 +194,7 @@ packages.install = async (url, author, package_name, version) => { return false; } + let name = packages.format_name(author, package_name, version); // removes zip's and folders diff --git a/src/modules/protocol.js b/src/modules/protocol.js new file mode 100644 index 0000000..1aeb7f9 --- /dev/null +++ b/src/modules/protocol.js @@ -0,0 +1,39 @@ +const { app } = require("electron"); + +const win = require("../win"); +const version = require("./version"); + +module.exports = async (argv) => { + if (version.northstar() == "unknown") + return; + + const args = argv || process.argv; + + for (const key of args) { + if (key.startsWith("ror2mm://")) { + let fragments = key.slice(9).split("/"); + + if (fragments.length < 6) + return; + + const ver = fragments[0]; + const term = fragments[1]; + const domain = fragments[2]; + const author = fragments[3]; + const package_name = fragments[4]; + const version = fragments[5]; + + // There is only v1 + if (ver != "v1") + continue; + + // No support for custom thunderstore instances + if (domain != "thunderstore.io") + continue; + + if (term == "install") { + win().send("protocol-install-mod", [domain, author, package_name, version]); + } + } + } +} diff --git a/src/modules/update.js b/src/modules/update.js index c001ba8..7469e02 100644 --- a/src/modules/update.js +++ b/src/modules/update.js @@ -401,9 +401,32 @@ update.northstar = async (force_install) => { console.ok(lang("cli.update.download_done")); + let destination = unzip.Extract({path: settings().gamepath}); + + // If we receive multiple errors of the same type we ignore them + let received_errors = []; + destination.on("error", (err) => { + if (received_errors.indexOf(err.code) >= 0) + return; + + received_errors.push(err.code); + extract.close(); + update.northstar.updating = false; + + let description = lang("gui.toast.desc.unknown_error") + " (" + err.code + ")"; + + win().toast({ + scheme: "error", + title: lang("gui.toast.title.failed"), + description: description + }) + + win().send("ns-update-event", "cli.update.failed"); + }) + // extracts the zip, this is the part where we're actually // installing Northstar. - extract.pipe(unzip.Extract({path: settings().gamepath})) + extract.pipe(destination) let extracted = 0; let size = received; |