mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
oculus detection complete
This commit is contained in:
@@ -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."
|
||||
|
||||
@@ -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,6 +35,7 @@ export class BSLauncherService{
|
||||
}
|
||||
|
||||
public async launch(launchOptions: LauchOption): Promise<LaunchResult>{
|
||||
if(launchOptions.version.oculus && !this.oculusService.oculusRunning()){ return "OCULUS_NOT_RUNNING" }
|
||||
if(!this.steamService.steamRunning()){ return "STEAM_NOT_RUNNING" }
|
||||
if(this.isBsRunning()){ return "BS_ALREADY_RUNNING" }
|
||||
|
||||
@@ -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 **/ });
|
||||
|
||||
@@ -154,7 +154,7 @@ export class BSLocalVersionService{
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
@@ -164,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}
|
||||
@@ -192,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){
|
||||
|
||||
@@ -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[]{
|
||||
|
||||
@@ -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