add possibility to change installations folder

This commit is contained in:
MathieuG-P
2022-06-25 03:46:10 +02:00
parent ce768f6b8e
commit 0b50aa35f9
13 changed files with 190 additions and 36 deletions
@@ -0,0 +1,22 @@
import { BsmButton } from "renderer/components/shared/bsm-button.component";
import { BsmImage } from "renderer/components/shared/bsm-image.component";
import { ModalExitCode, ModalResponse } from "renderer/services/modale.service";
import BeatConflict from "../../../../../assets/beat-conflict.png"
export function InstallationFolderModal({resolver}: {resolver: (x: ModalResponse) => void}) {
return (
<>
<span className="absolute bg-gradient-to-r from-blue-500 to-red-500 top-0 w-full left-0 h-1"></span>
<h1 className="text-3xl uppercase tracking-wide w-full text-center">installation folder</h1>
<BsmImage className="mx-auto h-24" image={BeatConflict}/>
<p className="max-w-sm">Changing the default installation folder for Beat Saber instances will cause all installed data to be moved to the new folder.</p>
<div className="grid grid-flow-col grid-cols-2 gap-4 mt-4">
<BsmButton className="rounded-md text-center bg-gray-500 hover:brightness-110 transition-all" onClick={() => resolver({exitCode: ModalExitCode.CANCELED})} withBar={false} text="Cancel"/>
<BsmButton className="rounded-md text-center bg-blue-500 hover:brightness-110 transition-all" onClick={() => resolver({exitCode: ModalExitCode.COMPLETED})} withBar={false} text="Choose Folder"/>
</div>
</>
)
}
@@ -1,7 +1,9 @@
import { BehaviorSubject } from 'rxjs';
import { IpcResponse } from 'shared/models/ipc-models.model';
import { DownloadInfo } from '../../main/ipcs/bs-download-ipcs';
import { BSVersion } from '../../main/services/bs-version-manager.service'
import { BSVersionManagerService } from './bs-version-manager.service';
import { IpcService } from './ipc.service';
import { ModalExitCode, ModalService, ModalType } from './modale.service';
export class BsDownloaderService{
@@ -9,6 +11,7 @@ export class BsDownloaderService{
private static instance: BsDownloaderService;
private readonly modalService: ModalService = ModalService.getInsance();
private readonly ipcService: IpcService;
private readonly bsVersionManager: BSVersionManagerService = BSVersionManagerService.getInstance();
public readonly currentBsVersionDownload$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
@@ -16,6 +19,7 @@ export class BsDownloaderService{
public readonly selectedBsVersion$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
public static getInstance(): BsDownloaderService{
if(!BsDownloaderService.instance){ BsDownloaderService.instance = new BsDownloaderService(); }
return BsDownloaderService.instance;
@@ -23,6 +27,7 @@ export class BsDownloaderService{
private constructor(){
this.asignListerners();
this.ipcService = IpcService.getInstance();
}
private asignListerners(): void{
@@ -81,4 +86,13 @@ export class BsDownloaderService{
return !!this.currentBsVersionDownload$.value || !!this.downloadProgress$.value;
}
public async getInstallationFolder(): Promise<string>{
const res = await this.ipcService.send<string>("bs-download.installation-folder");
return res.success ? res.data : "";
}
public setInstallationFolder(path: string): Promise<IpcResponse<string>>{
return this.ipcService.send<string>("bs-download.set-installation-folder", {args: path});
}
}
+1
View File
@@ -52,6 +52,7 @@ export enum ModalType {
STEAM_LOGIN = "STEAM_LOGIN",
GUARD_CODE = "GUARD_CODE",
UNINSTALL = "UNINSTALL",
INSTALLATION_FOLDER = "INSTALLATION_FOLDER",
}
export enum ModalExitCode {