aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/extras/find.js36
-rw-r--r--src/lang/en.json8
-rw-r--r--src/utils.js43
3 files changed, 70 insertions, 17 deletions
diff --git a/src/extras/find.js b/src/extras/find.js
index 0d32157..3f5a555 100644
--- a/src/extras/find.js
+++ b/src/extras/find.js
@@ -6,6 +6,7 @@ const { app } = require("electron");
const util = require("util");
const exec = util.promisify(require("child_process").exec);
+let libraries = [];
let home = app.getPath("home");
let symdir = ".steam/steam";
@@ -38,7 +39,30 @@ module.exports = {
return false;
},
- game: async () => {
+ proton: () => {
+ module.exports.game(true);
+
+ let proton = "0.0";
+ let protonpath = false;
+
+ for (let i = 0; i < libraries.length; i++) {
+ let files = fs.readdirSync(libraries[i]);
+ for (let ii = 0; ii < files.length; ii++) {
+ if (files[ii].match(/^Proton [0-9]+\.[0-9]+/)) {
+ if (fs.existsSync(path.join(libraries[i], files[ii], "/dist/bin/wine64"))) {
+ let version = files[ii].replace(/^Proton /, "");
+ if (version > proton) {
+ proton = version;
+ protonpath = path.join(libraries[i], files[ii], "/dist/bin/wine64");
+ }
+ }
+ }
+ }
+ }
+
+ return protonpath;
+ },
+ game: async (quiet) => {
let gamepath = "";
// Autodetect path
@@ -67,16 +91,20 @@ module.exports = {
if (typeof values[values.length - 1] != "object") {
values.pop(1);
}
+
+ libraries = [];
// `.length - 1` This is because the last value is `contentstatsid`
for (let i = 0; i < values.length; i++) {
+ libraries.push(values[i].path + "/steamapps/common");
+
let data_array = Object.values(values[i])
if (fs.existsSync(data_array[0] + "/steamapps/common/Titanfall2/Titanfall2.exe")) {
- console.log("Found game in:", data_array[0])
+ if (! quiet ) {console.log("Found game in:", data_array[0])}
return data_array[0] + "/steamapps/common/Titanfall2";
} else {
- console.log("Game not in:", data_array[0])
+ if (! quiet ) {console.log("Game not in:", data_array[0])}
}
}
}
@@ -102,7 +130,7 @@ module.exports = {
if (folders.length > 0) {
for (let i = 0; i < folders.length; i++) {
if (! fs.existsSync(folders[i])) {continue}
- console.log("Searching VDF file at:", folders[i])
+ if (! quiet ) {console.log("Searching VDF file at:", folders[i])}
let data = fs.readFileSync(folders[i])
let read_vdf = readvdf(data.toString())
diff --git a/src/lang/en.json b/src/lang/en.json
index fbd6b0b..92aab31 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -92,9 +92,9 @@
"gui.settings.nsargs.title": "Launch options",
"gui.settings.nsargs.desc": "Here you can add launch options for Northstar/Titanfall.",
"gui.settings.wineprefix.title": "Wine Prefix",
- "gui.settings.wineprefix.desc": "The prefix which Wine/Proton will run from, if the game is installed through Steam this should be auto detected.",
+ "gui.settings.wineprefix.desc": "The prefix which Wine/Proton will use, if left empty, it'll try to find your Steam prefix automatically.",
"gui.settings.winebin.title": "Wine Executable",
- "gui.settings.winebin.desc": "The version of Wine/Proton to use to run the game, this is by default set to \"/usr/bin/wine64\" if Proton can't be found.<br><br>This is unlikely to work properly, and is only a fallback",
+ "gui.settings.winebin.desc": "The version of Wine/Proton to use to run the game, if set to \"/usr/bin/wine64\", Viper will try to find the latest installed version of Proton automatically, if it can't find anything it'll fallback to wine64",
"gui.settings.autolang.title": "Auto-Detect Language",
"gui.settings.autolang.desc": "When enabled, Viper tries to automatically detect your system language, when disabled you can manually change the language below.",
"gui.settings.forcedlang.title": "Language",
@@ -132,6 +132,10 @@
"gui.toast.desc.malformed": "has an incorrect folder structure, if you're the developer, you should fix this.",
"gui.toast.desc.failed": "An unknown error occurred while trying to install the mod. This may be the author's fault, and it may also be Viper's fault.",
+ "wine.invalidprefix": "The selected Wine prefix doesn't exist, and is therefore invalid.",
+ "wine.originnotfound": "Origin can't be found in the selected Wine prefix.",
+ "wine.cantfindprefix": "Viper was unable to automatically find and set your Wine prefix.",
+
"viper.menu.main": "Viper",
"viper.menu.release": "Release Notes",
"viper.menu.info": "Extras",
diff --git a/src/utils.js b/src/utils.js
index b100cf9..bb5b982 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -357,17 +357,35 @@ function updatevp(autoinstall) {
// however it'll be added at some point.
function launch(version) {
let cwd = process.cwd();
- let prefix = settings.wineprefix;
+ let prefix = {
+ path: settings.wineprefix,
+ origin: path.join(settings.wineprefix, "/drive_c/Program Files (x86)/Origin/Origin.exe")
+ }
+
process.chdir(settings.gamepath);
+ let winebin = settings.winebin;
+
if (process.platform != "win32") {
- let foundprefix = find.prefix();
- if (foundprefix) {
- prefix = foundprefix;
+ if (winebin == "/usr/bin/wine64") {
+ let proton = find.proton();
+ if (proton) {winebin = proton}
+ }
+
+ if (prefix.path == "") {
+ let foundprefix = find.prefix();
+ if (foundprefix) {
+ prefix = foundprefix;
+ } else {
+ winAlert(lang("wine.cantfindprefix"));
+ return false;
+ }
+ } else {
+
}
if (! fs.existsSync(prefix.path)) {
- winAlert("invalid wine prefix");
+ winAlert(lang("wine.invalidprefix") + "\n\n" + prefix.path);
return false;
} else {
process.env["WINEPREFIX"] = prefix.path;
@@ -379,7 +397,7 @@ function launch(version) {
console.log(lang("general.launching"), "Vanilla...")
if (process.platform != "win32") {
- run(settings.winebin, [path.join(settings.gamepath + "/Titanfall2.exe")])
+ run(winebin, [path.join(settings.gamepath + "/Titanfall2.exe")])
} else {
run(path.join(settings.gamepath + "/Titanfall2.exe"))
}
@@ -389,10 +407,15 @@ function launch(version) {
console.log(lang("general.launching"), "Northstar...")
if (process.platform != "win32") {
- run(settings.winebin, [prefix.origin])
- run(settings.winebin, [path.join(settings.gamepath + "/NorthstarLauncher.exe")])
+ if (! fs.existsSync(prefix.origin)) {
+ winAlert(lang("wine.originnotfound") + "\n\n" + prefix.origin);
+ return false;
+ }
+
+ run(winebin, [prefix.origin])
+ run(winebin, [path.join(settings.gamepath + "/NorthstarLauncher.exe")])
} else {
- run(path.join(settings.gamepath + "/Titanfall2.exe -northstar"))
+ run(path.join(settings.gamepath + "/Titanfall2.exe", ["-northstar"]))
}
break;
@@ -824,8 +847,6 @@ setInterval(() => {
}
}, 1500)
-console.log(find.prefix())
-
module.exports = {
mods,
lang,