[feature] we can now create custom launch options (#861)

This commit is contained in:
MathieuG-P
2025-04-24 15:43:42 +02:00
committed by GitHub
parent cc4061fd38
commit 266feae483
17 changed files with 330 additions and 47 deletions
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Geteilt",
"pin": "Anheften",
"unpin": "Lösen",
"this-guide": "dieser Leitfaden"
"this-guide": "dieser Leitfaden",
"create": "Erstellen",
"edit": "Bearbeiten"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "Diese Version ist veraltet, und einige Mods oder Funktionen funktionieren möglicherweise nicht wie erwartet. Es wird empfohlen, die empfohlene Version ({recommendedVersion}) von Beat Saber zu verwenden, um die neuesten Funktionen und Fehlerbehebungen zu genießen.",
"advanced-launch": {
"button": "Startoptionen",
"placeholder": "Startoptionen, bspw: KEY=VALUE %command% fpfc"
"placeholder": "Startoptionen, bspw: KEY=VALUE %command% fpfc",
"create-launch-option": "Eine Startoption erstellen"
},
"skipsteam": "Steam überspringen",
"skipsteam-description": "Verhindert, dass Steam automatisch mit Beat Saber geöffnet wird. Aktivieren Sie dies, wenn Sie eine andere VR-Laufzeit wie WiVRn oder Monado verwenden, mit der SteamVR interferieren könnte.",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "Die Version {outdatedVersion} ist veraltet, und einige Mods oder Funktionen funktionieren möglicherweise nicht mehr wie erwartet. Bitte lade die neueste empfohlene Version ({recommendedVersion}) von Beat Saber herunter, um die neuesten Funktionen und Fehlerbehebungen zu nutzen."
},
"custom-launch-option": {
"title": "Benutzerdefinierte Startoption",
"title-placeholder": "Meine Option",
"desc": "Erstellen Sie eine wiederverwendbare Startoption, um Beat Saber mit einem bestimmten Befehl zu starten.",
"name": "Name",
"launch-option": "Startoption",
"create": "Erstellen"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Shared",
"pin": "Pin",
"unpin": "Unpin",
"this-guide": "this guide"
"this-guide": "this guide",
"create": "Create",
"edit": "Edit"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "This version is outdated, and some mods or features may no longer work as expected. Prefer using the recommended version ({recommendedVersion}) of Beat Saber to enjoy the latest features and bugfixes.",
"advanced-launch": {
"button": "Launch options",
"placeholder": "Launch options ex: KEY=VALUE %command% fpfc"
"placeholder": "Launch options ex: KEY=VALUE %command% fpfc",
"create-launch-option": "Create a launch option"
},
"skipsteam": "Skip Steam",
"skipsteam-description": "Stops Steam from opening automatically with Beat Saber, enable if you are using a different VR runtime like WiVRn or Monado that SteamVR may interfere with.",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "The version {outdatedVersion} is outdated, and some mods or features may no longer work as expected. Please download the latest recommended version ({recommendedVersion}) of Beat Saber to enjoy the latest features and bugfixes."
},
"custom-launch-option": {
"title": "Custom launch option",
"title-placeholder": "My option",
"desc": "Create a re-usable launch option to launch Beat Saber with a specific command.",
"name": "Name",
"launch-option": "Launch option",
"create": "Create"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Compartido",
"pin": "Fijar",
"unpin": "Desfijar",
"this-guide": "esta guía"
"this-guide": "esta guía",
"create": "Crear",
"edit": "Editar"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "Esta versión está desactualizada, y algunos mods o funciones pueden no funcionar como se espera. Es mejor usar la versión recomendada ({recommendedVersion}) de Beat Saber para disfrutar de las últimas características y correcciones.",
"advanced-launch": {
"button": "Opciones de lanzamiento",
"placeholder": "Opciones de lanzamiento ej: KEY=VALUE %command% fpfc"
"placeholder": "Opciones de lanzamiento ej: KEY=VALUE %command% fpfc",
"create-launch-option": "Crear una opción de lanzamiento"
},
"skipsteam": "Saltar Steam",
"skipsteam-description": "Evita que Steam se abra automáticamente con Beat Saber, habilita esto si estás usando un runtime de VR diferente como WiVRn o Monado que SteamVR podría interferir.",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "La versión {outdatedVersion} está obsoleta, y algunos mods o funciones pueden no funcionar como se espera. Por favor, descarga la última versión recomendada ({recommendedVersion}) de Beat Saber para disfrutar de las últimas funciones y correcciones de errores."
},
"custom-launch-option": {
"title": "Opción de lanzamiento personalizada",
"title-placeholder": "Mi opción",
"desc": "Crea una opción de lanzamiento reutilizable para lanzar Beat Saber con un comando específico.",
"name": "Nombre",
"launch-option": "Opción de lanzamiento",
"create": "Crear"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Partagé",
"pin": "Épingler",
"unpin": "Désépingler",
"this-guide": "ce guide"
"this-guide": "ce guide",
"create": "Créer",
"edit": "Modifier"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "Cette version est obsolète et certains mods ou fonctionnalités peuvent ne plus fonctionner comme prévu. Préférez utiliser la version recommandée ({recommendedVersion}) de Beat Saber pour profiter des dernières fonctionnalités et correctifs.",
"advanced-launch": {
"button": "Options de lancement",
"placeholder": "Options de lancement ex: KEY=VALUE %command% fpfc"
"placeholder": "Options de lancement ex: KEY=VALUE %command% fpfc",
"create-launch-option": "Créer une option de lancement"
},
"skipsteam": "Ignorer Steam",
"skipsteam-description": "Empêche Steam de s'ouvrir automatiquement avec Beat Saber, activez-le si vous utilisez un autre runtime VR comme WiVRn ou Monado avec lequel SteamVR pourrait interférer.",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "La version {outdatedVersion} est obsolète, et certains mods ou fonctionnalités peuvent ne plus fonctionner comme prévu. Veuillez télécharger la dernière version recommandée ({recommendedVersion}) de Beat Saber pour profiter des dernières fonctionnalités et corrections de bugs."
},
"custom-launch-option": {
"title": "Option de lancement personnalisée",
"title-placeholder": "Mon option",
"desc": "Créer une option de lancement réutilisable pour lancer Beat Saber avec une commande spécifique.",
"name": "Nom",
"launch-option": "Option de lancement",
"create": "Créer"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Condivisi",
"pin": "Fissa",
"unpin": "Rimuovi Fissaggio",
"this-guide": "questa guida"
"this-guide": "questa guida",
"create": "Crea",
"edit": "Modifica"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "Questa versione è obsoleta, e alcune mod o funzioni non potrebbero più funzionare correttamente. Consigliamo di usare la versione raccomandata ({recommendedVersion}) di Beat Saber per godere delle ultime funzioni e bugfix.",
"advanced-launch": {
"button": "Opzioni di Lancio",
"placeholder": "Opzioni di Lancio es: KEY=VALUE %command% fpfc"
"placeholder": "Opzioni di Lancio es: KEY=VALUE %command% fpfc",
"create-launch-option": "Crea un'opzione di lancio"
},
"skipsteam": "Salta Steam",
"skipsteam-description": "Ferma Steam da aprirsi automaticamente con Beat Saber, abilitalo se stai usando un VR runtime differente come WiVRn o Monado con cui SteamVR potrebbe interferire.",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "La versione {outdatedVersion} è obsoleta, e alcune mod o funzioni potrebbero non funzionare più come previsto. Per favore scarica l'ultima versione raccomandata ({recommendedVersion}) di Beat Saber per godere delle ultime funzioni e bugfix."
},
"custom-launch-option": {
"title": "Opzione di lancio personalizzata",
"title-placeholder": "La mia opzione",
"desc": "Crea un'opzione di lancio rilocabile per lanciare Beat Saber con un comando specifico.",
"name": "Nome",
"launch-option": "Opzione di lancio",
"create": "Crea"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "共有",
"pin": "固定",
"unpin": "固定解除",
"this-guide": "このガイド"
"this-guide": "このガイド",
"create": "作成",
"edit": "編集"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "このバージョンは古いため、一部のMODや機能が期待通りに動作しない可能性があります。最新の機能やバグ修正を楽しむには、推奨バージョン ({recommendedVersion}) のBeat Saberを使用することをお勧めします。",
"advanced-launch": {
"button": "起動オプション",
"placeholder": "起動オプション 例:KEY=VALUE %command% fpfc"
"placeholder": "起動オプション 例:KEY=VALUE %command% fpfc",
"create-launch-option": "起動オプションを作成"
},
"skipsteam": "Steamをスキップ",
"skipsteam-description": "Beat Saberと一緒にSteamが自動的に開くのを防ぎます。SteamVRが干渉する可能性のあるWiVRnやMonadoなど、別のVRランタイムを使用している場合は有効にしてください。",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "バージョン {outdatedVersion} は古いため、一部のモッドや機能が期待通りに動作しない場合があります。最新の機能やバグ修正を楽しむために、推奨される最新バージョンの Beat Saber ({recommendedVersion}) をダウンロードしてください。"
},
"custom-launch-option": {
"title": "カスタム起動オプション",
"title-placeholder": "私のオプション",
"desc": "特定のコマンドでBeat Saberを起動するための再利用可能な起動オプションを作成します。",
"name": "名前",
"launch-option": "起動オプション",
"create": "作成"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "공유",
"pin": "고정",
"unpin": "고정 해제",
"this-guide": "이 가이드"
"this-guide": "이 가이드",
"create": "만들기",
"edit": "수정"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "이 버전은 오래되어 일부 모드나 기능이 예상대로 작동하지 않을 수 있습니다. 최신 기능과 버그 수정을 사용하려면 권장 버전({recommendedVersion})의 Beat Saber를 사용하는 것이 좋습니다.",
"advanced-launch": {
"button": "실행 옵션",
"placeholder": "실행 옵션 예: KEY=VALUE %command% fpfc"
"placeholder": "실행 옵션 예: KEY=VALUE %command% fpfc",
"create-launch-option": "실행 옵션 만들기"
},
"skipsteam": "Steam 실행 건너뛰기",
"skipsteam-description": "Beat Saber와 함께 Steam이 자동으로 열리는 것을 방지합니다. SteamVR이 간섭할 수 있는 WiVRn 또는 Monado와 같은 다른 VR 런타임을 사용하는 경우 활성화하세요.",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "버전 {outdatedVersion}은(는) 오래되어 일부 모드나 기능이 예상대로 작동하지 않을 수 있습니다. 최신 기능과 버그 수정 사항을 즐기기 위해 Beat Saber의 최신 권장 버전 ({recommendedVersion})을 다운로드하십시오."
},
"custom-launch-option": {
"title": "사용자 정의 실행 옵션",
"title-placeholder": "내 옵션",
"desc": "특정 명령으로 Beat Saber를 실행하기 위한 재사용 가능한 실행 옵션을 만듭니다.",
"name": "이름",
"launch-option": "실행 옵션",
"create": "만들기"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Compartilhados",
"pin": "Fixar",
"unpin": "Desafixar",
"this-guide": "este guia"
"this-guide": "este guia",
"create": "Criar",
"edit": "Editar"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "Essa versão está desatualizada, e alguns mods ou funções podem não funcionar mais como esperado. Prefira utilizar a versão recomendada ({recommendedVersion}) de Beat Saber para aproveitar todas as últimas novidades e correções de erros.",
"advanced-launch": {
"button": "Opções de Inicialização",
"placeholder": "Opções de lançamento, ex: KEY=VALUE %command% fpfc"
"placeholder": "Opções de lançamento, ex: KEY=VALUE %command% fpfc",
"create-launch-option": "Criar uma opção de lançamento"
},
"skipsteam": "Pular Steam",
"skipsteam-description": "Faz com que a Steam pare de abrir automaticamente com Beat Saber, ative se você está utilizando algum outro executável de VR como WiVRn ou Monado, que pode interferir com o SteamVR.",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "Essa versão {outdatedVersion} está desatualizada, e alguns mods ou funções podem não funcionar como esperado. Por favor baixe a versão mais recente ({recommendedVersion}) de Beat Saber para aproveitar as últimas novidades e correções."
},
"custom-launch-option": {
"title": "Opção de lançamento personalizada",
"title-placeholder": "Minha opção",
"desc": "Crie uma opção de lançamento reutilizável para lançar Beat Saber com um comando específico.",
"name": "Nome",
"launch-option": "Opção de lançamento",
"create": "Criar"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Общий",
"pin": "Закрепить",
"unpin": "Открепить",
"this-guide": "это руководство"
"this-guide": "это руководство",
"create": "Создать",
"edit": "Редактировать"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "Эта версия устарела, и некоторые моды или функции могут работать не так, как ожидалось. Рекомендуется использовать рекомендуемую версию ({recommendedVersion}) Beat Saber, чтобы воспользоваться последними функциями и исправлениями ошибок.",
"advanced-launch": {
"button": "Параметры запуска",
"placeholder": "Параметры запуска, например: KEY=VALUE %command% fpfc"
"placeholder": "Параметры запуска, например: KEY=VALUE %command% fpfc",
"create-launch-option": "Создать параметр запуска"
},
"skipsteam": "Пропустить Steam",
"skipsteam-description": "Предотвращает автоматическое открытие Steam с Beat Saber, включите, если вы используете другую VR-среду, такую как WiVRn или Monado, с которой SteamVR может мешать.",
@@ -970,6 +973,14 @@
},
"bs-version-outdated": {
"body": "Версия {outdatedVersion} устарела, и некоторые моды или функции могут работать некорректно. Пожалуйста, скачайте последнюю рекомендуемую версию ({recommendedVersion}) Beat Saber, чтобы воспользоваться новейшими функциями и исправлениями ошибок."
},
"custom-launch-option": {
"title": "Опция запуска",
"title-placeholder": "Моя опция",
"desc": "Создайте повторно используемую опцию запуска для запуска Beat Saber с конкретной командой.",
"name": "Имя",
"launch-option": "Опция запуска",
"create": "Создать"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Ibinahagi",
"pin": "I-pin",
"unpin": "I-unpin",
"this-guide": "ang gabay na ito"
"this-guide": "ang gabay na ito",
"create": "Lumikha",
"edit": "I-edit"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "Ang bersyon na ito ay lipas na, at maaaring hindi na gumana ang ilang mods o features tulad ng inaasahan. Mas mainam na gumamit ng inirerekomendang bersyon ({recommendedVersion}) ng Beat Saber upang magamit ang mga pinakabagong features at pag-aayos ng bug.",
"advanced-launch": {
"button": "Launch options",
"placeholder": "Launch options hal: KEY=VALUE %command% fpfc"
"placeholder": "Launch options hal: KEY=VALUE %command% fpfc",
"create-launch-option": "Lumikha ng launch option"
},
"skipsteam": "I-skip ang Steam",
"skipsteam-description": "Pinipigilan mo ang Steam na awtomatikong magbukas kasama ng Beat Saber, i-enable ito kung gumagamit ka ng ibang VR runtime tulad ng WiVRn o Monado na maaaring magdulot ng problema sa SteamVR.",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "Ang bersyon na {outdatedVersion} ay lipas na, at ang ilang mods o features ay maaaring hindi na gumana ng tama. Mangyaring i-download ang pinakabagong inirerekomendang bersyon ({recommendedVersion}) ng Beat Saber upang tamasahin ang mga pinakabagong tampok at mga pag-aayos ng bug."
},
"custom-launch-option": {
"title": "Custom na opsyon sa paglulunsad",
"title-placeholder": "Aking opsyon",
"desc": "Gumawa ng muling magagamit na opsyon sa paglulunsad upang ilunsad ang Beat Saber gamit ang isang partikular na command.",
"name": "Pangalan",
"launch-option": "Opsyon sa paglulunsad",
"create": "Lumikha"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "Спільне",
"pin": "Закріпити",
"unpin": "Відкріпити",
"this-guide": "цей посібник"
"this-guide": "цей посібник",
"create": "Створити",
"edit": "Редагувати"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "Ця версія застаріла і деякі моди і/або функції можуть працювати некоректно. Рекомендуємо використовувати версію ({recommendedVersion}), щоб скористатися останніми функціями і виправленнями.",
"advanced-launch": {
"button": "Параметри запуску",
"placeholder": "Параметри запуску, наприклад: KEY=VALUE %command% fpfc"
"placeholder": "Параметри запуску, наприклад: KEY=VALUE %command% fpfc",
"create-launch-option": "Створити параметр запуску"
},
"skipsteam": "Пропустити Steam",
"skipsteam-description": "Запобігає автоматичному відкриттю Steam. Увімкніть це, якщо ви використовуєте інше серидовище VR (WiVRn/Monado), з яким Steam праює некоректно.",
@@ -966,6 +969,14 @@
},
"bs-version-outdated": {
"body": "Версія {outdatedVersion} застаріла, і деякі моди чи функції можуть більше не працювати належним чином. Будь ласка, завантажте останню рекомендовану версію ({recommendedVersion}) Beat Saber, щоб насолоджуватися останніми функціями та виправленнями помилок."
},
"custom-launch-option": {
"title": "Опція запуску",
"title-placeholder": "Моя опція",
"desc": "Створіть повторно використовувану опцію запуску для запуску Beat Saber з конкретною командою.",
"name": "Ім'я",
"launch-option": "Опція запуску",
"create": "Створити"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "共享",
"pin": "固定",
"unpin": "取消固定",
"this-guide": "本指南"
"this-guide": "本指南",
"create": "新增",
"edit": "編輯"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "此版本已過時,某些模組或功能可能無法按預期運作。建議使用推薦版本的 Beat Saber ({recommendedVersion}),以享受最新功能和修復。",
"advanced-launch": {
"button": "啟動選項",
"placeholder": "啟動選項,例如: KEY=VALUE %command% fpfc"
"placeholder": "啟動選項,例如: KEY=VALUE %command% fpfc",
"create-launch-option": "新增啟動選項"
},
"skipsteam": "跳過 Steam",
"skipsteam-description": "防止 Steam 與 Beat Saber 自動打開,如果您使用的是其他 VR 執行時,如 WiVRn 或 Monado,SteamVR 可能會干擾,請啟用此選項。",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "版本 {outdatedVersion} 已過時,某些模組或功能可能無法正常運作。請下載最新推薦的 Beat Saber 版本 ({recommendedVersion}),以享受最新功能和修正。"
},
"custom-launch-option": {
"title": "自訂啟動選項",
"title-placeholder": "我的選項",
"desc": "建立一個可重用的啟動選項,以特定命令啟動 Beat Saber。",
"name": "名稱",
"launch-option": "啟動選項",
"create": "建立"
}
},
"maps": {
+13 -2
View File
@@ -27,7 +27,9 @@
"shared": "共享",
"pin": "固定",
"unpin": "取消固定",
"this-guide": "本指南"
"this-guide": "本指南",
"create": "创建",
"edit": "编辑"
},
"generic": {
"env": {
@@ -57,7 +59,8 @@
"outdated-tippy": "此版本已过时,某些模组或功能可能无法按预期运行。建议使用推荐版本的 Beat Saber ({recommendedVersion}),以享受最新功能和修复。",
"advanced-launch": {
"button": "启动选项",
"placeholder": "启动选项,例如: KEY=VALUE %command% fpfc"
"placeholder": "启动选项,例如: KEY=VALUE %command% fpfc",
"create-launch-option": "创建启动选项"
},
"skipsteam": "跳过 Steam",
"skipsteam-description": "防止 Steam 与 Beat Saber 自动打开,如果您使用的是其他 VR 运行时,如 WiVRn 或 Monado,SteamVR 可能会干扰,请启用此选项。",
@@ -971,6 +974,14 @@
},
"bs-version-outdated": {
"body": "版本 {outdatedVersion} 已过时,某些模组或功能可能无法正常工作。请下载最新推荐的 Beat Saber 版本 ({recommendedVersion}),以享受最新功能和修复。"
},
"custom-launch-option": {
"title": "自定义启动选项",
"title-placeholder": "我的选项",
"desc": "创建一个可重用的启动选项,以特定命令启动 Beat Saber。",
"name": "名称",
"launch-option": "启动选项",
"create": "创建"
}
},
"maps": {
@@ -0,0 +1,60 @@
import { BsmImage } from "renderer/components/shared/bsm-image.component";
import { useTranslationV2 } from "renderer/hooks/use-translation.hook";
import BeatRunning from "../../../../../assets/images/apngs/beat-running.png";
import { BsmButton } from "renderer/components/shared/bsm-button.component";
import { ModalComponent, ModalExitCode } from "renderer/services/modale.service";
import { CustomLaunchOption } from "renderer/components/version-viewer/slides/launch/launch-options-panel.component";
import { FormEvent, useState } from "react";
import { useConstant } from "renderer/hooks/use-constant.hook";
type Data = Partial<CustomLaunchOption>;
export const CreateCustomLaunchOptionModal: ModalComponent<CustomLaunchOption, Data> = ({resolver, options}) => {
const { text: t } = useTranslationV2();
const uid = useConstant(() => options?.data?.id ?? crypto.randomUUID());
const [name, setName] = useState(options?.data?.label ?? "");
const [command, setCommand] = useState(options?.data?.data?.command ?? "");
const onSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
resolver({
exitCode: ModalExitCode.COMPLETED,
data: {
id: uid,
label: name,
data: {
command,
}
}
});
}
const cancel = () => {
resolver({
exitCode: ModalExitCode.CANCELED,
data: null,
});
}
return (
<form onSubmit={onSubmit} className="max-w-xs">
<h1 className="text-3xl uppercase tracking-wide w-full text-center">{t("modals.custom-launch-option.title")}</h1>
<BsmImage className="mx-auto h-24" image={BeatRunning} />
<p className="mb-2">{t("modals.custom-launch-option.desc")}</p>
<div className="flex flex-col gap-px mb-3">
<label className="font-bold cursor-pointer tracking-wide inline-block w-fit" htmlFor="name">{t("modals.custom-launch-option.name")}</label>
<input className="h-8 px-1.5 bg-light-main-color-1 dark:bg-main-color-1 rounded-md" type="text" id="name" required value={name} onChange={e => setName(e.target.value)} placeholder={t("modals.custom-launch-option.title-placeholder")} />
</div>
<div className="flex flex-col gap-px mb-3">
<label className="font-bold cursor-pointer tracking-wide inline-block w-fit" htmlFor="launch-option">{t("modals.custom-launch-option.launch-option")}</label>
<input className="h-8 px-1.5 bg-light-main-color-1 dark:bg-main-color-1 rounded-md" type="text" id="launch-option" required value={command} onChange={e => setCommand(e.target.value)} placeholder="--launch-option" />
</div>
<div className="flex gap-3">
<BsmButton className="rounded-md flex justify-center items-center transition-all h-10 grow shrink-0" text={t("misc.cancel")} typeColor="cancel" withBar={false} onClick={cancel}/>
<BsmButton className="rounded-md flex justify-center items-center transition-all h-10 grow shrink-0" type="submit" text={t("misc.create")} typeColor="primary" withBar={false} />
</div>
</form>
)
};
@@ -4,8 +4,11 @@ import { PinIcon } from "renderer/components/svgs/icons/pin-icon.component";
import { UnpinIcon } from "renderer/components/svgs/icons/unpin-icon.component";
import { SvgIcon } from "renderer/components/svgs/svg-icon.type";
import { cn } from "renderer/helpers/css-class.helpers";
import { useThemeColor } from "renderer/hooks/use-theme-color.hook";
import { useTranslationV2 } from "renderer/hooks/use-translation.hook";
import { LaunchMod } from "shared/models/bs-launch/launch-option.interface";
import { AddIcon } from "renderer/components/svgs/icons/add-icon.component";
import { EditIcon } from "renderer/components/svgs/icons/edit-icon.component";
import { TrashIcon } from "renderer/components/svgs/icons/trash-icon.component";
type Props = {
readonly className?: string;
@@ -13,17 +16,26 @@ type Props = {
readonly launchArgs?: string;
readonly launchMods?: LaunchModItemProps[];
readonly onLaunchArgsChange?: (args: string) => void;
readonly onAddLaunchMod?: (command?: string) => void;
};
export function LaunchOptionsPanel({ className, open, launchArgs, launchMods, onLaunchArgsChange }: Props) {
export function LaunchOptionsPanel({ className, open, launchArgs, launchMods, onLaunchArgsChange, onAddLaunchMod }: Props) {
const {text: t} = useTranslationV2();
const color = useThemeColor("first-color");
const { text: t } = useTranslationV2();
return (
<div className={cn("grid grid-rows-[0fr] transition-[grid-template-rows] bg-theme-2 rounded-md shadow-md shadow-black overflow-hidden", open && "!grid-rows-[1fr]", className)}>
<div className="flex flex-col overflow-y-scroll scrollbar-default">
<div className="p-3.5">
<input className="h-10 w-full rounded-md bg-theme-1 text-center mb-2" type="text" placeholder={t("pages.version-viewer.launch-mods.advanced-launch.placeholder")} value={launchArgs} onChange={e => onLaunchArgsChange(e.target.value)}/>
<div className="w-full relative flex justify-center items-center mb-2">
<input className="h-10 w-full rounded-md bg-theme-1 text-center" type="text" placeholder={t("pages.version-viewer.launch-mods.advanced-launch.placeholder")} value={launchArgs} onChange={e => onLaunchArgsChange(e.target.value)}/>
<Tippy theme="default" placement="top" content={t("pages.version-viewer.launch-mods.advanced-launch.create-launch-option")}>
<button className="absolute size-8 rounded-md p-0.5 right-1 hover:brightness-110" style={{ backgroundColor: color }} onClick={() => onAddLaunchMod?.(launchArgs)}>
<AddIcon className="size-full"/>
</button>
</Tippy>
</div>
<div className={cn("flex gap-2 flex-wrap")}>
{launchMods?.map((mod) => (
<LaunchModItem key={mod.id} {...mod}/>
@@ -35,25 +47,35 @@ export function LaunchOptionsPanel({ className, open, launchArgs, launchMods, on
)
}
export type CustomLaunchOption = {
readonly id: string;
readonly label: string;
readonly data: {
readonly command?: string;
}
}
export type LaunchModItemProps = {
readonly id: LaunchMod;
readonly id: string;
readonly icon?: SvgIcon;
readonly label: string;
readonly description: string;
readonly description?: string;
readonly active: boolean;
readonly visible?: boolean;
readonly pinned?: boolean;
readonly onChange?: (val: boolean) => void;
readonly onPinChange?: (val: boolean) => void;
readonly onEdit?: () => void;
readonly onDelete?: () => void;
}
export function LaunchModItem({ id, icon: Icon, label, description, active, visible, pinned, onChange, onPinChange }: LaunchModItemProps) {
export function LaunchModItem({ id, icon: Icon, label, description, active, visible, pinned, onChange, onPinChange, onEdit, onDelete }: LaunchModItemProps) {
const { text: t } = useTranslationV2();
return (
<Tippy theme="default" className="break-words" placement="top" content={description}>
<button id={id} className={cn("grow rounded-md bg-theme-1 relative flex justify-center items-center h-10 py-1 px-3", visible === false && "hidden")} onClick={e => { e.preventDefault(); e.stopPropagation(); onChange?.(!active) }}>
<Tippy theme="default" className="break-words" placement="top" content={description ?? null} disabled={!description}>
<div id={id} className={cn("grow rounded-md bg-theme-1 relative flex justify-center items-center h-10 py-1 px-3", visible === false && "hidden")} onClick={e => { e.preventDefault(); e.stopPropagation(); onChange?.(!active) }}>
<BsmCheckbox className="h-4 aspect-square z-[1] relative mr-1.5" checked={active} onChange={onChange}/>
{Icon && <Icon className="h-full w-fit py-0.5 mr-1.5 text-gray-800 dark:text-gray-200"/>}
<span className="font-bold text-gray-800 dark:text-gray-200">{label}</span>
@@ -66,7 +88,21 @@ export function LaunchModItem({ id, icon: Icon, label, description, active, visi
</button>
</Tippy>
)}
</button>
{onEdit && (
<Tippy theme="default" placement="right" content={t("misc.edit")} hideOnClick>
<button className="h-full py-2 px-1" onClick={e => { e.preventDefault(); e.stopPropagation(); onEdit?.() }}>
<EditIcon className="size-full text-gray-800 dark:text-gray-200"/>
</button>
</Tippy>
)}
{onDelete && (
<Tippy theme="default" placement="right" content={t("misc.delete")} hideOnClick>
<button className="h-full py-2 px-1" onClick={e => { e.preventDefault(); e.stopPropagation(); onDelete?.() }}>
<TrashIcon className="size-full text-gray-800 dark:text-gray-200"/>
</button>
</Tippy>
)}
</div>
</Tippy>
);
@@ -18,13 +18,15 @@ import { BSVersionManagerService } from "renderer/services/bs-version-manager.se
import { safeLt } from "shared/helpers/semver.helpers";
import { WarningIcon } from "renderer/components/svgs/icons/warning-icon.component";
import Tippy from "@tippyjs/react";
import { LaunchModItemProps, LaunchOptionsPanel } from "./launch-options-panel.component";
import { LaunchMod, LaunchMods } from "shared/models/bs-launch/launch-option.interface";
import { CustomLaunchOption, LaunchModItemProps, LaunchOptionsPanel } from "./launch-options-panel.component";
import { LaunchMods } from "shared/models/bs-launch/launch-option.interface";
import { OculusIcon } from "renderer/components/svgs/icons/oculus-icon.component";
import { DesktopIcon } from "renderer/components/svgs/icons/desktop-icon.component";
import { TerminalIcon } from "renderer/components/svgs/icons/terminal-icon.component";
import { DefaultConfigKey } from "renderer/config/default-configuration.config";
import { EditIcon } from "renderer/components/svgs/icons/edit-icon.component";
import { ModalExitCode, ModalService } from "renderer/services/modale.service";
import { CreateCustomLaunchOptionModal } from "renderer/components/modal/modal-types/create-custom-launch-option.component";
type Props = { version: BSVersion };
@@ -35,12 +37,15 @@ export function LaunchSlide({ version }: Props) {
const bsLauncherService = useService(BSLauncherService);
const bsDownloader = useService(BsDownloaderService);
const versions = useService(BSVersionManagerService);
const modal = useService(ModalService);
const [advancedLaunch, setAdvancedLaunch] = useState(false);
const [command, setCommand] = useState<string>(configService.get<string>("launch-command") || "");
const customLaunchOptions = useObservable<CustomLaunchOption[]>(() => configService.watch<CustomLaunchOption[]>("custom-launch-options"), []);
const [customLaunchModsArgs, setCustomLaunchModsArgs] = useState<string[]>([]);
const versionDownloading = useObservable(() => bsDownloader.downloadingVersion$);
const [activeLaunchMods, setActiveLaunchMods] = useState<LaunchMod[]>(configService.get("launch-mods") ?? []);
const [pinnedLaunchMods, setPinnedLaunchMods] = useState<LaunchMod[]>(configService.get("pinned-launch-mods" as DefaultConfigKey) ?? []);
const [activeLaunchMods, setActiveLaunchMods] = useState<string[]>(configService.get("launch-mods") ?? []);
const [pinnedLaunchMods, setPinnedLaunchMods] = useState<string[]>(configService.get("pinned-launch-mods" as DefaultConfigKey) ?? []);
const versionRunning = useObservable(() => bsLauncherService.versionRunning$);
@@ -60,11 +65,11 @@ export function LaunchSlide({ version }: Props) {
}
}, [activeLaunchMods]);
const toggleActiveLaunchMod = (checked: boolean, launchMod: LaunchMod) => checked
const toggleActiveLaunchMod = (checked: boolean, launchMod: string) => checked
? setActiveLaunchMods(prev => [...prev, launchMod])
: setActiveLaunchMods(prev => prev.filter(mod => mod !== launchMod));
const togglePinnedLaunchMod = (pinned: boolean, launchMod: LaunchMod) => pinned
const togglePinnedLaunchMod = (pinned: boolean, launchMod: string) => pinned
? setPinnedLaunchMods(prev => [...prev, launchMod])
: setPinnedLaunchMods(prev => prev.filter(mod => mod !== launchMod));
@@ -77,6 +82,29 @@ export function LaunchSlide({ version }: Props) {
: ["BSInstances", version.name, "Logs"];
}
const customOptions = customLaunchOptions?.map<LaunchModItemProps>(option => ({
id: option.id,
label: option.label,
active: activeLaunchMods.includes(option.id),
pinned: pinnedLaunchMods.includes(option.id),
onChange: (checked) => {
toggleActiveLaunchMod(checked, option.id)
setCustomLaunchModsArgs(prev => {
if(checked){
return [...prev, option.data.command];
}
return prev.filter(arg => arg !== option.data.command);
});
},
onPinChange: (pinned) => togglePinnedLaunchMod(pinned, option.id),
onEdit: () => {
saveCustomLaunchOption(option);
},
onDelete: () => {
deleteCustomLaunchOption(option.id);
},
})) ?? [];
return [
{
id: LaunchMods.OCULUS,
@@ -141,14 +169,15 @@ export function LaunchSlide({ version }: Props) {
onChange: (checked) => toggleActiveLaunchMod(checked, LaunchMods.PROTON_LOGS),
onPinChange: (pinned) => togglePinnedLaunchMod(pinned, LaunchMods.PROTON_LOGS),
},
...customOptions,
]
}, [activeLaunchMods, pinnedLaunchMods, version]);
}, [activeLaunchMods, pinnedLaunchMods, customLaunchOptions, version]);
const launch = async () => {
const launch$ = bsLauncherService.launch({
version,
launchMods: activeLaunchMods,
command,
launchMods: activeLaunchMods.map(mod => LaunchMods[mod as keyof typeof LaunchMods]).filter(Boolean),
command: [command, ...customLaunchModsArgs].filter(Boolean).join(" ").trim(),
});
return lastValueFrom(launch$).catch(() => {});
@@ -158,6 +187,19 @@ export function LaunchSlide({ version }: Props) {
return safeLt(version?.BSVersion, versions.getRecommendedVersion()?.BSVersion);
}, [version]);
const saveCustomLaunchOption = async (option: Partial<CustomLaunchOption>) => {
const result = await modal.openModal(CreateCustomLaunchOptionModal, { data: option });
if(result.exitCode !== ModalExitCode.COMPLETED) { return; }
const newCustomLaunchOptions = (customLaunchOptions ?? []).filter(mode => mode.id !== result.data.id);
newCustomLaunchOptions.push(result.data);
configService.set("custom-launch-options", newCustomLaunchOptions);
}
const deleteCustomLaunchOption = (id: string) => {
const newCustomLaunchOptions = (customLaunchOptions ?? []).filter(mode => mode.id !== id);
configService.set("custom-launch-options", newCustomLaunchOptions);
}
return (
<div className="w-full shrink-0 items-center relative flex flex-col justify-start overflow-hidden">
<div className="flex flex-col gap-3 justify-center items-center mb-4">
@@ -204,7 +246,7 @@ export function LaunchSlide({ version }: Props) {
/>
</div>
</div>
<LaunchOptionsPanel open={advancedLaunch} launchMods={launchModItems} launchArgs={command} className="w-full max-w-3xl mt-3" onLaunchArgsChange={setCommand}/>
<LaunchOptionsPanel open={advancedLaunch} launchMods={launchModItems} launchArgs={command} className="w-full max-w-3xl mt-3" onLaunchArgsChange={setCommand} onAddLaunchMod={command => saveCustomLaunchOption({ data: { command } })}/>
<div className='grow flex justify-center items-center p-2'>
<BsmButton
onClick={launch}
@@ -29,7 +29,7 @@ export class ConfigurationService {
public get<Type>(key: string | DefaultConfigKey): Type {
const rawValue = (window.sessionStorage.getItem(key) ?? window.localStorage.getItem(key));
const tryParse = tryit<Type>(() => JSON.parse(rawValue));
const tryParse = tryit(() => JSON.parse(rawValue));
const res = (tryParse.error ? rawValue : tryParse.result) as Type;
@@ -64,4 +64,6 @@ export class ConfigurationService {
this.observers.set(key, new BehaviorSubject(this.get(key)));
return this.observers.get(key).asObservable() as Observable<T>;
}
}