aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/dev_builds.yml10
-rw-r--r--.github/workflows/release_builds.yml4
-rw-r--r--package-lock.json4
-rw-r--r--package.json2
-rw-r--r--src/app/icons/linux.pngbin0 -> 6465 bytes
-rw-r--r--src/app/index.html47
-rw-r--r--src/app/js/settings.js37
-rw-r--r--src/app/js/toasts.js4
-rw-r--r--src/lang/de.json30
-rw-r--r--src/lang/en.json35
-rw-r--r--src/lang/es.json24
-rw-r--r--src/lang/fr.json30
-rw-r--r--src/lang/zh.json30
-rw-r--r--src/modules/in_path.js24
-rw-r--r--src/modules/launch.js195
-rw-r--r--src/modules/settings.js4
-rw-r--r--src/win.js19
17 files changed, 457 insertions, 42 deletions
diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml
index 1951ee7..d60db94 100644
--- a/.github/workflows/dev_builds.yml
+++ b/.github/workflows/dev_builds.yml
@@ -14,13 +14,13 @@ jobs:
- name: Setup Node environment
uses: actions/setup-node@v3
with:
- node-version: 16
+ node-version: 20
- name: Install dependencies
run: npm install
- name: Create builds
run: npm run build:windows
- name: Archive production artifacts
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: viper-windows-builds
path: |
@@ -34,17 +34,17 @@ jobs:
- name: Setup Node environment
uses: actions/setup-node@v3
with:
- node-version: 16
+ node-version: 20
- name: Install dependencies
run: npm install
- name: Create builds
run: npm run build:linux
- name: Archive production artifacts
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: viper-linux-builds
path: |
dist/*.AppImage
dist/*.tar.gz
dist/*.deb
- dist/*.rpm \ No newline at end of file
+ dist/*.rpm
diff --git a/.github/workflows/release_builds.yml b/.github/workflows/release_builds.yml
index bc3dac6..e2ebb04 100644
--- a/.github/workflows/release_builds.yml
+++ b/.github/workflows/release_builds.yml
@@ -12,7 +12,7 @@ jobs:
- name: Setup Node environment
uses: actions/setup-node@v3
with:
- node-version: 16
+ node-version: 20
- name: Install dependencies
run: npm install
- name: Create builds
@@ -35,7 +35,7 @@ jobs:
- name: Setup Node environment
uses: actions/setup-node@v3
with:
- node-version: 16
+ node-version: 20
- name: Install dependencies
run: npm install
- name: Create builds
diff --git a/package-lock.json b/package-lock.json
index 17cd704..3d93f18 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "viper",
- "version": "1.11.1",
+ "version": "1.12.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "viper",
- "version": "1.11.1",
+ "version": "1.12.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"electron-updater": "^4.6.1",
diff --git a/package.json b/package.json
index 9a7ea79..be9ab65 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "viper",
"productName": "Viper",
- "version": "1.11.1",
+ "version": "1.12.0",
"description": "Launcher+Updater for TF|2 Northstar",
"main": "src/index.js",
"build": {
diff --git a/src/app/icons/linux.png b/src/app/icons/linux.png
new file mode 100644
index 0000000..29460ce
--- /dev/null
+++ b/src/app/icons/linux.png
Binary files differ
diff --git a/src/app/index.html b/src/app/index.html
index 1f9f443..9e97810 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -65,6 +65,53 @@
</div>
</div>
</details>
+ <details open platform="linux">
+ <summary>
+ <div class="title">
+ <img src="icons/linux.png">
+ <h2>%%gui.settings.title.linux%%</h2>
+ </div>
+ </summary>
+ <div class="option" name="linux_launch_method">
+ <div class="text">
+ %%gui.settings.linux_launch_method.title%%
+ <div class="desc">
+ %%gui.settings.linux_launch_method.desc%%
+ </div>
+ </div>
+ <div class="actions">
+ <select>
+ <option value="steam_auto">%%gui.settings.linux_launch_method.methods.steam_auto%%</option>
+ <option value="steam_executable">%%gui.settings.linux_launch_method.methods.steam_executable%%</option>
+ <option value="steam_flatpak">%%gui.settings.linux_launch_method.methods.steam_flatpak%%</option>
+ <option value="steam_protocol">%%gui.settings.linux_launch_method.methods.steam_protocol%%</option>
+ <option value="custom_command">%%gui.settings.linux_launch_method.methods.command%%</option>
+ </select>
+ </div>
+ </div>
+ <div class="option" name="linux_launch_cmd_ns">
+ <div class="text">
+ %%gui.settings.linux_launch_cmd_ns.title%%
+ <div class="desc">
+ %%gui.settings.linux_launch_cmd_ns.desc%%
+ </div>
+ </div>
+ <div class="actions">
+ <input>
+ </div>
+ </div>
+ <div class="option" name="linux_launch_cmd_vanilla">
+ <div class="text">
+ %%gui.settings.linux_launch_cmd_vanilla.title%%
+ <div class="desc">
+ %%gui.settings.linux_launch_cmd_vanilla.desc%%
+ </div>
+ </div>
+ <div class="actions">
+ <input>
+ </div>
+ </div>
+ </details>
<details open>
<summary>
diff --git a/src/app/js/settings.js b/src/app/js/settings.js
index d57dfc7..b5ef773 100644
--- a/src/app/js/settings.js
+++ b/src/app/js/settings.js
@@ -106,6 +106,8 @@ ipcRenderer.on("changed-settings", (e, new_settings) => {
})
let settings = {
+ default: {...settings_data},
+
data: () => {return settings_data},
// asks the main process to reset the config/settings file
@@ -138,7 +140,7 @@ settings.popup.toggle = (state) => {
}
settings.popup.apply = () => {
- settings = {...settings, ...settings.popup.get()};
+ settings.set(settings.popup.get());
ipcRenderer.send("save-settings", settings.popup.get());
}
@@ -174,11 +176,25 @@ settings.popup.load = () => {
let categories = document.querySelectorAll("#options details");
for (let i = 0; i < categories.length; i++) {
categories[i].setAttribute("open", true);
+
+ // hide categories that aren't for the current platform
+ let for_platform = categories[i].getAttribute("platform");
+ if (for_platform && process.platform != for_platform) {
+ categories[i].style.display = "none";
+ categories[i].setAttribute("perma-hidden", true);
+ }
}
let options = document.querySelectorAll(".option");
for (let i = 0; i < options.length; i++) {
+ // hide options that aren't for the current platform
+ let for_platform = options[i].getAttribute("platform");
+ if (for_platform && process.platform != for_platform) {
+ options[i].style.display = "none";
+ options[i].setAttribute("perma-hidden", true);
+ }
+
let optName = options[i].getAttribute("name");
if (optName == "forcedlang") {
let div = options[i].querySelector("select");
@@ -207,6 +223,25 @@ settings.popup.load = () => {
}
if (settings_data[optName] != undefined) {
+ // check if setting has a `<select>`
+ let select_el = options[i].querySelector(".actions select");
+ if (select_el) {
+ // get `<option>` for settings value, if it exists
+ let option = select_el.querySelector(
+ `option[value="${settings_data[optName]}"]`
+ )
+
+ // check if it exists
+ if (option) {
+ // set the `<select>` to the settings value
+ select_el.value = settings_data[optName];
+ } else { // use the default value
+ select_el.value = settings.default[optName];
+ }
+
+ continue;
+ }
+
switch(typeof settings_data[optName]) {
case "string":
options[i].querySelector(".actions input").value = settings_data[optName];
diff --git a/src/app/js/toasts.js b/src/app/js/toasts.js
index c3bba99..83ddf6a 100644
--- a/src/app/js/toasts.js
+++ b/src/app/js/toasts.js
@@ -74,4 +74,8 @@ toasts.dismiss = (id) => {
}
}
+ipcRenderer.on("toast", (_, properties) => {
+ Toast(properties);
+})
+
module.exports = toasts;
diff --git a/src/lang/de.json b/src/lang/de.json
index c7dfb0e..9e68986 100644
--- a/src/lang/de.json
+++ b/src/lang/de.json
@@ -150,6 +150,25 @@
"desc": "Wenn \"Automatische Spracherkennung\" deaktiviert ist, wird diese Option genutzt um die Sprachen zu ändern. Oft ist ein Neustart nötig!",
"title": "Sprache"
},
+ "linux_launch_cmd_ns": {
+ "desc": "Dieser Befehl wird zum starten von Northstar ausgeführt wenn die Startmethode \"Eigener Befehl\" ausgewählt ist. Startvariabeln werden am ende des Befehl angehangen und als Environmentvariable $TF_ARGS mitgegeben.",
+ "title": "Northstar Startbefehl"
+ },
+ "linux_launch_cmd_vanilla": {
+ "desc": "Dieser Befehl wird zum starten von Vanilla ausgeführt wenn die Startmethode \"Eigener Befehl\" ausgewählt ist. Startvariabeln werden am ende des Befehls angehangen und als Environmentvariable $TF_ARGS mitgegeben.",
+ "title": "Vanilla Startbefehl"
+ },
+ "linux_launch_method": {
+ "desc": "Die Methode welche zum start des Spieles auf Linux genutzt wird.",
+ "methods": {
+ "command": "Eigener Befehl",
+ "steam_auto": "Steam (Automatisch)",
+ "steam_executable": "Steam (Ausführungsdatei)",
+ "steam_flatpak": "Steam (Flatpak)",
+ "steam_protocol": "Steam (Protokoll)"
+ },
+ "title": "Linux Startmethode"
+ },
"miscbuttons": {
"buttons": {
"change_gamepath": "Spielepfad ändern",
@@ -179,6 +198,7 @@
"save": "Speichern",
"title": {
"language": "Sprache",
+ "linux": "Linux",
"misc": "Sonstiges",
"ns": "Northstar",
"updates": "Updates"
@@ -197,16 +217,26 @@
"desc": {
"duped": "hat mehrere Ordner in sich mit dem selben Namen, wodurch ein duplizierter Ordner ensteht! Falls du der Entwickler bist solltest du dies beheben!",
"failed": "Ein unbekannter Fehler ist aufgetaucht beim Installieren, die Schuld kann beim Autor liegen oder bei Viper selbst!",
+ "failed_launch_command": "Es gab einen Fehler beim ausführen vom Startbefehl.",
"installed": "wurde installiert!",
"malformed": "hat eine fehlerhafte Ordnerstruktur, falls du der Entwickler bist, solltest du dies beheben.",
+ "missing_flatpak": "Konnte nicht mit Flatpak starten, da keine Instanz gefunden wurde.",
+ "missing_flatpak_steam": "Konnte nicht mit der Flatpak version von Steam starten, da keine Instanz gefunden wurde.",
+ "missing_launch_command": "Es wurde kein Startbefehl angegeben, bitte setze einen fest.",
+ "missing_steam": "Kann nicht direkt über Steam starten, da keine Instanz gefunden wurde.",
"no_internet": "Viper funktioniert möglicherweise nicht korrekt",
"unknown_error": "Ein unbekannter Fehler ist aufgetreten für mehr details drücken! Es wird empfohlen einen Screenshot von der detalierten Fehlernachricht zu machen wenn ein Bug-Report erstellt wird!"
},
"title": {
"duped": "Duplizierter Ordner name!",
"failed": "Fehler beim Installieren des Mods!",
+ "failed_launch_command": "Ausführungsfehler vom Startbefehl!",
"installed": "Mod installiert!",
"malformed": "Fehlerhafte Ordnerstruktur!",
+ "missing_flatpak": "Flatpak fehlt!",
+ "missing_flatpak_steam": "Flatpak Steam fehlt!",
+ "missing_launch_command": "Fehlender Startbefehl!",
+ "missing_steam": "Steam fehlt!",
"no_internet": "Kein Internet",
"unknown_error": "Unbekannter Fehler!"
}
diff --git a/src/lang/en.json b/src/lang/en.json
index eca640d..c705517 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -134,6 +134,7 @@
"title": {
"ns": "Northstar",
+ "linux": "Linux",
"language": "Language",
"updates": "Updates",
"misc": "Miscellaneous"
@@ -198,6 +199,26 @@
"open_gamepath_alert": "No valid gamepath is selected, so there's no gamepath to open, please select a valid gamepath first!",
"reset_config_alert": "Please confirm that you want to reset the config file, after confirming Viper will delete the config file, and then restart."
+ },
+
+ "linux_launch_method": {
+ "title": "Linux launch method",
+ "desc": "The method to use when launching the game on Linux",
+ "methods": {
+ "steam_auto": "Steam (Auto)",
+ "steam_executable": "Steam (Executable)",
+ "steam_flatpak": "Steam (Flatpak)",
+ "steam_protocol": "Steam (Protocol)",
+ "command": "Custom command"
+ }
+ },
+ "linux_launch_cmd_ns": {
+ "title": "Northstar launch command",
+ "desc": "This is the command that will be used when you use \"Custom command\" as the launch method and you're launching Northstar, launch options are appended at the end of the command and in an environment variable named $TF_ARGS"
+ },
+ "linux_launch_cmd_vanilla": {
+ "title": "Vanilla launch command",
+ "desc": "This is the command that will be used when you use \"Custom command\" as the launch method and you're launching the vanilla game, launch options are appended at the end of the command and in an environment variable named $TF_ARGS"
}
},
@@ -234,7 +255,12 @@
"failed": "Failed to install",
"malformed": "Incorrect folder structure!",
"unknown_error": "Unknown Error!",
- "no_internet": "No Internet"
+ "no_internet": "No Internet",
+ "failed_launch_command": "Failed running launch command",
+ "missing_launch_command": "Missing launch command",
+ "missing_steam": "Missing Steam",
+ "missing_flatpak": "Missing Flatpak",
+ "missing_flatpak_steam": "Missing Flatpak Steam"
},
"desc": {
@@ -243,7 +269,12 @@
"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.",
"duped": "has multiple mod folders in it, with the same name, causing duplicate folders, if you're the developer, you should fix this.",
"unknown_error": "An unknown error occurred, click for more details. You may want to take a screenshot of the detailed error when filing a bug report.",
- "no_internet": "Viper may not work properly."
+ "no_internet": "Viper may not work properly.",
+ "failed_launch_command": "Something went wrong whilst running the custom launch command",
+ "missing_launch_command": "There's currently no custom launch command set, one has to be configured to launch",
+ "missing_steam": "Can't launch with Steam directly, as it doesn't seem to be installed",
+ "missing_flatpak": "Can't launch with Flatpak, as it doesn't seem to be installed",
+ "missing_flatpak_steam": "Can't launch with the Flatpak version of Steam, as it doesn't seem to be installed"
}
}
},
diff --git a/src/lang/es.json b/src/lang/es.json
index 4a8d238..3da6d89 100644
--- a/src/lang/es.json
+++ b/src/lang/es.json
@@ -150,6 +150,25 @@
"desc": "Cuando \"Detectar automáticamente el idioma\" está deshabilitado, ésta opción decidirá el lenguaje. Se necesita reiniciar para que surja efecto.",
"title": "Idioma"
},
+ "linux_launch_cmd_ns": {
+ "desc": "Este es el comando que será usado cuando seleccione \"Comando personalizado\" como el método de ejecución al lanzar Northstar. Las opciones de ejecución seran añadidas al final de dicho comando y en una variable de entorno llamada $TF_ARGS",
+ "title": "Comando de lanzamiento para Northstar"
+ },
+ "linux_launch_cmd_vanilla": {
+ "desc": "Este es el comando que será usado cuando seleccione \"Comando personalizado\" como el método de ejecución al lanzar la versión \"Vanilla\" del juego. Las opciones de ejecución seran añadidas al final de dicho comando y en una variable de entorno llamada $TF_ARGS",
+ "title": "Comando de ejecución para \"Vanilla\""
+ },
+ "linux_launch_method": {
+ "desc": "El método a usarse cuando ejecute el juego en Linux",
+ "methods": {
+ "command": "Comando personalizado",
+ "steam_auto": "Steam (Automático)",
+ "steam_executable": "Steam (Ejecutable)",
+ "steam_flatpak": "Steam (Flatpak)",
+ "steam_protocol": "Steam (Protocolo)"
+ },
+ "title": "Modo de ejecución en Linux"
+ },
"miscbuttons": {
"buttons": {
"change_gamepath": "Cambiar ruta del juego",
@@ -179,6 +198,7 @@
"save": "Guardar",
"title": {
"language": "Idioma",
+ "linux": "Linux",
"misc": "Misceláneos",
"ns": "Northstar",
"updates": "Actualizaciones"
@@ -205,8 +225,10 @@
"title": {
"duped": "tiene varias carpetas de la modificación con el mismo nombre, lo que genera carpetas duplicadas. Si eres el desarrollador, deberías arreglar esto.",
"failed": "¡Falló al instalar!",
+ "failed_launch_command": "Error al ejecutar el comando de lanzamiento",
"installed": "¡Modificación instalada!",
"malformed": "¡Estructura de las carpetas incorrecta!",
+ "missing_launch_command": "El comando de lanzamiento no fue asignado o no se encuentra",
"no_internet": "Sin Internet",
"unknown_error": "¡Error desconocido!"
}
@@ -264,4 +286,4 @@
"release": "Notas de la versión"
}
}
-} \ No newline at end of file
+}
diff --git a/src/lang/fr.json b/src/lang/fr.json
index 675fa33..52d9703 100644
--- a/src/lang/fr.json
+++ b/src/lang/fr.json
@@ -150,6 +150,25 @@
"desc": "Lorsque \"Auto-détection de la langue\" est désactivée, cette option permet de sélectionner la langue (requiert un redémarrage).",
"title": "Langue"
},
+ "linux_launch_cmd_ns": {
+ "desc": "Commande qui sera utilisée lorsque vous sélectionnez \"Commande personnalisée\" comme méthode de lancement de Northstar ; les arguments de démarrage sont ajoutés à la fin de cette commande et dans une variable d'environnement nommée $TF_ARGS",
+ "title": "Commande de lancement de Northstar"
+ },
+ "linux_launch_cmd_vanilla": {
+ "desc": "Commande qui sera utilisée lorsque vous sélectionnez \"Commande personnalisée\" comme méthode de lancement vanilla ; les arguments de démarrage sont ajoutés à la fin de cette commande et dans une variable d'environnement nommée $TF_ARGS",
+ "title": "Commande de lancement vanilla"
+ },
+ "linux_launch_method": {
+ "desc": "La façon de lancer le jeu sur Linux",
+ "methods": {
+ "command": "Commande personnalisée",
+ "steam_auto": "Steam (auto)",
+ "steam_executable": "Steam (exécutable)",
+ "steam_flatpak": "Steam (Flatpak)",
+ "steam_protocol": "Steam (protocole)"
+ },
+ "title": "Méthode de lancement sur Linux"
+ },
"miscbuttons": {
"buttons": {
"change_gamepath": "Changer le dossier du jeu",
@@ -179,6 +198,7 @@
"save": "Sauvegarder",
"title": {
"language": "Langue",
+ "linux": "Linux",
"misc": "Divers",
"ns": "Northstar",
"updates": "Mises à jour"
@@ -197,16 +217,26 @@
"desc": {
"duped": "contient plusieurs dossiers ayant le même nom ; si vous êtes le développer, vous devriez réparer ceci.",
"failed": "Une erreur inconnue est survenue lors de l'installation du mod. Cela peut être du ressort de l'auteur du mod ou de Viper.",
+ "failed_launch_command": "Quelque chose s'est mal passé lors de l'exécution de la commande",
"installed": "a été installé avec succès !",
"malformed": "a une structure de dossier incorrecte ; si vous êtes son développeur, vous devriez réparer ça.",
+ "missing_flatpak": "Lancement via Flatpak impossible (ne semble pas être installé)",
+ "missing_flatpak_steam": "Lancement via Flatpak Steam impossible (ne semble pas être installé)",
+ "missing_launch_command": "Il n'y a actuellement pas d'argument de lancement configuré, il en faut au moins un pour lancer le jeu",
+ "missing_steam": "Lancement via Steam impossible (ne semble pas être installé)",
"no_internet": "Viper ne fonctionnera pas correctement tant que la connexion n'est pas rétablie.",
"unknown_error": "Une erreur inconnue est survenue, cliquez pour plus de détails. Vous devriez prendre une capture d'écran de l'erreur si vous comptez créer un ticket."
},
"title": {
"duped": "Nom de dossier dupliqué !",
"failed": "L'installation a échoué",
+ "failed_launch_command": "Echec du lancement de la commande",
"installed": "Mod installé !",
"malformed": "La structure du dossier du mod est incorrecte.",
+ "missing_flatpak": "Flatpak manquant",
+ "missing_flatpak_steam": "Flatpak Steam manquant",
+ "missing_launch_command": "Commande de lancement manquante",
+ "missing_steam": "Steam manquant",
"no_internet": "Pas de connexion Internet",
"unknown_error": "Erreur inconnue"
}
diff --git a/src/lang/zh.json b/src/lang/zh.json
index ccd3ce7..ae086d4 100644
--- a/src/lang/zh.json
+++ b/src/lang/zh.json
@@ -150,6 +150,25 @@
"desc": "当 \"自动检测语言\" 被禁用后, 此设置将会作为Viper的语言. 需要重启Viper来生效.",
"title": "语言"
},
+ "linux_launch_cmd_ns": {
+ "desc": "当您以 \"自定义命令\" 选项启动Northstar客户端时,此项将会以$TF_ARGS的形式包含在启动命令的尾部作为Northstar的启动参数",
+ "title": "Northstar启动参数"
+ },
+ "linux_launch_cmd_vanilla": {
+ "desc": "当您以 \"自定义命令\" 选项启动原版客户端时,此项将会以$TF_ARGS的形式包含在启动命令的尾部作为原版的启动参数",
+ "title": "原版启动参数"
+ },
+ "linux_launch_method": {
+ "desc": "在Linux系统中启动游戏的方式",
+ "methods": {
+ "command": "自定义命令",
+ "steam_auto": "Steam(自动)",
+ "steam_executable": "Steam(程序)",
+ "steam_flatpak": "Steam (Flatpak)",
+ "steam_protocol": "Steam (Protocol)"
+ },
+ "title": "Linux启动方式"
+ },
"miscbuttons": {
"buttons": {
"change_gamepath": "更改游戏目录",
@@ -179,6 +198,7 @@
"save": "保存",
"title": {
"language": "语言",
+ "linux": "Linux",
"misc": "杂项",
"ns": "Northstar",
"updates": "更新"
@@ -197,16 +217,26 @@
"desc": {
"duped": "存在多个同名的模组文件夹, 如果你是它的开发者, 你应该修复这个问题.",
"failed": "在尝试安装该时发生了未知错误, 这可能是作者的问题, 也可能是Viper的问题",
+ "failed_launch_command": "在运行自定义启动命令时发生了一些错误",
"installed": "已成功安装!",
"malformed": "拥有错误的文件夹结构, 如果您是它的开发者, 您应该修复这个问题.",
+ "missing_flatpak": "无法以Flatpak的方式启动,看起来它并没有被安装",
+ "missing_flatpak_steam": "无法以Steam (Flatpak) 的方式启动,看起来它并没有被安装",
+ "missing_launch_command": "当前缺少运行游戏的自定义命令,需指定来启动游戏",
+ "missing_steam": "无法以Steam的方式启动,看起来它并没有被安装",
"no_internet": "Viper可能不会正常工作.",
"unknown_error": "一个未知错误产生了, 点击来查看更多细节. 您可能会想要对错误信息进行截图用于bug反馈"
},
"title": {
"duped": "重复的文件夹名字!",
"failed": "安装失败",
+ "failed_launch_command": "运行启动命令失败",
"installed": "模组安装成功!",
"malformed": "错误的文件夹结构!",
+ "missing_flatpak": "缺少Flatpak",
+ "missing_flatpak_steam": "缺少Steam(Flatpak)",
+ "missing_launch_command": "缺少启动命令",
+ "missing_steam": "缺少Steam",
"no_internet": "没有互联网",
"unknown_error": "未知错误!"
}
diff --git a/src/modules/in_path.js b/src/modules/in_path.js
new file mode 100644
index 0000000..49288c1
--- /dev/null
+++ b/src/modules/in_path.js
@@ -0,0 +1,24 @@
+const fs = require("fs");
+const join = require("path").join;
+
+// checks whether `executable_to_check` is in `$PATH`
+module.exports = (executable_to_check) => {
+ // get folders in `$PATH`
+ let path_dirs = process.env["PATH"].split(":");
+
+ // run through folders
+ for (let i = 0; i < path_dirs.length; i++) {
+ // path to executable this iteration
+ let executable = join(path_dirs[i], executable_to_check);
+
+ // if `executable` exists and is a file, then we found it
+ if (fs.existsSync(executable)
+ && fs.statSync(executable).isFile()) {
+
+ return true;
+ }
+ }
+
+ // we didn't find `executable_to_check`
+ return false;
+}
diff --git a/src/modules/launch.js b/src/modules/launch.js
index 7faf372..fab80c7 100644
--- a/src/modules/launch.js
+++ b/src/modules/launch.js
@@ -1,10 +1,11 @@
-const exec = require("child_process").exec;
-const ipcMain = require("electron").ipcMain;
+const { ipcMain, shell } = require("electron");
+const { exec, execSync } = require("child_process");
const cli = require("../cli");
const win = require("../win");
const lang = require("../lang");
+const in_path = require("./in_path");
const settings = require("./settings");
console = require("./console");
@@ -17,37 +18,187 @@ ipcMain.on("launch", (_, game_version) => {
//
// either Northstar or Vanilla. Linux support is not currently a thing,
// however it'll be added at some point.
-function launch(game_version) {
- // return early, and show error message if on Linux
- if (process.platform == "linux") {
- win().alert(lang("cli.launch.linux_error"));
- console.error(lang("cli.launch.linux_error"));
- cli.exit(1);
- return;
- }
+function launch(game_version, method = settings().linux_launch_method) {
+ console.info(
+ lang("general.launching"),
+ game_version || "Northstar" + "..."
+ )
// change current directory to gamepath
process.chdir(settings().gamepath);
let launch_args = settings().nsargs || "";
- // launch the requested game version
- switch(game_version) {
- case "vanilla":
- console.info(lang("general.launching"), "Vanilla...");
- exec("Titanfall2.exe " + launch_args, {
- cwd: settings().gamepath
+ // add `-vanilla` or `-northstar` depending on `game_version`
+ if (game_version == "vanilla") {
+ launch_args += " -vanilla"
+ } else {
+ launch_args += " -northstar"
+ }
+
+
+ // Linux launch support
+ if (process.platform == "linux") {
+ let flatpak_id = "com.valvesoftware.Steam";
+ let steam_run_str = `steam://run/1237970//${launch_args}/`;
+ console.log(steam_run_str)
+
+ // returns whether the Flatpak version of Steam is installed
+ let flatpak_steam_installed = () => {
+ // this will throw an error if the command fails,
+ // either because of an error with the command, or
+ // because it's not installed, either way,
+ // indicating it's not installed
+ try {
+ execSync(
+ `flatpak info ${flatpak_id}`
+ )
+
+ return true;
+ }catch(err) {}
+
+ return false;
+ }
+
+ switch(method) {
+ case "steam_auto":
+ // if a Steam executable is found, use that
+ if (in_path("steam")) {
+ return launch(game_version, "steam_executable");
+
+ // is Flatpak (likely) installed?
+ } else if (in_path("flatpak")) {
+
+ if (flatpak_steam_installed()) {
+ return launch(game_version, "steam_flatpak");
+ }
+ }
+
+ // fallback to Steam protocol
+ return launch(game_version, "steam_protocol");
+
+ case "steam_flatpak":
+ // make sure Flatpak is installed, and show an error
+ // toast if not
+ if (! in_path("flatpak")) {
+ win().toast({
+ scheme: "error",
+ title: lang("gui.toast.title.missing_flatpak"),
+ description: lang(
+ "gui.toast.desc.missing_flatpak"
+ )
+ })
+ return;
+ }
+
+ // make sure the Flatpak version of Steam is installed,
+ // and show an error toast if not
+ if (! flatpak_steam_installed()) {
+ win().toast({
+ scheme: "error",
+ title: lang(
+ "gui.toast.title.missing_flatpak_steam"
+ ),
+ description: lang(
+ "gui.toast.desc.missing_flatpak_steam"
+ )
+ })
+ return;
+ }
+
+ // attempt to launch the game with Flatpak Steam
+ exec(`flatpak run ${flatpak_id} "${steam_run_str}"`, {
+
+ cwd: settings().gamepath
+ })
+
+ return;
+
+ case "steam_executable":
+ // make sure Steam is installed, and show an error toast
+ // if not
+ if (! in_path("steam")) {
+ win().toast({
+ scheme: "error",
+ title: lang("gui.toast.title.missing_steam"),
+ description: lang(
+ "gui.toast.desc.missing_steam"
+ )
+ })
+ return;
+ }
+
+ // attempt to launch the game with the Steam executable
+ exec(`steam "${steam_run_str}"`, {
+ cwd: settings().gamepath
+ })
+
+ return;
+
+ case "steam_protocol":
+ // attempt to launch the game with the Steam protocol
+ shell.openExternal(steam_run_str)
+
+ return;
+ }
+
+ // launch Vanilla with custom command
+ let command = settings().linux_launch_cmd_ns;
+ if (game_version == "vanilla") {
+ command = settings().linux_launch_cmd_vanilla;
+ }
+
+ // make sure the custom command is not just whitespace, and show
+ // an error toast if it is
+ if (! command.trim()) {
+ win().toast({
+ scheme: "error",
+ title: lang("gui.toast.title.missing_launch_command"),
+ description: lang(
+ "gui.toast.desc.missing_launch_command"
+ )
})
- break;
- default:
- console.info(lang("general.launching"), "Northstar...");
- exec("NorthstarLauncher.exe " + launch_args, {
- cwd: settings().gamepath
+ return;
+ }
+
+ // launch Northstar with custom command
+ try {
+ exec(command, {
+ cwd: settings().gamepath,
+ env: {
+ ...process.env,
+ TF_ARGS: launch_args
+ }
})
+ }catch(err) {
+ // show error if custom commands fails
+ // this should basically never trigger, it should only
+ // trigger if `command` isn't set to something valid
+ win().toast({
+ scheme: "error",
+ title: lang("gui.toast.title.failed_launch_command"),
+ description: lang(
+ "gui.toast.desc.failed_launch_command"
+ )
+ })
+ }
+
+ return;
+ }
- break;
+ // default launches with Northstar
+ let executable = "NorthstarLauncher.exe"
+
+ // change over to using vanilla executable
+ if (game_version == "vanilla") {
+ executable = "Titanfall2.exe"
}
+
+ // launch executable/game
+ exec(executable + " " + launch_args, {
+ cwd: settings().gamepath
+ })
}
module.exports = launch;
diff --git a/src/modules/settings.js b/src/modules/settings.js
index d513ec9..60d6be0 100644
--- a/src/modules/settings.js
+++ b/src/modules/settings.js
@@ -47,6 +47,10 @@ var settings = {
nsargs: "-multiple",
zip: "/northstar.zip",
+ linux_launch_cmd_ns: "",
+ linux_launch_cmd_vanilla: "",
+ linux_launch_method: "steam_auto",
+
// these files won't be overwritten when installing/updating
// Northstar, useful for config files
excludes: [
diff --git a/src/win.js b/src/win.js
index 9bec3c9..91ef93a 100644
--- a/src/win.js
+++ b/src/win.js
@@ -25,6 +25,11 @@ alert = async (msg) => {
})
}
+// sends an toast to the renderer
+toast = (properties) => {
+ win.send("toast", properties);
+}
+
// this increments for every confirm alert that's created, the ID is
// used to keep track of popups being opened or closed.
let confirm_id = 0;
@@ -48,9 +53,10 @@ confirm = async (msg) => {
let win = {
send: () => {},
- log: log,
- alert: alert,
- confirm: confirm
+ log: log,
+ toast: toast,
+ alert: alert,
+ confirm: confirm
}
let func = () => {
@@ -60,9 +66,10 @@ let func = () => {
func.set = (main_window) => {
win = main_window;
- win.log = log;
- win.alert = alert;
- win.confirm = confirm;
+ win.log = log;
+ win.toast = toast;
+ win.alert = alert;
+ win.confirm = confirm;
}
module.exports = func;