From bed81851cc1cb60e36064183dc8d6ce0e9a8d32d Mon Sep 17 00:00:00 2001 From: MathieuG-P Date: Tue, 19 Jul 2022 21:28:19 +0200 Subject: [PATCH] use new version path fonction from LocalVersionService --- src/main/ipcs/bs-version-ipcs.ts | 4 ++-- src/main/services/bs-launcher.service.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/ipcs/bs-version-ipcs.ts b/src/main/ipcs/bs-version-ipcs.ts index 01ae180e..f762e4ea 100644 --- a/src/main/ipcs/bs-version-ipcs.ts +++ b/src/main/ipcs/bs-version-ipcs.ts @@ -28,8 +28,8 @@ ipcMain.on('bs-version.installed-versions', async (event, req: IpcRequest) }); ipcMain.on("bs-version.open-folder", async (event, req: IpcRequest) => { - const locationService = InstallationLocationService.getInstance(); - const versionFolder = req.args.steam ? await SteamService.getInstance().getGameFolder(BS_APP_ID, "Beat Saber") : path.join(locationService.versionsDirectory, req.args.BSVersion); + const localVersionService = BSLocalVersionService.getInstance(); + const versionFolder = await localVersionService.getVersionPath(req.args); UtilsService.getInstance().folderExist(versionFolder) && exec(`start "" "${versionFolder}"`); }); diff --git a/src/main/services/bs-launcher.service.ts b/src/main/services/bs-launcher.service.ts index 312f5f10..e544a31b 100644 --- a/src/main/services/bs-launcher.service.ts +++ b/src/main/services/bs-launcher.service.ts @@ -6,6 +6,7 @@ import { BS_EXECUTABLE, BS_APP_ID } from "../constants"; import { ChildProcessWithoutNullStreams, spawn } from "child_process"; import { SteamService } from "./steam.service"; import { InstallationLocationService } from "./installation-location.service"; +import { BSLocalVersionService } from "./bs-local-version.service"; export class BSLauncherService{ @@ -14,6 +15,7 @@ export class BSLauncherService{ private readonly utilsService: UtilsService; private readonly steamService: SteamService; private readonly installLocationService: InstallationLocationService; + private readonly localVersionService: BSLocalVersionService; private bsProcess: ChildProcessWithoutNullStreams; @@ -26,24 +28,22 @@ export class BSLauncherService{ this.utilsService = UtilsService.getInstance(); this.steamService = SteamService.getInstance(); this.installLocationService = InstallationLocationService.getInstance(); + this.localVersionService = BSLocalVersionService.getInstance(); } public isBsRunning(): boolean{ return this.bsProcess?.connected || this.utilsService.taskRunning(BS_EXECUTABLE); } - public isExeExist(version: BSVersion): boolean{ - const exePath = path.join(this.installLocationService.versionsDirectory, version.BSVersion, BS_EXECUTABLE); - return this.utilsService.pathExist(exePath); - } - public async launch(launchOptions: LauchOption): Promise{ if(!this.steamService.steamRunning()){ return "STEAM_NOT_RUNNING" } - if(!this.isExeExist(launchOptions.version)){ return "EXE_NOT_FINDED"; } if(this.isBsRunning()){ return "BS_ALREADY_RUNNING" } - const cwd = launchOptions.version.steam ? await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber") : path.join(this.installLocationService.versionsDirectory, launchOptions.version.BSVersion); + const cwd = await this.localVersionService.getVersionPath(launchOptions.version); const exePath = path.join(cwd, BS_EXECUTABLE); + + if(!this.utilsService.pathExist(exePath)){ return "EXE_NOT_FINDED"; } + const launchMods = [launchOptions.oculus && "-vrmode oculus", launchOptions.desktop && "fpfc", launchOptions.debug && "--verbose"]; this.bsProcess = spawn(`\"${exePath}\"`, launchMods, {shell: true, cwd: cwd, env: {...process.env, "SteamAppId": BS_APP_ID}});