aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils.js36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/utils.js b/src/utils.js
index 521931d..50ad240 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -116,14 +116,33 @@ northstar_auto_updates: {
//
// If running with CLI it takes in the --setpath argument otherwise it
// open the systems file browser for the user to select a path.
-function setpath(win) {
+async function setpath(win) {
if (! win) { // CLI
settings.gamepath = cli.param("setpath");
} else { // GUI
+ function setGamepath(folder) {
+ settings.gamepath = folder + "/steamapps/common/Titanfall2/";
+ settings.zip = path.join(settings.gamepath + "/northstar.zip");
+ saveSettings();
+ win.webContents.send("newpath", settings.gamepath);
+ ipcMain.emit("newpath", null, settings.gamepath);
+ }
+
// Autodetect path
// Windows only using powershell and windows registery
// Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Respawn\Titanfall2\
- if (process.platform == "win32") {/* TODO */}
+ if (process.platform == "linux") {
+ try {
+ let {stdout} = await exec("Get-Item -Path Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Respawn\\Titanfall2\\", {"shell":"powershell.exe"});
+ let originPath = stdout.split('\n')
+ .filter(r => r.indexOf("Install Dir") !== -1)[0]
+ .replace(/\s+/g,' ')
+ .trim()
+ .replace("Install Dir : ","");
+ setGamepath(originPath)
+ return
+ } catch (err) {}
+ }
// Detect using Steam VDF
function readvdf(data) {
@@ -137,16 +156,11 @@ function setpath(win) {
if (fs.existsSync(data_array[0] + "/steamapps/common/Titanfall2/Titanfall2.exe")) {
// Found the location
- settings.gamepath = data_array[0] + "/steamapps/common/Titanfall2/";
- settings.zip = path.join(settings.gamepath + "/northstar.zip");
- saveSettings();
- win.webContents.send("newpath", settings.gamepath);
- ipcMain.emit("newpath", null, settings.gamepath);
+ setGamepath(data_array[0] + "/steamapps/common/Titanfall2")
saveSettings();
cli.exit();
- // Return 1 if success
- return 1;
+ return true;
}
}
}
@@ -155,13 +169,13 @@ function setpath(win) {
case "win32":
if (fs.existsSync("C:\\Program Files (x86)\\Steam\\steamapps\\libraryfolders.vdf")) {
let data = fs.readFileSync("C:\\Program Files (x86)\\Steam\\steamapps\\libraryfolders.vdf")
- if (readvdf(data.toString()) == 1) {return}
+ if (readvdf(data.toString())) {return}
}
break;
case "linux":
if (fs.existsSync(path.join(app.getPath("home"), "/.steam/steam/steamapps/libraryfolders.vdf"))) {
let data = fs.readFileSync(os.homedir() + "/.steam/steam/steamapps/libraryfolders.vdf")
- if (readvdf(data.toString()) == 1) {return}
+ if (readvdf(data.toString())) {return}
}
break;
}