mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
temporary code to lunch BS
This commit is contained in:
@@ -3,34 +3,36 @@ import path from "path";
|
||||
import { spawn } from 'child_process';
|
||||
import { UtilsService } from '../services/utils.service'
|
||||
import { SteamService } from '../services/steam.service';
|
||||
import { BSVersionManagerService } from '../services/bs-version-manager.service';
|
||||
import { BSVersion, BSVersionManagerService } from '../services/bs-version-manager.service';
|
||||
import { BSInstallerService } from '../services/bs-installer.service'
|
||||
import { BS_EXECUTABLE, BS_APP_ID } from '../constants';
|
||||
|
||||
ipcMain.on('test-launch', async () => {
|
||||
console.log("steam "+ UtilsService.getInstance().taskRunning('steam.exe'));
|
||||
console.log(await SteamService.getInstance().getSteamGamesFolder());
|
||||
console.log(BSInstallerService.getInstance().getBSInstallationFolder());
|
||||
console.log((await BSVersionManagerService.getInstance().getAvailableVersions()));
|
||||
console.log(await BSVersionManagerService.getInstance().getVersionOfBSFolder(path.join(await SteamService.getInstance().getSteamGamesFolder(), "Beat Saber")));
|
||||
console.log(await BSInstallerService.getInstance().getInstalledBsVersion());
|
||||
return;
|
||||
export interface LauchOption {
|
||||
version: BSVersion,
|
||||
oculus: boolean,
|
||||
desktop: boolean,
|
||||
debug: boolean
|
||||
}
|
||||
|
||||
const BS_EXE = "Beat Saber.exe"
|
||||
const BS_PATH = path.join('C:', 'Users', 'Mathieu', 'Desktop', 'BSLegacyLauncher', 'Beat Saber')
|
||||
let a = spawn(`\"${path.join(BS_PATH, BS_EXE)}\"`, ["-vrmode oculus", "--verbose"], { shell: true, cwd: BS_PATH, env: {...process.env ,"SteamAppId": "620980"}});
|
||||
a.stdout.on('data', data => console.log(data.toString()));
|
||||
a.stderr.on('data', data => console.log(data.toString()));
|
||||
a.on('message', m => console.log(m));
|
||||
a.on('error', err => console.log(err));
|
||||
a.on('exit', e => console.log(e));
|
||||
a.on('disconnect', (d: any) => console.log(d))
|
||||
console.log('oui');
|
||||
});
|
||||
|
||||
ipcMain.on('bs-launch.steam', async (event, args) => {
|
||||
ipcMain.on('bs-launch.launch', async (event, args: LauchOption) => { //Create a service BSLauncherService
|
||||
const steamService = SteamService.getInstance();
|
||||
const beatSaberSteamFolder = await steamService.getGameFolder(BS_APP_ID, "Beat Saber");
|
||||
const beatSaberSteamExe = path.join(beatSaberSteamFolder, BS_EXECUTABLE);
|
||||
const spawnProcess = spawn(`\"${beatSaberSteamExe}\"`, [], {shell: true, cwd: beatSaberSteamFolder, env: {...process.env, "SteamAppId": BS_APP_ID}});
|
||||
})
|
||||
const installerService = BSInstallerService.getInstance();
|
||||
let cwd = "";
|
||||
if(!steamService.steamRunning()){ UtilsService.getInstance().ipcSend("bs-launch.launch", 1); return; }
|
||||
if(args.version.steam){
|
||||
cwd = await steamService.getGameFolder(BS_APP_ID, "Beat Saber");
|
||||
}
|
||||
else{
|
||||
cwd = path.join(installerService.getBSInstallationFolder(), args.version.BSVersion);
|
||||
}
|
||||
const exePath = path.join(cwd, BS_EXECUTABLE);
|
||||
if(!UtilsService.getInstance().pathExist(exePath)){ UtilsService.getInstance().ipcSend("bs-launch.launch", 2); return; }
|
||||
|
||||
const launchMods = [];
|
||||
if(args.oculus){ launchMods.push("-vrmode oculus"); }
|
||||
if(args.debug){ launchMods.push("--verbose"); }
|
||||
if(args.desktop){ launchMods.push("fpfc"); }
|
||||
spawn(`\"${exePath}\"`, launchMods, {shell: true, cwd: cwd, env: {...process.env, "SteamAppId": BS_APP_ID}});
|
||||
|
||||
UtilsService.getInstance().ipcSend("bs-launch.launch", 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user