mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Merge pull request #17 from Zagrios/feature/oculus-installation-detection
Feature/oculus installation detection
This commit is contained in:
@@ -202,12 +202,14 @@
|
||||
"titles":{
|
||||
"UNABLE_TO_LAUNCH": "Unable to launch",
|
||||
"STEAM_NOT_RUNNING": "Steam is not running",
|
||||
"OCULUS_NOT_RUNNING": "Oculus is not running",
|
||||
"BS_ALREADY_RUNNING": "BeatSaber already running",
|
||||
"EXE_NOT_FINDED": "Missing files",
|
||||
"EXIT": "Abrupt stop"
|
||||
},
|
||||
"msg":{
|
||||
"STEAM_NOT_RUNNING": "Steam must be running to launch BeatSaber.",
|
||||
"OCULUS_NOT_RUNNING": "Oculus must be running to launch BeatSaber.",
|
||||
"BS_ALREADY_RUNNING": "Close BeatSaber before launching it again.",
|
||||
"EXE_NOT_FINDED": "Some files seem to be missing, try to verify the files.",
|
||||
"EXIT": "BeatSaber stopped abruptly, tries to check the files."
|
||||
|
||||
@@ -203,12 +203,14 @@
|
||||
"titles":{
|
||||
"UNABLE_TO_LAUNCH": "No se puede lanzar",
|
||||
"STEAM_NOT_RUNNING": "Steam no funciona",
|
||||
"OCULUS_NOT_RUNNING": "Oculus no funciona",
|
||||
"BS_ALREADY_RUNNING": "BeatSaber ya está en marcha",
|
||||
"EXE_NOT_FINDED": "Archivos perdidos",
|
||||
"EXIT": "Parada abrupta"
|
||||
},
|
||||
"msg":{
|
||||
"STEAM_NOT_RUNNING": "Para iniciar BeatSaber es necesario que Steam esté en funcionamiento.",
|
||||
"OCULUS_NOT_RUNNING": "Oculus debe estar funcionando para lanzar BeatSaber.",
|
||||
"BS_ALREADY_RUNNING": "Cierra BeatSaber antes de volver a lanzarlo.",
|
||||
"EXE_NOT_FINDED": "Parece que faltan algunos archivos, intente verificar los archivos.",
|
||||
"EXIT": "BeatSaber se detuvo abruptamente, trata de revisar los archivos."
|
||||
|
||||
@@ -202,12 +202,14 @@
|
||||
"titles":{
|
||||
"UNABLE_TO_LAUNCH": "Lancement impossible",
|
||||
"STEAM_NOT_RUNNING": "Steam n'est pas lancé",
|
||||
"OCULUS_NOT_RUNNING": "Oculus n'est pas lancé",
|
||||
"BS_ALREADY_RUNNING": "BeatSaber est déjà lancé",
|
||||
"EXE_NOT_FINDED": "Fichiers manquants",
|
||||
"EXIT": "Arrêt brutal"
|
||||
},
|
||||
"msg":{
|
||||
"STEAM_NOT_RUNNING": "Steam doit être en cours d'exécution pour lancer BeatSaber.",
|
||||
"OCULUS_NOT_RUNNING": "Oculus doit être en cours d'exécution pour lancer BeatSaber.",
|
||||
"BS_ALREADY_RUNNING": "Ferme BeatSaber avant de le lancer à nouveau.",
|
||||
"EXE_NOT_FINDED": "Quelques fichiers semblent manquants. Essaye de vérifier les fichiers.",
|
||||
"EXIT": "BeatSaber s'est arrêté brusquement, essaye de vérifier les fichiers."
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export const BS_EXECUTABLE = "Beat Saber.exe";
|
||||
export const OCULUS_BS_DIR = "hyperbolic-magnetism-beat-saber"
|
||||
export const BS_APP_ID = "620980";
|
||||
export const BS_DEPOT = "620981";
|
||||
|
||||
@@ -2,13 +2,9 @@ import { ipcMain } from 'electron';
|
||||
import { UtilsService } from '../services/utils.service';
|
||||
import { BSVersionLibService } from '../services/bs-version-lib.service'
|
||||
import { BSVersion } from 'shared/bs-version.interface';
|
||||
import path from 'path';
|
||||
import { exec } from 'child_process';
|
||||
import { SteamService } from '../services/steam.service';
|
||||
import { BS_APP_ID } from '../constants';
|
||||
import { IpcRequest } from 'shared/models/ipc';
|
||||
import { BSLocalVersionService } from '../services/bs-local-version.service';
|
||||
import { InstallationLocationService } from '../services/installation-location.service';
|
||||
import { BsmException } from 'shared/models/bsm-exception.model';
|
||||
|
||||
ipcMain.on('bs-version.get-version-dict', (event, req: IpcRequest<void>) => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { BS_EXECUTABLE, BS_APP_ID } from "../constants";
|
||||
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
|
||||
import { SteamService } from "./steam.service";
|
||||
import { BSLocalVersionService } from "./bs-local-version.service";
|
||||
import { OculusService } from "./oculus.service";
|
||||
|
||||
export class BSLauncherService{
|
||||
|
||||
@@ -12,6 +13,7 @@ export class BSLauncherService{
|
||||
|
||||
private readonly utilsService: UtilsService;
|
||||
private readonly steamService: SteamService;
|
||||
private readonly oculusService: OculusService;
|
||||
private readonly localVersionService: BSLocalVersionService;
|
||||
|
||||
private bsProcess: ChildProcessWithoutNullStreams;
|
||||
@@ -24,6 +26,7 @@ export class BSLauncherService{
|
||||
private constructor(){
|
||||
this.utilsService = UtilsService.getInstance();
|
||||
this.steamService = SteamService.getInstance();
|
||||
this.oculusService = OculusService.getInstance();
|
||||
this.localVersionService = BSLocalVersionService.getInstance();
|
||||
}
|
||||
|
||||
@@ -32,7 +35,8 @@ export class BSLauncherService{
|
||||
}
|
||||
|
||||
public async launch(launchOptions: LauchOption): Promise<LaunchResult>{
|
||||
if(!this.steamService.steamRunning()){ return "STEAM_NOT_RUNNING" }
|
||||
if(launchOptions.version.oculus && !this.oculusService.oculusRunning()){ return "OCULUS_NOT_RUNNING" }
|
||||
if(!launchOptions.version.oculus && !this.steamService.steamRunning()){ return "STEAM_NOT_RUNNING" }
|
||||
if(this.isBsRunning()){ return "BS_ALREADY_RUNNING" }
|
||||
|
||||
const cwd = await this.localVersionService.getVersionPath(launchOptions.version);
|
||||
@@ -42,7 +46,7 @@ export class BSLauncherService{
|
||||
|
||||
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}});
|
||||
this.bsProcess = spawn(`\"${exePath}\"`, launchMods, {shell: true, cwd, env: {...process.env, "SteamAppId": BS_APP_ID}});
|
||||
|
||||
this.bsProcess.on('message', msg => { /** EMIT HERE **/ });
|
||||
this.bsProcess.on('error', err => { /** EMIT HERE **/ });
|
||||
|
||||
@@ -3,7 +3,7 @@ import { BSVersion } from 'shared/bs-version.interface';
|
||||
import { InstallationLocationService } from "./installation-location.service";
|
||||
import { SteamService } from "./steam.service";
|
||||
import { UtilsService } from "./utils.service";
|
||||
import { BS_APP_ID } from "../constants";
|
||||
import { BS_APP_ID, OCULUS_BS_DIR } from "../constants";
|
||||
import path from "path";
|
||||
import { createInterface } from "readline";
|
||||
import { createReadStream } from "fs";
|
||||
@@ -12,6 +12,8 @@ import { ConfigurationService } from "./configuration.service";
|
||||
import { rename } from "fs/promises";
|
||||
import { BsmException } from "shared/models/bsm-exception.model";
|
||||
import log from "electron-log";
|
||||
import { OculusService } from "./oculus.service";
|
||||
import { DownloadLinkType } from "shared/models/mods";
|
||||
|
||||
export class BSLocalVersionService{
|
||||
|
||||
@@ -22,6 +24,7 @@ export class BSLocalVersionService{
|
||||
private readonly installLocationService: InstallationLocationService;
|
||||
private readonly utilsService: UtilsService;
|
||||
private readonly steamService: SteamService;
|
||||
private readonly oculusService: OculusService;
|
||||
private readonly remoteVersionService: BSVersionLibService;
|
||||
private readonly configService: ConfigurationService;
|
||||
|
||||
@@ -34,6 +37,7 @@ export class BSLocalVersionService{
|
||||
this.installLocationService = InstallationLocationService.getInstance();
|
||||
this.utilsService = UtilsService.getInstance();
|
||||
this.steamService = SteamService.getInstance();
|
||||
this.oculusService = OculusService.getInstance();
|
||||
this.remoteVersionService = BSVersionLibService.getInstance();
|
||||
this.configService = ConfigurationService.getInstance();
|
||||
}
|
||||
@@ -80,6 +84,7 @@ export class BSLocalVersionService{
|
||||
|
||||
public async getVersionPath(version: BSVersion): Promise<string>{
|
||||
if(version.steam){ return this.steamService.getGameFolder(BS_APP_ID, "Beat Saber") }
|
||||
if(version.oculus){ return this.oculusService.getGameFolder(OCULUS_BS_DIR); }
|
||||
return path.join(
|
||||
this.installLocationService.versionsDirectory,
|
||||
this.getVersionFolder(version)
|
||||
@@ -87,7 +92,6 @@ export class BSLocalVersionService{
|
||||
}
|
||||
|
||||
private removeSpecialChar(seq: string): string{
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
return seq.replace( /[<>:"\/\\|?*]+/g, '' );
|
||||
}
|
||||
|
||||
@@ -95,27 +99,46 @@ export class BSLocalVersionService{
|
||||
return version.name ? `${version.BSVersion}-${version.name}` : version.BSVersion;
|
||||
}
|
||||
|
||||
public getVersionType(version: BSVersion): "steam"|"universal"{
|
||||
public getVersionType(version: BSVersion): DownloadLinkType{
|
||||
if(version.steam){ return "steam"; }
|
||||
if(version.oculus){ return "oculus"; }
|
||||
return "universal"
|
||||
}
|
||||
|
||||
private async getSteamVersion(): Promise<BSVersion>{
|
||||
const steamBsFolder = await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber");
|
||||
if(!steamBsFolder || !this.utilsService.pathExist(steamBsFolder)){ return null; }
|
||||
const steamBsVersion = await this.getVersionOfBSFolder(steamBsFolder);
|
||||
if(!steamBsVersion){ return null; }
|
||||
const version = await this.remoteVersionService.getVersionDetails(steamBsVersion);
|
||||
if(!version){ return null; }
|
||||
return {...version, steam: true};
|
||||
}
|
||||
|
||||
private async getOculusVersion(): Promise<BSVersion>{
|
||||
const oculusBsFolder = await this.oculusService.getGameFolder(OCULUS_BS_DIR);
|
||||
if(!oculusBsFolder){ return null; }
|
||||
const oculusBsVersion = await this.getVersionOfBSFolder(oculusBsFolder);
|
||||
if(!oculusBsVersion){ return null; }
|
||||
const version = await this.remoteVersionService.getVersionDetails(oculusBsVersion);
|
||||
if(!version){ return null; }
|
||||
return {...version, oculus: true};
|
||||
}
|
||||
|
||||
public async getInstalledVersions(): Promise<BSVersion[]>{
|
||||
|
||||
const versions: BSVersion[] = [];
|
||||
const steamBsFolder = await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber");
|
||||
if(steamBsFolder && this.utilsService.pathExist(steamBsFolder)){
|
||||
const steamBsVersion = await this.getVersionOfBSFolder(steamBsFolder);
|
||||
if(steamBsVersion){
|
||||
const steamVersionDetails = this.remoteVersionService.getVersionDetails(steamBsVersion);
|
||||
versions.push(steamVersionDetails ? {...steamVersionDetails, steam: true} : {BSVersion: steamBsVersion, steam: true});
|
||||
}
|
||||
}
|
||||
const steamVersion = await this.getSteamVersion();
|
||||
if(steamVersion){ versions.push(steamVersion); }
|
||||
const oculusVersion = await this.getOculusVersion();
|
||||
if(oculusVersion){ versions.push(oculusVersion); }
|
||||
|
||||
if(!this.utilsService.pathExist(this.installLocationService.versionsDirectory)){ return versions }
|
||||
|
||||
const folderInInstallation = this.utilsService.listDirsInDir(this.installLocationService.versionsDirectory);
|
||||
folderInInstallation.forEach(f => {
|
||||
for(const f of folderInInstallation){
|
||||
log.info("try get version from folder", f);
|
||||
let version = this.remoteVersionService.getVersionDetails(f);
|
||||
let version = await this.remoteVersionService.getVersionDetails(f);
|
||||
if(version){ version = this.getCustomVersions().find(v => v.BSVersion === version.BSVersion && v.name === version.name) ?? version; }
|
||||
else { version = this.getCustomVersions().find(v => {
|
||||
const [version, ...rest] = f.split("-");
|
||||
@@ -125,13 +148,13 @@ export class BSLocalVersionService{
|
||||
})
|
||||
}
|
||||
version && versions.push(version);
|
||||
});
|
||||
};
|
||||
this.setCustomVersions(versions.filter(v => !!v.name || !!v.color));
|
||||
return versions;
|
||||
}
|
||||
|
||||
public async deleteVersion(version: BSVersion): Promise<boolean>{
|
||||
if(version.steam){ return false; }
|
||||
if(version.steam || version.oculus){ return false; }
|
||||
const versionFolder = await this.getVersionPath(version);
|
||||
if(!this.utilsService.pathExist(versionFolder)){ return true; }
|
||||
|
||||
@@ -141,7 +164,7 @@ export class BSLocalVersionService{
|
||||
}
|
||||
|
||||
public async editVersion(version: BSVersion, name: string, color: string): Promise<BSVersion>{
|
||||
if(version.steam){ throw {title: "CantEditSteam", msg: "CantEditSteam"} as BsmException; }
|
||||
if(version.steam || version.oculus){ throw {title: "CantEditSteam", msg: "CantEditSteam"} as BsmException; }
|
||||
const oldPath = await this.getVersionPath(version);
|
||||
const editedVersion: BSVersion = version.BSVersion === name
|
||||
? {...version, name: undefined, color}
|
||||
@@ -169,7 +192,7 @@ export class BSLocalVersionService{
|
||||
const originPath = await this.getVersionPath(version);
|
||||
const cloneVersion: BSVersion = version.BSVersion === name
|
||||
? {...version, name: undefined, color}
|
||||
: {...version, name: this.removeSpecialChar(name), color, steam: false};
|
||||
: {...version, name: this.removeSpecialChar(name), color, steam: false, oculus: false};
|
||||
const newPath = await this.getVersionPath(cloneVersion);
|
||||
|
||||
if(originPath === newPath){
|
||||
|
||||
@@ -16,7 +16,7 @@ export class BSVersionLibService{
|
||||
private utilsService: UtilsService;
|
||||
private requestService: RequestService
|
||||
|
||||
private bsVersions: BSVersion[] = [];
|
||||
private bsVersions: BSVersion[];
|
||||
|
||||
private constructor(){
|
||||
this.utilsService = UtilsService.getInstance();
|
||||
@@ -44,25 +44,26 @@ export class BSVersionLibService{
|
||||
writeFileSync(localVersionsPath, JSON.stringify(versions, null, "\t"), {encoding: 'utf-8', flag: 'w'});
|
||||
};
|
||||
|
||||
private async loadBsVersions(): Promise<BSVersion[]>{
|
||||
const [localVersions, remoteVersions] = await Promise.all([
|
||||
this.getLocalVersions(), (await isOnline({timeout: 1500}) && this.getRemoteVersions())
|
||||
]);
|
||||
let resVersions = localVersions;
|
||||
if(remoteVersions && remoteVersions.length){ resVersions = remoteVersions; this.updateLocalVersions(resVersions); }
|
||||
this.bsVersions = resVersions;
|
||||
return this.bsVersions;
|
||||
private async loadBsVersions(): Promise<BSVersion[]>{
|
||||
if(this.bsVersions){ return this.bsVersions; }
|
||||
const [localVersions, remoteVersions] = await Promise.all([
|
||||
this.getLocalVersions(), (await isOnline({timeout: 1500}) && this.getRemoteVersions())
|
||||
]);
|
||||
let resVersions = localVersions;
|
||||
if(remoteVersions && remoteVersions.length){ resVersions = remoteVersions; this.updateLocalVersions(resVersions); }
|
||||
this.bsVersions = resVersions;
|
||||
return this.bsVersions;
|
||||
}
|
||||
|
||||
public async getAvailableVersions(): Promise<BSVersion[]>{
|
||||
if(this.bsVersions && this.bsVersions.length){ return this.bsVersions; }
|
||||
const bsVersions = await this.loadBsVersions();
|
||||
if(!bsVersions || !bsVersions.length){ return []; }
|
||||
return bsVersions;
|
||||
}
|
||||
|
||||
public getVersionDetails(version: string): BSVersion{
|
||||
return this.bsVersions.find(v => v.BSVersion === version);
|
||||
}
|
||||
public async getVersionDetails(version: string): Promise<BSVersion>{
|
||||
const versions = await this.getAvailableVersions();
|
||||
return versions.find(v => v.BSVersion === version);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { UtilsService } from "./utils.service";
|
||||
import regedit from 'regedit'
|
||||
import path from "path";
|
||||
|
||||
export class OculusService {
|
||||
|
||||
private static instance: OculusService;
|
||||
|
||||
private readonly utils: UtilsService;
|
||||
|
||||
private oculusPaths: string[];
|
||||
|
||||
public static getInstance(): OculusService{
|
||||
if(!OculusService.instance){ OculusService.instance = new OculusService(); }
|
||||
return OculusService.instance;
|
||||
}
|
||||
|
||||
private constructor(){
|
||||
this.utils = UtilsService.getInstance();
|
||||
}
|
||||
|
||||
public oculusRunning(): boolean{
|
||||
return this.utils.taskRunning("OculusClient.exe");
|
||||
}
|
||||
|
||||
public async getOculusLibsPath(): Promise<string[]>{
|
||||
|
||||
if(this.oculusPaths){ return this.oculusPaths; }
|
||||
|
||||
const oculusLibsRegKey = "HKCU\\SOFTWARE\\Oculus VR, LLC\\Oculus\\Libraries";
|
||||
|
||||
const libsRegData = (await regedit.promisified.list([oculusLibsRegKey]))["HKCU\\SOFTWARE\\Oculus VR, LLC\\Oculus\\Libraries"];
|
||||
|
||||
if(!libsRegData.exists || !libsRegData.keys){ return null; }
|
||||
|
||||
const libsPath = (await Promise.all(libsRegData.keys.map(async key => {
|
||||
const originalPath = (await regedit.promisified.list([`${oculusLibsRegKey}\\${key}`]))[`${oculusLibsRegKey}\\${key}`];
|
||||
if(!originalPath.exists || !libsRegData.values || !originalPath.values["OriginalPath"]){ return null; }
|
||||
|
||||
return originalPath.values["OriginalPath"].value as string;
|
||||
|
||||
}, []))).filter(path => !!path);
|
||||
|
||||
this.oculusPaths = libsPath;
|
||||
|
||||
return libsPath;
|
||||
|
||||
}
|
||||
|
||||
public async getGameFolder(gameFolder: string): Promise<string>{
|
||||
|
||||
const libsFolders = await this.getOculusLibsPath();
|
||||
const rootLibDir = "Software"
|
||||
|
||||
for(const lib of libsFolders){
|
||||
const gameFullPath = path.join(lib, rootLibDir, gameFolder);
|
||||
if(this.utils.pathExist(gameFullPath)){ return gameFullPath; }
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export function BsVersionItem(props: {version: BSVersion}) {
|
||||
const {firstColor, secondColor} = useThemeColor();
|
||||
|
||||
const isActive = (): boolean => {
|
||||
return props.version?.BSVersion === state?.BSVersion && props?.version.steam === state?.steam && props?.version.name === state?.name;
|
||||
return props.version?.BSVersion === state?.BSVersion && props?.version.steam === state?.steam && props?.version.oculus === state?.oculus && props?.version.name === state?.name;
|
||||
}
|
||||
|
||||
const handleDoubleClick = () => {
|
||||
@@ -52,9 +52,9 @@ export function BsVersionItem(props: {version: BSVersion}) {
|
||||
useEffect(() => {
|
||||
const subs: Subscription[] = [];
|
||||
const downloadSub = combineLatest([downloaderService.currentBsVersionDownload$, downloaderService.downloadProgress$]).subscribe(vals => {
|
||||
if(vals[0]?.BSVersion === props.version.BSVersion && vals[0]?.steam === props.version.steam && vals[0]?.name === props.version.name){
|
||||
setDownloading(true);
|
||||
setDownloadPercent(vals[1]);
|
||||
if(vals[0]?.BSVersion === props.version.BSVersion && vals[0]?.steam === props.version.steam && vals[0].oculus === props.version.oculus && vals[0]?.name === props.version.name){
|
||||
setDownloading(true);
|
||||
setDownloadPercent(vals[1]);
|
||||
}
|
||||
else{
|
||||
setDownloading(false);
|
||||
@@ -65,14 +65,24 @@ export function BsVersionItem(props: {version: BSVersion}) {
|
||||
return () => { subs.forEach(s => s.unsubscribe()); }
|
||||
}, []);
|
||||
|
||||
const renderIcon = () => {
|
||||
const classes = "w-[19px] h-[19px] mr-[5px] shrink-0"
|
||||
if(props.version.steam){
|
||||
return <BsmIcon icon="steam" className={classes}/>
|
||||
}
|
||||
if(props.version.oculus){
|
||||
return <BsmIcon icon="oculus" className={`${classes} p-[2px] rounded-full bg-main-color-1 text-white dark:bg-white dark:text-black`}/>
|
||||
}
|
||||
return <BsmIcon icon="bsNote" className={classes} style={{color: props.version?.color ?? secondColor}}/>
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<li className={`outline-none relative p-[1px] overflow-hidden rounded-xl flex justify-center items-center mb-1 ${downloading && "nav-item-download"} active:translate-y-[1px]`}>
|
||||
{downloading && <div className="download-progress absolute top-0 w-full h-full" style={{transform: `translate(${-(100 - downloadPercent)}%, 0)`, background: `linear-gradient(90deg, ${firstColor}, ${secondColor}, ${firstColor}, ${secondColor})`}}/>}
|
||||
<div className={`wrapper z-[1] px-1 py-[3px] w-full rounded-xl ${downloading && 'bg-white dark:bg-black'} ${!downloading && "hover:bg-light-main-color-3 dark:hover:bg-main-color-3"} ${(isActive() && !downloading) && "bg-light-main-color-3 dark:bg-main-color-3"}`}>
|
||||
<Link onDoubleClick={handleDoubleClick} to={`/bs-version/${props.version.BSVersion}`} state={props.version} title={props.version.name && `${props.version.BSVersion} - ${props.version.name}`} className="w-full flex items-center justify-start content-center max-w-full">
|
||||
{props.version.steam && <BsmIcon icon="steam" className="w-[19px] h-[19px] mr-[5px] shrink-0"/>}
|
||||
{!props.version.steam && <BsmIcon icon="bsNote" className="w-[19px] h-[19px] mr-[5px] shrink-0" style={{color: props.version?.color ?? secondColor}}/>}
|
||||
{renderIcon()}
|
||||
<div className="overflow-hidden whitespace-nowrap text-xl dark:text-gray-200 text-gray-800 font-bold tracking-wide">
|
||||
<ReactFitty maxSize={19} minSize={9} className='align-middle pb-[2px] max-w-full overflow-hidden text-ellipsis'>{props.version.name || props.version.BSVersion}</ReactFitty>
|
||||
</div>
|
||||
|
||||
@@ -19,10 +19,10 @@ export function NavBar() {
|
||||
{installedVersions && installedVersions.map((version) => <BsVersionItem key={JSON.stringify(version)} version={version}/>)}
|
||||
</ol>
|
||||
<div className='w-full p-2 flex flex-col items-center content-center justify-start'>
|
||||
<Link className='mb-2' to={"blah"}>
|
||||
<Link className='mb-2' to="blah">
|
||||
<BsmIcon icon='add' className='text-blue-500 h-[34px]'/>
|
||||
</Link>
|
||||
<Link to={"settings"}>
|
||||
<Link to="settings">
|
||||
<BsmIcon icon='settings' className='text-blue-500 h-7'/>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -6,9 +6,9 @@ import { ConfigurationService } from "renderer/services/configuration.service";
|
||||
import { BSVersion } from "shared/bs-version.interface"
|
||||
import { LaunchModToogle } from "./launch-mod-toogle.component";
|
||||
|
||||
type props = {version: BSVersion};
|
||||
type Props = {version: BSVersion};
|
||||
|
||||
export function LaunchSlide({version}: props) {
|
||||
export function LaunchSlide({version}: Props) {
|
||||
|
||||
const configService = ConfigurationService.getInstance();
|
||||
const bsLauncherService = BSLauncherService.getInstance();
|
||||
@@ -34,12 +34,12 @@ export function LaunchSlide({version}: props) {
|
||||
configService.set(mode, value);
|
||||
}
|
||||
|
||||
const launch = () => bsLauncherService.launch(version, oculusMode, desktopMode, debugMode)
|
||||
const launch = () => bsLauncherService.launch(version, version.oculus ? false : oculusMode, desktopMode, debugMode)
|
||||
|
||||
return (
|
||||
<div className="w-full shrink-0 items-center relative flex flex-col justify-start">
|
||||
<div className='grid grid-flow-col grid-cols-3 gap-6'>
|
||||
<LaunchModToogle icon='oculus' onClick={() => setMode(LaunchMods.OCULUS_MOD, !oculusMode)} active={oculusMode} text="pages.version-viewer.launch-mods.oculus"/>
|
||||
<div className='grid grid-flow-col gap-6'>
|
||||
{!version.oculus && <LaunchModToogle icon='oculus' onClick={() => setMode(LaunchMods.OCULUS_MOD, !oculusMode)} active={oculusMode} text="pages.version-viewer.launch-mods.oculus"/>}
|
||||
<LaunchModToogle icon='desktop' onClick={() => setMode(LaunchMods.DESKTOP_MOD, !desktopMode)} active={desktopMode} text="pages.version-viewer.launch-mods.desktop"/>
|
||||
<LaunchModToogle icon='terminal' onClick={() => setMode(LaunchMods.DEBUG_MOD, !debugMode)} active={debugMode} text="pages.version-viewer.launch-mods.debug"/>
|
||||
</div>
|
||||
|
||||
@@ -80,11 +80,11 @@ export function VersionViewer() {
|
||||
</div>
|
||||
<BsmDropdownButton className='absolute top-5 right-5 h-9 w-9 bg-light-main-color-2 dark:bg-main-color-2 rounded-md' items={[
|
||||
{text: "pages.version-viewer.dropdown.open-folder", icon: "folder", onClick: openFolder},
|
||||
(!state.steam && {text: "pages.version-viewer.dropdown.verify-files", icon: "task", onClick: verifyFiles}),
|
||||
(!state.steam && {text: "Exporter les misc.maps", icon: "export", onClick: exportMaps}),
|
||||
(!state.steam && {text: "pages.version-viewer.dropdown.edit", icon: "edit", onClick: edit}),
|
||||
{text: "pages.version-viewer.dropdown.clone", icon: "copy", onClick: clone},
|
||||
(!state.steam && {text: "pages.version-viewer.dropdown.uninstall", icon:"trash", onClick: uninstall})
|
||||
((!state.steam && !state.oculus) && {text: "pages.version-viewer.dropdown.verify-files", icon: "task", onClick: verifyFiles}),
|
||||
((!state.steam && !state.oculus) && {text: "Exporter les misc.maps", icon: "export", onClick: exportMaps}),
|
||||
((!state.steam && !state.oculus) && {text: "pages.version-viewer.dropdown.edit", icon: "edit", onClick: edit}),
|
||||
(!state.oculus && {text: "pages.version-viewer.dropdown.clone", icon: "copy", onClick: clone}),
|
||||
((!state.steam && !state.oculus) && {text: "pages.version-viewer.dropdown.uninstall", icon:"trash", onClick: uninstall})
|
||||
]}/>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -33,10 +33,14 @@ export class BSVersionManagerService {
|
||||
public setInstalledVersions(versions: BSVersion[]){
|
||||
const sorted: BSVersion[] = versions.sort((a, b) => +b.ReleaseDate - +a.ReleaseDate)
|
||||
const steamIndex = sorted.findIndex(v => v.steam);
|
||||
const oculusIndex = sorted.findIndex(v => v.oculus);
|
||||
if(steamIndex > 0){
|
||||
[sorted[0], sorted[steamIndex]] = [sorted[steamIndex], sorted[0]];
|
||||
}
|
||||
const cleanedSort = [...new Map(sorted.map(version => [`${version.BSVersion}-${version.name}-${version.steam}`, version])).values()]
|
||||
if(oculusIndex > 0){
|
||||
[sorted[steamIndex > 0 ? 1 : 0], sorted[steamIndex]] = [sorted[steamIndex], sorted[steamIndex > 0 ? 1 : 0]];
|
||||
}
|
||||
const cleanedSort = [...new Map(sorted.map(version => [`${version.BSVersion}-${version.name}-${version.steam}-${version.oculus}`, version])).values()]
|
||||
this.installedVersions$.next(cleanedSort);
|
||||
}
|
||||
|
||||
@@ -63,7 +67,7 @@ export class BSVersionManagerService {
|
||||
}
|
||||
|
||||
public isVersionInstalled(version: BSVersion): boolean{
|
||||
return !!this.getInstalledVersions().find(v => v.BSVersion === version.BSVersion && v.steam === version.steam);
|
||||
return !!this.getInstalledVersions().find(v => v.BSVersion === version.BSVersion && v.steam === version.steam && v.oculus === version.oculus);
|
||||
}
|
||||
|
||||
public getAvaibleVersionsOfYear(year: string): BSVersion[]{
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface BSVersion {
|
||||
ReleaseDate?: string,
|
||||
year?: string,
|
||||
steam?: boolean,
|
||||
oculus?: boolean,
|
||||
name?: string,
|
||||
color?: string
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
export type LaunchResult = (
|
||||
"LAUNCHED"|
|
||||
"STEAM_NOT_RUNNING"|
|
||||
"STEAM_NOT_RUNNING"|"OCULUS_NOT_RUNNING"|
|
||||
"EXE_NOT_FINDED"|
|
||||
"BS_ALREADY_RUNNING"
|
||||
)
|
||||
Reference in New Issue
Block a user