diff options
-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, |