From 2fef88c70ef4063c2edcbae6eb6c0ae87016d345 Mon Sep 17 00:00:00 2001 From: silentrald Date: Fri, 20 Dec 2024 23:24:49 +0800 Subject: [PATCH 1/7] [feat-706] show DepotDownloader missing executable error --- assets/jsons/translations/en.json | 2 + src/main/models/depot-downloader.class.ts | 42 +++++++++++++------ .../bs-steam-downloader.service.ts | 29 ++++++------- .../depot-downloader.model.ts | 5 ++- 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/assets/jsons/translations/en.json b/assets/jsons/translations/en.json index 4715bc5b..32df3c4d 100644 --- a/assets/jsons/translations/en.json +++ b/assets/jsons/translations/en.json @@ -323,6 +323,8 @@ "msg": { "401": "Steam doesn't seem to want to let us download Beat Saber 😢", "404": "Unable to contact Steam servers.", + "ExeNotFoundWindows": "\"DepotDownloader.exe\" is missing. Please check if the executable is quarantined by your anti-virus.", + "ExeNotFoundLinux": "\"DepotDownloader\" binary is missing.", "Password": "Password is invalid.", "InvalidCredentials": "Invalid login credentials, unapproved connection, or too many login attempts.", "NoManifest": "No manifest was found", diff --git a/src/main/models/depot-downloader.class.ts b/src/main/models/depot-downloader.class.ts index dcaa101a..5c15fd18 100644 --- a/src/main/models/depot-downloader.class.ts +++ b/src/main/models/depot-downloader.class.ts @@ -1,30 +1,48 @@ +import path from "path"; +import fs from "fs"; import { ChildProcessWithoutNullStreams, SpawnOptionsWithoutStdio, spawn } from "child_process"; import { Observable, ReplaySubject, Subscriber, filter, map, share } from "rxjs"; import { DepotDownloaderArgsOptions, DepotDownloaderErrorEvent, DepotDownloaderEvent, DepotDownloaderEventType, DepotDownloaderEventTypes, DepotDownloaderInfoEvent, DepotDownloaderWarningEvent } from "../../shared/models/bs-version-download/depot-downloader.model"; +import { UtilsService } from 'main/services/utils.service'; +import { CustomError } from "shared/models/exceptions/custom-error.class"; export class DepotDownloader { + private static readonly EXE_PATH = path.join( + UtilsService.getInstance().getAssetsScriptsPath(), + process.platform === "win32" ? "DepotDownloader.exe" : "DepotDownloader" + ); + private process: ChildProcessWithoutNullStreams; private processOut$: Observable; private subscriber: Subscriber; + public constructor( options: { - command: string, args?: string[], options?: SpawnOptionsWithoutStdio, echoStartData?: unknown - }, + args?: string[], options?: SpawnOptionsWithoutStdio, echoStartData?: unknown + }, logger?: Logger - ){ - this.processOut$ = new Observable(subscriber => { + ) { + if (!fs.existsSync(DepotDownloader.EXE_PATH)) { + throw new CustomError( + "DepotDownloader executable not found", + process.platform === "win32" + ? DepotDownloaderErrorEvent.ExeNotFoundWindows + : DepotDownloaderErrorEvent.ExeNotFoundLinux + ); + } + this.processOut$ = new Observable(subscriber => { this.subscriber = subscriber; - this.process = spawn(options.command, options.args ?? [], options.options); + this.process = spawn(DepotDownloader.EXE_PATH, options.args ?? [], options.options); subscriber.next(`[Info]|[Start]|${JSON.stringify(options.echoStartData) ?? ""}`); - + this.process.stdout.on("data", data => { const stringData: string = data.toString(); - + if(!stringData.includes(DepotDownloaderInfoEvent.Progress) && !stringData.includes(DepotDownloaderInfoEvent.Validated)){ logger?.info("DepotDownloader stdout:", stringData); } @@ -32,7 +50,7 @@ export class DepotDownloader { const lines: string[] = stringData.split("\n"); lines.forEach(line => subscriber.next(line)); }); - + this.process.on("error", error => subscriber.error(error)); this.process.stderr.on("error", error => subscriber.error(error)); this.process.on("exit", () => subscriber.complete()); @@ -74,7 +92,7 @@ export class DepotDownloader { data: splitedLine[2], } - }), + }), filter(Boolean)); } @@ -93,7 +111,7 @@ export class DepotDownloader { const args: string[] = []; for(const [key, value] of Object.entries(depotDownloaderArgs)){ - + if(value === true){ args.push(`-${key}`); } @@ -102,7 +120,7 @@ export class DepotDownloader { args.push(`${value}`); } } - + return args; } @@ -112,4 +130,4 @@ interface Logger { info: (...args: unknown[]) => void, warn: (...args: unknown[]) => void, error: (...args: unknown[]) => void, -} \ No newline at end of file +} diff --git a/src/main/services/bs-version-download/bs-steam-downloader.service.ts b/src/main/services/bs-version-download/bs-steam-downloader.service.ts index fccb1b7b..8484f839 100644 --- a/src/main/services/bs-version-download/bs-steam-downloader.service.ts +++ b/src/main/services/bs-version-download/bs-steam-downloader.service.ts @@ -1,7 +1,6 @@ import { BS_APP_ID, BS_DEPOT } from "../../constants"; import path from "path"; import { BSVersion } from "shared/bs-version.interface"; -import { UtilsService } from "../utils.service"; import log from "electron-log"; import { InstallationLocationService } from "../installation-location.service"; import { BSLocalVersionService } from "../bs-local-version.service"; @@ -17,14 +16,12 @@ import { CustomError } from "shared/models/exceptions/custom-error.class"; export class BsSteamDownloaderService { private static instance: BsSteamDownloaderService; - private readonly utils: UtilsService; private readonly installLocationService: InstallationLocationService; private readonly localVersionService: BSLocalVersionService; private depotDownloader: DepotDownloader; private constructor() { - this.utils = UtilsService.getInstance(); this.installLocationService = InstallationLocationService.getInstance(); this.localVersionService = BSLocalVersionService.getInstance(); @@ -40,10 +37,6 @@ export class BsSteamDownloaderService { return BsSteamDownloaderService.instance; } - private getDepotDownloaderExePath(): string { - return path.join(this.utils.getAssetsScriptsPath(), process.platform === 'linux' ? "DepotDownloader" : "DepotDownloader.exe"); - } - private async buildDepotDownloaderInstance(downloadInfos: DownloadSteamInfo, qr?: boolean): Promise<{depotDownloader: DepotDownloader, depotDownloaderOptions: DepotDownloaderArgsOptions, version: BSVersion}> { const versionPath = await this.localVersionService.getVersionPath(downloadInfos.bsVersion); @@ -68,11 +61,9 @@ export class BsSteamDownloaderService { await ensureDir(this.installLocationService.versionsDirectory()); - const exePath = this.getDepotDownloaderExePath(); const args = DepotDownloader.buildArgs(depotDownloaderOptions); const depotDownloader = new DepotDownloader({ - command: exePath, args, options: { cwd: this.installLocationService.versionsDirectory() }, echoStartData: downloadVersion @@ -104,11 +95,21 @@ export class BsSteamDownloaderService { finalize(() => this.localVersionService.initVersionMetadata(version, { store: BsStore.STEAM })) ).subscribe(sub); - }).catch(err => sub.error({ - type: DepotDownloaderEventType.Error, - subType: DepotDownloaderErrorEvent.Unknown, - data: err - } as DepotDownloaderEvent)); + }).catch(err => { + if (err instanceof CustomError + && Object.values(DepotDownloaderErrorEvent).includes( + err.code as DepotDownloaderErrorEvent + ) + ) { + return sub.error(err); + } + + return sub.error({ + type: DepotDownloaderEventType.Error, + subType: DepotDownloaderErrorEvent.Unknown, + data: err + } as DepotDownloaderEvent) + }); return () => { depotDownloaderBuildPromise.then(({ depotDownloader }) => depotDownloader.stop()); diff --git a/src/shared/models/bs-version-download/depot-downloader.model.ts b/src/shared/models/bs-version-download/depot-downloader.model.ts index ae701b79..0e46a80e 100644 --- a/src/shared/models/bs-version-download/depot-downloader.model.ts +++ b/src/shared/models/bs-version-download/depot-downloader.model.ts @@ -2,7 +2,6 @@ export enum DepotDownloaderEventType { Error = "Error", Warning = "Warning", Info = "Info", - } export interface DepotDownloaderEvent { @@ -27,6 +26,8 @@ export enum DepotDownloaderInfoEvent { } export enum DepotDownloaderErrorEvent { + ExeNotFoundWindows = "ExeNotFoundWindows", + ExeNotFoundLinux = "ExeNotFoundLinux", Password = "Password", InvalidCredentials = "InvalidCredentials", NoManifest = "NoManifest", @@ -66,4 +67,4 @@ export interface DepotDownloaderArgsOptions { dir: string, validate?: boolean, qr?: boolean, -} \ No newline at end of file +} From d74ba720f1a5e72ff034657aa147d5f381277ef0 Mon Sep 17 00:00:00 2001 From: silentrald Date: Sat, 21 Dec 2024 21:33:09 +0800 Subject: [PATCH 2/7] [translation-706] added translation --- assets/jsons/translations/de.json | 2 ++ assets/jsons/translations/en.json | 2 +- assets/jsons/translations/es.json | 2 ++ assets/jsons/translations/fr.json | 2 ++ assets/jsons/translations/ja.json | 2 ++ assets/jsons/translations/ko.json | 2 ++ assets/jsons/translations/ru.json | 2 ++ assets/jsons/translations/zh-tw.json | 2 ++ assets/jsons/translations/zh.json | 2 ++ 9 files changed, 17 insertions(+), 1 deletion(-) diff --git a/assets/jsons/translations/de.json b/assets/jsons/translations/de.json index a6c92687..51a1e2b0 100644 --- a/assets/jsons/translations/de.json +++ b/assets/jsons/translations/de.json @@ -323,6 +323,8 @@ "msg": { "401": "Steam scheint uns Beat Saber nicht herunterladen zu lassen 😢", "404": "Steam-Server können nicht kontaktiert werden.", + "ExeNotFoundWindows": "\"DepotDownloader.exe\" fehlt. Bitte überprüfen Sie, ob die ausführbare Datei von Ihrer Antivirensoftware quarantäneiert wurde.", + "ExeNotFoundLinux": "Die ausführbare Datei \"DepotDownloader\" fehlt.", "Password": "Passwort ist ungültig.", "InvalidCredentials": "Ungültige Anmeldedaten, nicht genehmigte Verbindung oder zu viele Anmeldeversuche.", "NoManifest": "Es wurde kein Manifest gefunden.", diff --git a/assets/jsons/translations/en.json b/assets/jsons/translations/en.json index 32df3c4d..e379b9d2 100644 --- a/assets/jsons/translations/en.json +++ b/assets/jsons/translations/en.json @@ -324,7 +324,7 @@ "401": "Steam doesn't seem to want to let us download Beat Saber 😢", "404": "Unable to contact Steam servers.", "ExeNotFoundWindows": "\"DepotDownloader.exe\" is missing. Please check if the executable is quarantined by your anti-virus.", - "ExeNotFoundLinux": "\"DepotDownloader\" binary is missing.", + "ExeNotFoundLinux": "\"DepotDownloader\" executable is missing.", "Password": "Password is invalid.", "InvalidCredentials": "Invalid login credentials, unapproved connection, or too many login attempts.", "NoManifest": "No manifest was found", diff --git a/assets/jsons/translations/es.json b/assets/jsons/translations/es.json index a3685349..eadf8b00 100644 --- a/assets/jsons/translations/es.json +++ b/assets/jsons/translations/es.json @@ -323,6 +323,8 @@ "msg": { "401": "Parece que Steam no quiere dejarnos descargar Beat Saber 😢", "404": "No se puede contactar con los servidores de Steam", + "ExeNotFoundWindows": "Falta \"DepotDownloader.exe\". Por favor, verifique si el ejecutable está en cuarentena por su antivirus.", + "ExeNotFoundLinux": "Falta el ejecutable de \"DepotDownloader\".", "Password": "La contraseña es inválida.", "InvalidCredentials": "Credenciales de inicio de sesión inválidas, conexión no aprobada o demasiados intentos de inicio de sesión.", "NoManifest": "No se ha encontrado el manifiesto", diff --git a/assets/jsons/translations/fr.json b/assets/jsons/translations/fr.json index 53ba74ab..8f7ab7c2 100644 --- a/assets/jsons/translations/fr.json +++ b/assets/jsons/translations/fr.json @@ -323,6 +323,8 @@ "msg": { "401": "Steam ne semble pas vouloir nous laisser télécharger Beat Saber 😢", "404": "Impossible de contacter les serveurs de Steam.", + "ExeNotFoundWindows": "\"DepotDownloader.exe\" est manquant. Veuillez vérifier si l'exécutable est mis en quarantaine par votre antivirus.", + "ExeNotFoundLinux": "L'exécutable \"DepotDownloader\" est manquanto.", "Password": "Le mot de passe est invalide.", "InvalidCredentials": "Identifiants de connexion invalides, connexion non approuvée, ou trop de tentatives de connexion.", "NoManifest": "Aucun manifest n'a été trouvé.", diff --git a/assets/jsons/translations/ja.json b/assets/jsons/translations/ja.json index 54ffa8f5..9d7dac7c 100644 --- a/assets/jsons/translations/ja.json +++ b/assets/jsons/translations/ja.json @@ -323,6 +323,8 @@ "msg": { "401": "SteamがBeat Saberのダウンロードを許可してくれないようだ。😢", "404": "Steamサーバーに接続できません。", + "ExeNotFoundWindows": "「DepotDownloader.exe」が見つかりません。実行ファイルがアンチウイルスソフトによって隔離されていないか確認してください。", + "ExeNotFoundLinux": "「DepotDownloader」の実行ファイルが見つかりません。", "Password": "パスワードが不正です。", "InvalidCredentials": "無効なログイン認証情報、許可されていない接続、またはログイン試行回数が多すぎます。", "NoManifest": "マニフェストは見つかりませんでした", diff --git a/assets/jsons/translations/ko.json b/assets/jsons/translations/ko.json index e3cd35ca..d7f81a00 100644 --- a/assets/jsons/translations/ko.json +++ b/assets/jsons/translations/ko.json @@ -323,6 +323,8 @@ "msg": { "401": "Steam이 Beat Saber 다운로드를 허용하지 않는 것 같습니다 😢", "404": "Steam 서버에 연결할 수 없습니다.", + "ExeNotFoundWindows": "「DepotDownloader.exe」가 없습니다. 실행 파일이 바이러스 백신 프로그램에 의해 격리되었는지 확인하십시오.", + "ExeNotFoundLinux": "「DepotDownloader」 실행 파일이 없습니다.", "Password": "비밀번호가 올바르지 않습니다.", "InvalidCredentials": "유효하지 않은 로그인 자격 증명, 허가되지 않은 연결 또는 너무 많은 로그인 시도입니다.", "NoManifest": "매니페스트를 찾을 수 없습니다", diff --git a/assets/jsons/translations/ru.json b/assets/jsons/translations/ru.json index 45eecce3..7f4a4da5 100644 --- a/assets/jsons/translations/ru.json +++ b/assets/jsons/translations/ru.json @@ -323,6 +323,8 @@ "msg": { "401": "Похоже Steam не хочет, чтобы мы скачали Beat Saber 😢", "404": "Нет связи с серверами Steam.", + "ExeNotFoundWindows": "Отсутствует \"DepotDownloader.exe\". Пожалуйста, проверьте, не находится ли исполняемый файл в карантине вашего антивируса.", + "ExeNotFoundLinux": "Отсутствует исполняемый файл \"DepotDownloader\".", "Password": "Неверный пароль.", "InvalidCredentials": "Неверные учетные данные для входа, неразрешенное соединение или слишком много попыток входа.", "NoManifest": "Файл манифеста не найден", diff --git a/assets/jsons/translations/zh-tw.json b/assets/jsons/translations/zh-tw.json index fa0661d7..ac143982 100644 --- a/assets/jsons/translations/zh-tw.json +++ b/assets/jsons/translations/zh-tw.json @@ -323,6 +323,8 @@ "msg": { "401": "Steam 似乎不想讓我們下載 Beat Saber😢", "404": "無法聯繫 Steam 伺服器。", + "ExeNotFoundWindows": "\"DepotDownloader.exe\" 缺失。請檢查執行檔是否被您的防毒軟體隔離。", + "ExeNotFoundLinux": "\"DepotDownloader\" 的可執行檔缺失。", "Password": "密碼無效", "InvalidCredentials": "登錄憑據無效、連接未經批准或登錄嘗試次數過多。", "NoManifest": "未找到清單", diff --git a/assets/jsons/translations/zh.json b/assets/jsons/translations/zh.json index 9dc8c9c5..d28e1234 100644 --- a/assets/jsons/translations/zh.json +++ b/assets/jsons/translations/zh.json @@ -323,6 +323,8 @@ "msg": { "401": "Steam 似乎不想让我们下载 Beat Saber😢", "404": "无法联系 Steam 服务器。", + "ExeNotFoundWindows": "\"DepotDownloader.exe\" 缺失。请检查执行文件是否被您的防病毒软件隔离。", + "ExeNotFoundLinux": "\"DepotDownloader\" 的可执行文件缺失。", "Password": "密码无效", "InvalidCredentials": "登录凭据无效、连接未经批准或登录尝试次数过多。", "NoManifest": "未找到清单", From 08a8349d226b4ee420550fffdf8085c953a9469b Mon Sep 17 00:00:00 2001 From: silentrald Date: Mon, 23 Dec 2024 07:42:19 +0800 Subject: [PATCH 3/7] [chore] added instruction for adding logs in issue template * disabled submitting blank issues --- .github/ISSUE_TEMPLATE/1-bug-report.yaml | 6 ++++-- .github/ISSUE_TEMPLATE/config.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/1-bug-report.yaml b/.github/ISSUE_TEMPLATE/1-bug-report.yaml index 137f40f1..da1ca48c 100644 --- a/.github/ISSUE_TEMPLATE/1-bug-report.yaml +++ b/.github/ISSUE_TEMPLATE/1-bug-report.yaml @@ -26,7 +26,8 @@ body: id: replication attributes: label: Steps to Reproduce - description: Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant. + description: Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. + Include code to reproduce, if relevant. placeholder: | 1. Go to '...' 2. Click on '....' @@ -50,5 +51,6 @@ body: id: additional-context attributes: label: Additional Context - description: Any other context that you may share about the issue. You may add your log files here. + description: Any other context that you may share about the issue such as logs. + To get the logs, follow these steps `Open BSManager -> Go to settings -> Scroll down -> Open Logs`. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index cb856695..7dccb6a7 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,4 +1,4 @@ -lank_issues_enabled: true +blank_issues_enabled: false contact_links: - name: Discord Support url: https://discord.gg/uSqbHVpKdV From a54f81de423a4df9a59431841c6e78386a521de7 Mon Sep 17 00:00:00 2001 From: silentrald Date: Sat, 21 Dec 2024 22:59:11 +0800 Subject: [PATCH 4/7] [feat] add proton logs in advance launch settings for linux --- assets/jsons/translations/en.json | 4 +- .../bs-launcher/bs-launcher.service.ts | 2 + src/main/services/linux.service.ts | 13 ++++-- .../slides/launch/launch-slide.component.tsx | 45 ++++++++++++------- .../bs-launch/launch-option.interface.ts | 1 + 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/assets/jsons/translations/en.json b/assets/jsons/translations/en.json index 1ef9eab9..5d74e9f8 100644 --- a/assets/jsons/translations/en.json +++ b/assets/jsons/translations/en.json @@ -56,7 +56,9 @@ "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.", "map-editor": "Map Editor", - "map-editor-description": "Start the official Beat Saber map editor instead of the game." + "map-editor-description": "Start the official Beat Saber map editor instead of the game.", + "proton-logs": "Proton Logs", + "proton-logs-description": "Writes the proton logs within the Beat Saber version. To access logs, go to \"Version Settings ⚙️ > Open Folder > Open `Logs` Folder\"." }, "maps": { "search-bar": { diff --git a/src/main/services/bs-launcher/bs-launcher.service.ts b/src/main/services/bs-launcher/bs-launcher.service.ts index 5afe996e..96011b9b 100644 --- a/src/main/services/bs-launcher/bs-launcher.service.ts +++ b/src/main/services/bs-launcher/bs-launcher.service.ts @@ -131,6 +131,7 @@ export class BSLauncherService { if(launchOptions.launchMods?.includes(LaunchMods.DEBUG)){ res.debug = "true"; } if(launchOptions.additionalArgs){ res.additionalArgs = launchOptions.additionalArgs; } if(launchOptions.launchMods?.includes(LaunchMods.SKIP_STEAM)){ res.skipSteam = "true"; } + if(launchOptions.launchMods?.includes(LaunchMods.PROTON_LOGS)){ res.protonLogs = "true"; } return res; } @@ -248,6 +249,7 @@ type ShortcutParams = { debug?: string; additionalArgs?: string[]; skipSteam?: string; + protonLogs?: string; version: string; versionName?: string; versionIno?: string; diff --git a/src/main/services/linux.service.ts b/src/main/services/linux.service.ts index 88b22df3..0dba7c0f 100644 --- a/src/main/services/linux.service.ts +++ b/src/main/services/linux.service.ts @@ -6,6 +6,7 @@ import { StaticConfigurationService } from "./static-configuration.service"; import { CustomError } from "shared/models/exceptions/custom-error.class"; import { BSLaunchError, LaunchOption } from "shared/models/bs-launch"; import { bsmExec } from "main/helpers/os.helpers"; +import { LaunchMods } from "shared/models/bs-launch/launch-option.interface"; export class LinuxService { private static instance: LinuxService; @@ -78,11 +79,15 @@ export class LinuxService { "STEAM_COMPAT_CLIENT_INSTALL_PATH": steamPath, "STEAM_COMPAT_APP_ID": BS_APP_ID, // Run game in steam environment; fixes #585 for unicode song titles - "SteamEnv": "1", - // Uncomment these to create a proton log file in the Beat Saber install directory. - // "PROTON_LOG": 1, - // "PROTON_LOG_DIR": bsFolderPath, + "SteamEnv": 1, }); + + if (launchOptions.launchMods?.includes(LaunchMods.PROTON_LOGS)) { + Object.assign(env, { + "PROTON_LOG": 1, + "PROTON_LOG_DIR": path.join(bsFolderPath, "Logs"), + }); + } } public verifyProtonPath(protonFolder: string = ""): boolean { diff --git a/src/renderer/components/version-viewer/slides/launch/launch-slide.component.tsx b/src/renderer/components/version-viewer/slides/launch/launch-slide.component.tsx index b705b132..05ddbb8b 100644 --- a/src/renderer/components/version-viewer/slides/launch/launch-slide.component.tsx +++ b/src/renderer/components/version-viewer/slides/launch/launch-slide.component.tsx @@ -62,6 +62,14 @@ export function LaunchSlide({ version }: Props) { } }, [activeLaunchMods]); + const toggleActiveLaunchMod = (checked: boolean, launchMod: LaunchMod) => checked + ? setActiveLaunchMods(prev => [...prev, launchMod]) + : setActiveLaunchMods(prev => prev.filter(mod => mod !== launchMod)); + + const togglePinnedLaunchMod = (pinned: boolean, launchMod: LaunchMod) => pinned + ? setPinnedLaunchMods(prev => [...prev, launchMod]) + : setPinnedLaunchMods(prev => prev.filter(mod => mod !== launchMod)); + useEffect(() => { setLaunchModItems(() => [ { @@ -72,8 +80,8 @@ export function LaunchSlide({ version }: Props) { active: activeLaunchMods.includes(LaunchMods.OCULUS), visible: !(version.metadata?.store === BsStore.OCULUS), pinned: pinnedLaunchMods.includes(LaunchMods.OCULUS), - onChange: checked => checked ? setActiveLaunchMods(prev => [...prev, LaunchMods.OCULUS]) : setActiveLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.OCULUS)), - onPinChange: pinned => pinned ? setPinnedLaunchMods(prev => [...prev, LaunchMods.OCULUS]) : setPinnedLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.OCULUS)), + onChange: (checked) => toggleActiveLaunchMod(checked, LaunchMods.OCULUS), + onPinChange: (pinned) => togglePinnedLaunchMod(pinned, LaunchMods.OCULUS), }, { id: LaunchMods.FPFC, @@ -82,8 +90,8 @@ export function LaunchSlide({ version }: Props) { description: t("pages.version-viewer.launch-mods.desktop-description"), active: activeLaunchMods.includes(LaunchMods.FPFC), pinned: pinnedLaunchMods.includes(LaunchMods.FPFC), - onChange: checked => checked ? setActiveLaunchMods(prev => [...prev, LaunchMods.FPFC]) : setActiveLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.FPFC)), - onPinChange: pinned => pinned ? setPinnedLaunchMods(prev => [...prev, LaunchMods.FPFC]) : setPinnedLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.FPFC)), + onChange: (checked) => toggleActiveLaunchMod(checked, LaunchMods.FPFC), + onPinChange: (pinned) => togglePinnedLaunchMod(pinned, LaunchMods.FPFC), }, { id: LaunchMods.DEBUG, @@ -92,8 +100,8 @@ export function LaunchSlide({ version }: Props) { description: t("pages.version-viewer.launch-mods.debug-description"), active: activeLaunchMods.includes(LaunchMods.DEBUG), pinned: pinnedLaunchMods.includes(LaunchMods.DEBUG), - onChange: checked => checked ? setActiveLaunchMods(prev => [...prev, LaunchMods.DEBUG]) : setActiveLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.DEBUG)), - onPinChange: pinned => pinned ? setPinnedLaunchMods(prev => [...prev, LaunchMods.DEBUG]) : setPinnedLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.DEBUG)), + onChange: (checked) => toggleActiveLaunchMod(checked, LaunchMods.DEBUG), + onPinChange: (pinned) => togglePinnedLaunchMod(pinned, LaunchMods.DEBUG), }, { id: LaunchMods.SKIP_STEAM, @@ -101,8 +109,8 @@ export function LaunchSlide({ version }: Props) { description: t("pages.version-viewer.launch-mods.skipsteam-description"), active: activeLaunchMods.includes(LaunchMods.SKIP_STEAM), pinned: pinnedLaunchMods.includes(LaunchMods.SKIP_STEAM), - onChange: checked => checked ? setActiveLaunchMods(prev => [...prev, LaunchMods.SKIP_STEAM]) : setActiveLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.SKIP_STEAM)), - onPinChange: pinned => pinned ? setPinnedLaunchMods(prev => [...prev, LaunchMods.SKIP_STEAM]) : setPinnedLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.SKIP_STEAM)), + onChange: (checked) => toggleActiveLaunchMod(checked, LaunchMods.SKIP_STEAM), + onPinChange: (pinned) => togglePinnedLaunchMod(pinned, LaunchMods.SKIP_STEAM), }, { id: LaunchMods.EDITOR, @@ -112,14 +120,23 @@ export function LaunchSlide({ version }: Props) { active: activeLaunchMods.includes(LaunchMods.EDITOR), pinned: pinnedLaunchMods.includes(LaunchMods.EDITOR), visible: !safeLt(version.BSVersion, "1.23.0"), - onChange: checked => checked ? setActiveLaunchMods(prev => [...prev, LaunchMods.EDITOR]) : setActiveLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.EDITOR)), - onPinChange: pinned => pinned ? setPinnedLaunchMods(prev => [...prev, LaunchMods.EDITOR]) : setPinnedLaunchMods(prev => prev.filter(mod => mod !== LaunchMods.EDITOR)), - - } + onChange: (checked) => toggleActiveLaunchMod(checked, LaunchMods.EDITOR), + onPinChange: (pinned) => togglePinnedLaunchMod(pinned, LaunchMods.EDITOR), + }, + { + id: LaunchMods.PROTON_LOGS, + label: t("pages.version-viewer.launch-mods.proton-logs"), + description: t("pages.version-viewer.launch-mods.proton-logs-description"), + active: activeLaunchMods.includes(LaunchMods.PROTON_LOGS), + pinned: pinnedLaunchMods.includes(LaunchMods.PROTON_LOGS), + visible: window.electron.platform === "linux", + onChange: (checked) => toggleActiveLaunchMod(checked, LaunchMods.PROTON_LOGS), + onPinChange: (pinned) => togglePinnedLaunchMod(pinned, LaunchMods.PROTON_LOGS), + }, ]); }, [activeLaunchMods, pinnedLaunchMods, version]); - const launch = () => { + const launch = async () => { const additionalArgs = additionalArgsString?.split(";").map(arg => arg.trim()).filter(arg => arg.length > 0); const launch$ = bsLauncherService.launch({ @@ -193,5 +210,3 @@ export function LaunchSlide({ version }: Props) { ); } - - diff --git a/src/shared/models/bs-launch/launch-option.interface.ts b/src/shared/models/bs-launch/launch-option.interface.ts index 21455b5a..6199fdde 100644 --- a/src/shared/models/bs-launch/launch-option.interface.ts +++ b/src/shared/models/bs-launch/launch-option.interface.ts @@ -6,6 +6,7 @@ export const LaunchMods = { DEBUG: "debug", SKIP_STEAM: "skip_steam", EDITOR: "editor", + PROTON_LOGS: "proton_logs", } as const; export type LaunchMod = typeof LaunchMods[keyof typeof LaunchMods]; From cb755215b59beff961a418f55a52638315eb727f Mon Sep 17 00:00:00 2001 From: silentrald Date: Sun, 22 Dec 2024 13:07:43 +0800 Subject: [PATCH 5/7] [feat] changed proton logs tippy text * fixed issue with translation code where strings with "[]" characters throws an error --- assets/jsons/translations/en.json | 2 +- .../slides/launch/launch-mod-toogle.component.tsx | 4 ++-- src/renderer/services/i18n.service.ts | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/jsons/translations/en.json b/assets/jsons/translations/en.json index 5d74e9f8..a995b004 100644 --- a/assets/jsons/translations/en.json +++ b/assets/jsons/translations/en.json @@ -58,7 +58,7 @@ "map-editor": "Map Editor", "map-editor-description": "Start the official Beat Saber map editor instead of the game.", "proton-logs": "Proton Logs", - "proton-logs-description": "Writes the proton logs within the Beat Saber version. To access logs, go to \"Version Settings ⚙️ > Open Folder > Open `Logs` Folder\"." + "proton-logs-description": "Enables the recording of proton logs for this Beat Saber install to \"{versionPath}\"." }, "maps": { "search-bar": { diff --git a/src/renderer/components/version-viewer/slides/launch/launch-mod-toogle.component.tsx b/src/renderer/components/version-viewer/slides/launch/launch-mod-toogle.component.tsx index e560a7a2..8da346ac 100644 --- a/src/renderer/components/version-viewer/slides/launch/launch-mod-toogle.component.tsx +++ b/src/renderer/components/version-viewer/slides/launch/launch-mod-toogle.component.tsx @@ -2,7 +2,7 @@ import Tippy from "@tippyjs/react"; import { GlowEffect } from "renderer/components/shared/glow-effect.component"; import { BsmIcon } from "renderer/components/svgs/bsm-icon.component"; import { SvgIcon } from "renderer/components/svgs/svg-icon.type"; -import { useTranslation } from "renderer/hooks/use-translation.hook"; +import { useTranslationV2 } from "renderer/hooks/use-translation.hook"; type Props = { onClick: (active: boolean) => void; @@ -13,7 +13,7 @@ type Props = { }; export function LaunchModToogle({ onClick, active, text, icon: Icon, infoText }: Props) { - const t = useTranslation(); + const { text: t } = useTranslationV2(); return (