aboutsummaryrefslogtreecommitdiff
path: root/src/modules/launch.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-03-05 00:25:07 +0100
committer0neGal <mail@0negal.com>2023-03-05 00:38:53 +0100
commit5d86a3daa5f762326055469b6bcd8346e0655056 (patch)
tree110fb1395fac1510dc3bf70f39f073df555445ff /src/modules/launch.js
parent4536aad2c4f19d32569d84a7082e8636a2be6985 (diff)
downloadViper-5d86a3daa5f762326055469b6bcd8346e0655056.tar.gz
Viper-5d86a3daa5f762326055469b6bcd8346e0655056.zip
modularized many functions and got rid of utils.js
Notably, winLog() and winAlert() are now win.log() and win.alert() inside modules/window.js. updateViper(), updateNorthstar and handleNorthstarUpdating() are now update.viper(), update.northstar() and update.northstar_autoupdate(), inside modules/update.js isGameRunning() and isOriginRunning() are now is_running.origin() and is_running.game() inside modules/is_running.js, along with a .titanfall() and .northstar() for more specificity. Not used anywhere right now, but may in the future be used. setpath() and gamepathExists() are now gamepath.set() and gamepath.exists() inside modules/gamepath.js killOrigin() are now kill.origin() inside modules/kill.js setlang() is now just inlined into the only event where it's used.
Diffstat (limited to 'src/modules/launch.js')
-rw-r--r--src/modules/launch.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/modules/launch.js b/src/modules/launch.js
new file mode 100644
index 0000000..765c348
--- /dev/null
+++ b/src/modules/launch.js
@@ -0,0 +1,34 @@
+const exec = require("child_process").exec;
+
+const cli = require("../cli");
+const lang = require("../lang");
+
+const win = require("./window");
+const settings = require("./settings");
+
+// Launches the game
+//
+// Either Northstar or Vanilla. Linux support is not currently a thing,
+// however it'll be added at some point.
+function launch(game_version) {
+ if (process.platform == "linux") {
+ win.alert(lang("cli.launch.linuxerror"));
+ console.error("error:", lang("cli.launch.linuxerror"));
+ cli.exit(1);
+ return;
+ }
+
+ process.chdir(settings.gamepath);
+ switch(game_version) {
+ case "vanilla":
+ console.log(lang("general.launching"), "Vanilla...");
+ exec("Titanfall2.exe", {cwd: settings.gamepath});
+ break;
+ default:
+ console.log(lang("general.launching"), "Northstar...");
+ exec("NorthstarLauncher.exe", {cwd: settings.gamepath});
+ break;
+ }
+}
+
+module.exports = launch;