From 82ab89b7509f81066eea40d00dc7d7addf90be77 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 29 Apr 2024 17:55:06 +0200 Subject: [PATCH 01/11] fixed app/js/settings.js to for custom `'s for their value only worked on the `forcedlang` setting, now it just works overall, this wasn't an issue before, as we had no need for it. More importantly `forcedlang` is special in that it dynamically loads the list of languages available, so it was and still is handled separately, to support that behavior. --- src/app/js/settings.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/app/js/settings.js b/src/app/js/settings.js index 2d68c138..9eb6c760 100644 --- a/src/app/js/settings.js +++ b/src/app/js/settings.js @@ -1,6 +1,7 @@ var settings_fuse; var Settings = { + default: {settings}, toggle: (state) => { Settings.load(); options.scrollTo(0, 0); @@ -42,11 +43,25 @@ var Settings = { 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"); @@ -75,6 +90,25 @@ var Settings = { } if (settings[optName] != undefined) { + // check if setting has a `` to the settings value + select_el.value = settings[optName]; + } else { // use the default value + select_el.value = Settings.default[optName]; + } + + continue; + } + switch(typeof settings[optName]) { case "string": options[i].querySelector(".actions input").value = settings[optName]; @@ -92,7 +126,6 @@ var Settings = { switchDiv.classList.remove("on"); } break - } } } From 9b31e6dfc2277dc2b904b4319b9bc06f849c38dc Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 29 Apr 2024 18:01:07 +0200 Subject: [PATCH 02/11] added launch method settings --- src/app/icons/linux.png | Bin 0 -> 6465 bytes src/app/index.html | 47 ++++++++++++++++++++++++++++++++++++++++ src/app/main.js | 8 +++++++ src/modules/settings.js | 4 ++++ 4 files changed, 59 insertions(+) create mode 100644 src/app/icons/linux.png diff --git a/src/app/icons/linux.png b/src/app/icons/linux.png new file mode 100644 index 0000000000000000000000000000000000000000..29460ce9865fe058ddf9153018bd3c0921cf936b GIT binary patch literal 6465 zcmbt(=Tj3-xOG4f=}kh9KR{HP5I|Z)lp;k0R7xPUP$NlbYA7N_A(RM+LIkASAwUvH z1ZjcLBy=euAiXJFiYSOLci#Wt-VZyw`^@f~XU>P6bM_?L*_iY5Nbvvw0Demg)7t<5 z8}xt1DURbxy{{?*0FXRoX?o2*oVAu8k%@21YA-B#Retv>LjHzN7J#e}0BBAKHhl^^ zdsb4++Uxn3z^A<$Io&=Y-tCH!GMf69-QCG4k>{@67s>Y)O0FrsCIYS@Cb21!Kg1e; z?HT#oeI^!TqCN$idbr{^?9|lsyR_ip$_%Dq1IGKz;;cxrseH!&dTNau0164B(v^3v zigon^vjC+bfCu4RA6j>RUPfU)grAI zYm0nHcEH~wVhTjuX?+iWJ{y+W2uZ_Kh;$K8{DX}r=45;P*x;lK(#ZM2ME{>()dcLycs}Zl&uJZP_dS7FSeP|Jhz7C5ADh5E^6Apyd zQAES_g;9#x*}UdjR-aAnW)LgFS})FM2;&my`aYi#uXk8LWrQx&v3^@8wUkxM;vu5} zOG9dkyDm7V>9l3}bBoyztIcW@s53~mf@Jf4cUS^|OM`xR4HmCr)lQU2^VPF~B?v*l zUkC%h8LS9c72>ULGw3MSX^`hP`4u?x`1yYD)hCb=s)`0jSXO&){BsS}MXz^Mj*yEj zmsldMcI^LD^g(?^`BWY*8Jf>_9`)4S5?xiuOrJz)d5iE0xYr(ud!~4#)SP~!y@KXB zQKWV)w^K#+{Oos;ecRt`yLwvd6!I-;{2EE~=cf}LWT1DCJ6brj)$P$DKF=+#c%Mq; zu#~SL9%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title%% +
+ %%gui.settings.linux_launch_method.desc%% +
+
+
+ +
+
+
+
+ %%gui.settings.linux_launch_cmd_ns.title%% +
+ %%gui.settings.linux_launch_cmd_ns.desc%% +
+
+
+ +
+
+
+
+ %%gui.settings.linux_launch_cmd_vanilla.title%% +
+ %%gui.settings.linux_launch_cmd_vanilla.desc%% +
+
+
+ +
+
+
diff --git a/src/app/main.js b/src/app/main.js index c3f89d29..f4c16241 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -15,6 +15,9 @@ var modsobj = { let shouldInstallNorthstar = false; // Base settings +// +// TODO: dont duplicate this, instead just use the one in +// `src/modules/settings.js` automatically var settings = { nsargs: "", gamepath: "", @@ -25,6 +28,11 @@ var settings = { originkill: false, zip: "/northstar.zip", lang: navigator.language, + + linux_launch_cmd_ns: "", + linux_launch_cmd_vanilla: "", + linux_launch_method: "steam_auto", + excludes: [ "ns_startup_args.txt", "ns_startup_args_dedi.txt" diff --git a/src/modules/settings.js b/src/modules/settings.js index d513ec98..60d6be0f 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: [ From 97be082dbbe66684f3e8a558e309329cad024e27 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 29 Apr 2024 18:59:28 +0200 Subject: [PATCH 03/11] actual Linux launch support The "Steam (Auto)" launch method should ideally work in all scenarios, ideally! Obviously, I can't and haven't tested in every environment, but I've attempted to make sure it functions. Launching Vanilla and Northstar works just fine, custom launch arguments also work just fine, it works with normal Steam, Flatpak Steam, and as a fallback with the Steam Browser Protocol (`steam://`) There's also the option to set your own/custom launch command for both the Vanilla and Northstar launch options. How well they work will of course depend on what the user set them to. "Steam (Auto)" attempts to pick the right Steam launch method depending on what's available, if the Steam executable can be found, it'll use "Steam (Executable)", if it cant and Flatpak is found on top of an install of Steam through Flatpak, then "Steam (Flatpak)" is used, if all of that fails, then we attempt to use "Steam (Protocol)" Some toasts will be shown if you attempt to run the game with either "Steam (Executable)" or "Steam (Flatpak)" and they cant find the game/Steam. This isn't an issue with "Steam (Auto)" --- src/app/js/toast.js | 4 + src/lang/en.json | 35 +++++++- src/modules/in_path.js | 24 +++++ src/modules/launch.js | 197 ++++++++++++++++++++++++++++++++++++----- src/win.js | 19 ++-- 5 files changed, 248 insertions(+), 31 deletions(-) create mode 100644 src/modules/in_path.js diff --git a/src/app/js/toast.js b/src/app/js/toast.js index e0aba6be..501bf423 100644 --- a/src/app/js/toast.js +++ b/src/app/js/toast.js @@ -69,3 +69,7 @@ function dismissToast(id) { }, 500) } } + +ipcRenderer.on("toast", (_, properties) => { + Toast(properties); +}) diff --git a/src/lang/en.json b/src/lang/en.json index eca640d2..c7055176 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/modules/in_path.js b/src/modules/in_path.js new file mode 100644 index 00000000..49288c11 --- /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 73ce4080..544e155b 100644 --- a/src/modules/launch.js +++ b/src/modules/launch.js @@ -1,15 +1,16 @@ -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"); -ipcMain.on("launch-ns", launch); +ipcMain.on("launch-ns", () => {launch()}); ipcMain.on("launch-vanilla", () => { launch("vanilla"); }) @@ -18,37 +19,187 @@ ipcMain.on("launch-vanilla", () => { // // 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/win.js b/src/win.js index 9bec3c9c..91ef93ab 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; From fdcb812d5be35dcda98101137802a7ca7bd6d26f Mon Sep 17 00:00:00 2001 From: KenMizz Date: Mon, 29 Apr 2024 18:34:02 -0400 Subject: [PATCH 04/11] update zh translation for linux-launch-v2 --- src/lang/zh.json | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/lang/zh.json b/src/lang/zh.json index ccd3ce7f..96534e2b 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": "未知错误!" } From 1b3a598f1da37ab7db910f4ec9c8a980c3b2ae81 Mon Sep 17 00:00:00 2001 From: KenMizz Date: Mon, 29 Apr 2024 18:37:00 -0400 Subject: [PATCH 05/11] fix error --- src/lang/zh.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lang/zh.json b/src/lang/zh.json index 96534e2b..f681abab 100644 --- a/src/lang/zh.json +++ b/src/lang/zh.json @@ -223,7 +223,7 @@ "missing_flatpak": "无法以Flatpak的方式启动,看起来它并没有被安装", "missing_flatpak_steam": "无法以Steam(Flatpak)的方式启动,看起来它并没有被安装", "missing_launch_command": "当前缺少运行游戏的自定义命令,需指定来启动游戏", - "missing_steam": "无法以Steam的方式启动游戏,看起来它并没有被安装", + "missing_steam": "无法以Steam的方式启动,看起来它并没有被安装", "no_internet": "Viper可能不会正常工作.", "unknown_error": "一个未知错误产生了, 点击来查看更多细节. 您可能会想要对错误信息进行截图用于bug反馈" }, From 2d3b231d7e52266023061d786b37c84e80a57228 Mon Sep 17 00:00:00 2001 From: KenMizz Date: Mon, 29 Apr 2024 18:44:25 -0400 Subject: [PATCH 06/11] fix error again --- src/lang/zh.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lang/zh.json b/src/lang/zh.json index f681abab..ebe5bd8e 100644 --- a/src/lang/zh.json +++ b/src/lang/zh.json @@ -163,7 +163,7 @@ "methods": { "command": "自定义命令", "steam_auto": "Steam(自动)", - "steam_executable": "Steam(快捷方式)", + "steam_executable": "Steam(程序)", "steam_flatpak": "Steam (Flatpak)", "steam_protocol": "Steam (Protocol)" }, @@ -221,7 +221,7 @@ "installed": "已成功安装!", "malformed": "拥有错误的文件夹结构, 如果您是它的开发者, 您应该修复这个问题.", "missing_flatpak": "无法以Flatpak的方式启动,看起来它并没有被安装", - "missing_flatpak_steam": "无法以Steam(Flatpak)的方式启动,看起来它并没有被安装", + "missing_flatpak_steam": "无法以Steam (Flatpak) 的方式启动,看起来它并没有被安装", "missing_launch_command": "当前缺少运行游戏的自定义命令,需指定来启动游戏", "missing_steam": "无法以Steam的方式启动,看起来它并没有被安装", "no_internet": "Viper可能不会正常工作.", From ce1050134edb8498675e0cb7287d41c92fb9a252 Mon Sep 17 00:00:00 2001 From: KenMizz Date: Mon, 29 Apr 2024 18:58:00 -0400 Subject: [PATCH 07/11] =?UTF-8?q?i18n:=20'=E5=8F=82=E6=95=B0'=20instead=20?= =?UTF-8?q?of=20'=E5=91=BD=E4=BB=A4'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lang/zh.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lang/zh.json b/src/lang/zh.json index ebe5bd8e..ae086d4d 100644 --- a/src/lang/zh.json +++ b/src/lang/zh.json @@ -151,12 +151,12 @@ "title": "语言" }, "linux_launch_cmd_ns": { - "desc": "当您以 \"自定义命令\" 选项启动Northstar客户端时,此项将会以$TF_ARGS的形式包含在启动命令的尾部作为Northstar的启动选项", - "title": "Northstar启动命令" + "desc": "当您以 \"自定义命令\" 选项启动Northstar客户端时,此项将会以$TF_ARGS的形式包含在启动命令的尾部作为Northstar的启动参数", + "title": "Northstar启动参数" }, "linux_launch_cmd_vanilla": { - "desc": "当您以 \"自定义命令\" 选项启动原版客户端时,此项将会以$TF_ARGS的形式包含在启动命令的尾部作为原版的启动选项", - "title": "原版启动命令" + "desc": "当您以 \"自定义命令\" 选项启动原版客户端时,此项将会以$TF_ARGS的形式包含在启动命令的尾部作为原版的启动参数", + "title": "原版启动参数" }, "linux_launch_method": { "desc": "在Linux系统中启动游戏的方式", From 896df9b680146933c457b8df2ea60ee3b2bf617d Mon Sep 17 00:00:00 2001 From: Presti Date: Tue, 30 Apr 2024 13:02:24 +0200 Subject: [PATCH 08/11] German Translation --- src/lang/de.json | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/lang/de.json b/src/lang/de.json index c7dfb0ee..9e689861 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!" } From 14f6d2b78ff07a6bf4da33457aadbef51a2273dc Mon Sep 17 00:00:00 2001 From: XNovaDelta Date: Thu, 2 May 2024 00:12:11 -0500 Subject: [PATCH 09/11] Update es.json --- src/lang/es.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lang/es.json b/src/lang/es.json index 4a8d238f..eebd9c16 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 metodo 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 metodo 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!" } From fef12cf4a235e731ff39ec9026ee94f25deda932 Mon Sep 17 00:00:00 2001 From: XNovaDelta <31860825+XNovaDelta@users.noreply.github.com> Date: Thu, 2 May 2024 00:25:52 -0500 Subject: [PATCH 10/11] Update es.json Spelling corrections --- src/lang/es.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lang/es.json b/src/lang/es.json index eebd9c16..3da6d899 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -151,11 +151,11 @@ "title": "Idioma" }, "linux_launch_cmd_ns": { - "desc": "Este es el comando que será usado cuando seleccione \"Comando personalizado\" como el metodo 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", + "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 metodo 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", + "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": { @@ -286,4 +286,4 @@ "release": "Notas de la versión" } } -} \ No newline at end of file +} From 2867f48198f5e640eb6e9b03fc30227a61100ef7 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 2 May 2024 14:24:35 +0200 Subject: [PATCH 11/11] feat: add french translation --- src/lang/fr.json | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/lang/fr.json b/src/lang/fr.json index 675fa33f..52d97038 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" }