diff options
author | 0neGal <mail@0negal.com> | 2021-12-27 02:13:32 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2021-12-27 02:13:32 +0100 |
commit | 9d438e3f8f543a93a916f0573c0ea24dbaf4a395 (patch) | |
tree | 58b5544ac81f13f070462458342a78239b38ec04 /src | |
parent | 6ac8259ec96db1ac0e770dd42b4f21c2eabd5c63 (diff) | |
download | Viper-9d438e3f8f543a93a916f0573c0ea24dbaf4a395.tar.gz Viper-9d438e3f8f543a93a916f0573c0ea24dbaf4a395.zip |
this might add launch options? maybe?
I haven't tested this on Windows... And I will in a bit...
Diffstat (limited to 'src')
-rw-r--r-- | src/app/index.html | 4 | ||||
-rw-r--r-- | src/app/main.js | 3 | ||||
-rw-r--r-- | src/cli.js | 12 | ||||
-rw-r--r-- | src/index.js | 5 | ||||
-rw-r--r-- | src/utils.js | 20 |
5 files changed, 41 insertions, 3 deletions
diff --git a/src/app/index.html b/src/app/index.html index 263a903..b7b260d 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -15,8 +15,8 @@ <div class="line"> <div class="text">Launch:</div> <div class="buttons"> - <button id="vanilla">Vanilla</button> - <button id="northstar">Northstar</button> + <button id="vanilla" onclick="launchVanilla()">Vanilla</button> + <button id="northstar" onclick="launch()">Northstar</button> </div> </div> </div> diff --git a/src/app/main.js b/src/app/main.js index 9783459..404e762 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -19,6 +19,9 @@ if (fs.existsSync(settings.file)) { function update() {ipcRenderer.send("update")} function setpath() {ipcRenderer.send("setpath")} +function launch() {ipcRenderer.send("launch")} +function launchVanilla() {ipcRenderer.send("launchVanilla")} + ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = newpath; }) @@ -10,6 +10,7 @@ function hasArgs() { if (cli.hasSwitch("cli") || cli.hasSwitch("help") || cli.hasSwitch("update") || + cli.hasSwitch("launch") || cli.hasSwitch("setpath") || cli.hasSwitch("gamepath")) { return true; @@ -44,6 +45,17 @@ async function init() { console.error("error: No argumment provided for --setpath"); } } + + if (cli.hasSwitch("launch")) { + switch(cli.getSwitchValue("launch")) { + case "vanilla": + ipcMain.emit("launchVanilla"); + break; + default: + ipcMain.emit("launch"); + break; + } + } } module.exports = { diff --git a/src/index.js b/src/index.js index 9fe7610..6095803 100644 --- a/src/index.js +++ b/src/index.js @@ -27,8 +27,11 @@ function start() { ipcMain.on("setpath", (event) => {utils.setpath(win)}) } -ipcMain.on("setpathcli", (event) => {utils.setpath()}) +ipcMain.on("launch", (event) => {utils.launch()}) +ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")}) + ipcMain.on("update", (event) => {utils.update()}) +ipcMain.on("setpathcli", (event) => {utils.setpath()}) process.chdir(app.getPath("appData")); diff --git a/src/utils.js b/src/utils.js index 5394894..c60eb5e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -9,6 +9,7 @@ const cli = require("./cli"); const unzip = require("unzipper"); const request = require("request"); +const exec = require("child_process").spawn; const { https } = require("follow-redirects"); process.chdir(app.getPath("appData")); @@ -65,7 +66,26 @@ function update() { }) } +function launch(version) { + if (process.platform == "linux") { + console.error("error: Launching the game is not currently supported on Linux") + cli.exit(1); + } + + switch(version) { + case "vanilla": + console.log("Launching Vanilla...") + exec(path.join(settings.gamepath + "/Titanfall2.exe")) + break; + default: + console.log("Launching Northstar...") + exec(path.join(settings.gamepath + "/NorthstarLauncher.exe")) + break; + } +} + module.exports = { + launch, update, setpath, settings, |