mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
listage des version BS dispo, le path de BS steam est mtn bien détécté
This commit is contained in:
@@ -30,9 +30,7 @@ ipcMain.on('test-launch', async () => {
|
||||
|
||||
ipcMain.on('bs-launch.steam', async (event, args) => {
|
||||
const steamService = SteamService.getInstance();
|
||||
const beatSaberSteamFolder = path.join(await steamService.getSteamGamesFolder(), "Beat Saber");
|
||||
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}});
|
||||
|
||||
|
||||
})
|
||||
|
||||
@@ -30,11 +30,15 @@ export class BSInstallerService{
|
||||
|
||||
public async getInstalledBsVersion(): Promise<BSVersion[]>{
|
||||
const versions: BSVersion[] = [];
|
||||
if(this.steamService.isGameInstalled(BS_APP_ID)){
|
||||
const steamBsFolder = path.join(await this.steamService.getSteamGamesFolder(), "Beat Saber");
|
||||
console.log("aaa");
|
||||
const steamBsFolder = await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber")
|
||||
console.log(steamBsFolder);
|
||||
if(steamBsFolder && this.utils.pathExist(steamBsFolder)){
|
||||
const steamBsVersion = await this.bsVersionService.getVersionOfBSFolder(steamBsFolder);
|
||||
const steamVersionDetails = this.bsVersionService.getVersionDetailFromVersionNumber(steamBsVersion);
|
||||
versions.push(steamVersionDetails ? {...steamVersionDetails, steam: true} : {BSVersion: steamBsVersion, steam: true});
|
||||
if(steamBsVersion){
|
||||
const steamVersionDetails = this.bsVersionService.getVersionDetailFromVersionNumber(steamBsVersion);
|
||||
versions.push(steamVersionDetails ? {...steamVersionDetails, steam: true} : {BSVersion: steamBsVersion, steam: true});
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.utils.folderExist(this.getBSInstallationFolder())){ return versions }
|
||||
|
||||
@@ -70,6 +70,7 @@ export class BSVersionManagerService{
|
||||
|
||||
public async getVersionOfBSFolder(bsPath: string): Promise<string>{
|
||||
const versionFilePath = path.join(bsPath, 'Beat Saber_Data', 'globalgamemanagers');
|
||||
console.log(versionFilePath);
|
||||
if(!this.utilsService.pathExist(versionFilePath)){ return null; }
|
||||
|
||||
const versionsAvailable = await this.getAvailableVersions();
|
||||
|
||||
@@ -37,28 +37,24 @@ export class SteamService{
|
||||
return this.steamPath;
|
||||
}
|
||||
|
||||
public async getSteamGamesFolder(): Promise<string>{
|
||||
this.isGameInstalled("");
|
||||
const steamFolder = await this.getSteamPath();
|
||||
return path.join(steamFolder, 'steamapps', 'common');
|
||||
}
|
||||
|
||||
public async isGameInstalled(gameId: string): Promise<boolean>{
|
||||
public async getGameFolder(gameId: string, gameFolder?: string): Promise<string>{
|
||||
const steamPath = await this.getSteamPath();
|
||||
let libraryFolders: any = path.join(steamPath, 'steamapps', 'libraryfolders.vdf');
|
||||
|
||||
if(!this.utils.pathExist(libraryFolders)){ return false; }
|
||||
if(!this.utils.pathExist(libraryFolders)){ console.log("null 1"); return null; }
|
||||
libraryFolders = parse(await readFile(libraryFolders, {encoding: 'utf-8'}));
|
||||
|
||||
|
||||
if(!libraryFolders.libraryfolders){ return false; }
|
||||
if(!libraryFolders.libraryfolders){ return null; }
|
||||
libraryFolders = libraryFolders.libraryfolders
|
||||
|
||||
for(const libKey in Object.keys(libraryFolders)){
|
||||
console.log(libraryFolders[libKey]);
|
||||
if(!libraryFolders[libKey] || !libraryFolders[libKey]["apps"]){ continue; }
|
||||
if(libraryFolders[libKey]["apps"][gameId]){ return true };
|
||||
if(libraryFolders[libKey]["apps"][gameId]){ return path.join(libraryFolders[libKey]["path"], "steamapps", "common", gameFolder); };
|
||||
}
|
||||
return false;
|
||||
console.log("null 3")
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user