Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/jsons/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
},
"available-versions": {
"title": "Wähle eine Version",
"title": "Eine Version herunterladen",
"steam-release": "Versionsseite",
"dropdown": {
"refresh": "Aktualisiere die Versionen",
Expand Down
2 changes: 1 addition & 1 deletion assets/jsons/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
},
"available-versions": {
"title": "Select a version",
"title": "Download a version",
"steam-release": "Release page",
"dropdown": {
"refresh": "Refresh versions",
Expand Down
2 changes: 1 addition & 1 deletion assets/jsons/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
},
"available-versions": {
"title": "Selecciona una versión",
"title": "Descargar una versión",
"steam-release": "Anuncio en Steam",
"dropdown": {
"refresh": "Actualizar las versiones",
Expand Down
2 changes: 1 addition & 1 deletion assets/jsons/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
},
"available-versions": {
"title": "Choisis une version",
"title": "Télécharger une version",
"steam-release": "Notes de version",
"dropdown": {
"refresh": "Actualiser les versions",
Expand Down
2 changes: 1 addition & 1 deletion assets/jsons/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
},
"available-versions": {
"title": "バージョンを選択",
"title": "バージョンをダウンロード",
"steam-release": "リリースページ",
"dropdown": {
"refresh": "バージョンの更新",
Expand Down
2 changes: 1 addition & 1 deletion assets/jsons/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
},
"available-versions": {
"title": "Выберите версию",
"title": "Скачать версию",
"steam-release": "Список изменений",
"dropdown": {
"refresh": "Обновить версии",
Expand Down
2 changes: 1 addition & 1 deletion assets/jsons/translations/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
},
"available-versions": {
"title": "選擇版本",
"title": "下載一個版本",
"steam-release": "發布頁面",
"dropdown": {
"refresh": "刷新版本",
Expand Down
2 changes: 1 addition & 1 deletion assets/jsons/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
}
},
"available-versions": {
"title": "选择版本",
"title": "下载一个版本",
"steam-release": "发布页面",
"dropdown": {
"refresh": "刷新版本",
Expand Down
4 changes: 4 additions & 0 deletions src/main/ipcs/static-configuration.ipcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ ipc.on("static-configuration.get", (args, reply) => {
ipc.on("static-configuration.set", (args, reply) => {
reply(from(staticConfig.set(args.key, args.value)));
});

ipc.on("static-configuration.delete", (key, reply) => {
reply(of(staticConfig.delete(key)));
});
5 changes: 5 additions & 0 deletions src/main/services/bs-launcher/bs-launcher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { OculusLauncherService } from "./oculus-launcher.service";
import { BSVersion } from "shared/bs-version.interface";
import { BsStore } from "../../../shared/models/bs-store.enum";
import { LaunchMod, LaunchMods } from "shared/models/bs-launch/launch-option.interface";
import { StaticConfigurationService } from "../static-configuration.service";

export class BSLauncherService {
private static instance: BSLauncherService;
Expand All @@ -32,6 +33,7 @@ export class BSLauncherService {
private readonly remoteVersion: BSVersionLibService;
private readonly steamLauncher: SteamLauncherService;
private readonly oculusLauncher: OculusLauncherService;
private readonly staticConfig: StaticConfigurationService;

public static getInstance(): BSLauncherService {
if (!BSLauncherService.instance) {
Expand All @@ -48,6 +50,7 @@ export class BSLauncherService {
this.remoteVersion = BSVersionLibService.getInstance();
this.steamLauncher = SteamLauncherService.getInstance();
this.oculusLauncher = OculusLauncherService.getInstance();
this.staticConfig = StaticConfigurationService.getInstance();

this.bsmProtocolService.on("launch", link => {
log.info("Launch from bsm protocol", link.toString());
Expand All @@ -73,6 +76,8 @@ export class BSLauncherService {
return throwError(() => new Error("Unable to get launcher for the provided version"));
}

this.staticConfig.set("last-version-launched", launchOptions.version);

return launcher.launch(launchOptions);
}

Expand Down
23 changes: 23 additions & 0 deletions src/main/services/bs-local-version.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Observable, Subject, catchError, finalize, from, map, switchMap, throwE
import { BsStore } from "../../shared/models/bs-store.enum";
import { CustomError } from "../../shared/models/exceptions/custom-error.class";
import crypto from "crypto";
import { StaticConfigurationService } from "./static-configuration.service";


export class BSLocalVersionService {
Expand All @@ -32,6 +33,7 @@ export class BSLocalVersionService {
private readonly remoteVersionService: BSVersionLibService;
private readonly configService: ConfigurationService;
private readonly linker: FolderLinkerService;
private readonly staticConfig: StaticConfigurationService;
private readonly _loadedVersions$: Subject<BSVersion[]>;

public static getInstance(): BSLocalVersionService {
Expand All @@ -48,6 +50,7 @@ export class BSLocalVersionService {
this.remoteVersionService = BSVersionLibService.getInstance();
this.configService = ConfigurationService.getInstance();
this.linker = FolderLinkerService.getInstance();
this.staticConfig = StaticConfigurationService.getInstance();

this._loadedVersions$ = new Subject<BSVersion[]>();
}
Expand Down Expand Up @@ -171,6 +174,24 @@ export class BSLocalVersionService {
this.setCustomVersions([...this.getCustomVersions() ?? [], version]);
}

private updateLastVersionLaunched(version: BSVersion, editedVersion: BSVersion): void {
const lastVersion = this.staticConfig.get("last-version-launched");
if (!lastVersion) {
return;
}

if (
version.BSVersion !== lastVersion.BSVersion
|| version.name !== lastVersion.name
|| version.steam !== lastVersion.steam
|| version.oculus !== lastVersion.oculus
) {
return;
}

this.staticConfig.set("last-version-launched", editedVersion);
}

private getCustomVersions(): BSVersion[]{
return this.configService.get<BSVersion[]>(this.CUSTOM_VERSIONS_KEY) || [];
}
Expand Down Expand Up @@ -317,6 +338,7 @@ export class BSLocalVersionService {
if(oldPath === newPath){
this.deleteCustomVersion(version);
this.addCustomVersion(editedVersion);
this.updateLastVersionLaunched(version, editedVersion);
return editedVersion;
}

Expand All @@ -327,6 +349,7 @@ export class BSLocalVersionService {
return rename(oldPath, newPath).then(() => {
this.deleteCustomVersion(version);
this.addCustomVersion(editedVersion);
this.updateLastVersionLaunched(version, editedVersion);
return editedVersion;
}).catch((err: Error) => {
log.error("edit version error", err, version, name, color);
Expand Down
1 change: 1 addition & 0 deletions src/main/services/static-configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface StaticConfigKeyValues {
"disable-hadware-acceleration": boolean;
"use-symlinks": boolean;
"use-system-proxy": boolean;
"last-version-launched": BSVersion;

// Linux Specific static configs
"proton-folder": string;
Expand Down
53 changes: 44 additions & 9 deletions src/renderer/services/bs-version-manager.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BSVersion } from "shared/bs-version.interface";
import { BehaviorSubject, Observable, Subscription, lastValueFrom, shareReplay, throwError } from "rxjs";
import { BehaviorSubject, Observable, Subscription, lastValueFrom, map, share, shareReplay, throwError } from "rxjs";
import { IpcService } from "./ipc.service";
import { ModalExitCode, ModalService } from "./modale.service";
import { NotificationService } from "./notification.service";
Expand All @@ -19,6 +19,7 @@ export class BSVersionManagerService {
private readonly progressBar: ProgressBarService;
private readonly modals: ModalService;

private askInstalledVersionsObserver$: Observable<BSVersion[]> | null = null;
public readonly installedVersions$: BehaviorSubject<BSVersion[]> = new BehaviorSubject([]);
public readonly availableVersions$: BehaviorSubject<BSVersion[]> = new BehaviorSubject([]);

Expand All @@ -28,7 +29,9 @@ export class BSVersionManagerService {
this.notification = NotificationService.getInstance();
this.progressBar = ProgressBarService.getInstance();
this.modals = ModalService.getInstance();
this.askAvailableVersions().then(() => this.askInstalledVersions());

this.askAvailableVersions();
this.askInstalledVersions();
}

public static getInstance() {
Expand All @@ -54,15 +57,47 @@ export class BSVersionManagerService {
});
}

public askInstalledVersions(): Promise<BSVersion[]> {
return lastValueFrom(this.ipcService.sendV2("bs-version.installed-versions")).then(res => {
this.setInstalledVersions(res);
return res;
});
public async askInstalledVersions(): Promise<BSVersion[]> {
if (this.askInstalledVersionsObserver$) {
return lastValueFrom(this.askInstalledVersionsObserver$);
}

this.askInstalledVersionsObserver$ = this.ipcService
.sendV2("bs-version.installed-versions")
.pipe(
map(versions => {
let processed = BSVersionManagerService.sortVersions(versions);
processed = BSVersionManagerService.removeDuplicateVersions(processed);
return processed;
}),
share(),
);

return lastValueFrom(this.askInstalledVersionsObserver$)
.then(versions => {
this.setInstalledVersions(versions);
return versions;
})
.finally(() => {
this.askInstalledVersionsObserver$ = null;
});
}

public isVersionInstalled(version: BSVersion): boolean {
return !!this.getInstalledVersions().find(v => v.BSVersion === version.BSVersion && v.steam === version.steam && v.oculus === version.oculus);
public async isVersionInstalled(version: BSVersion): Promise<boolean> {
try {
const versions: BSVersion[] = this.askInstalledVersionsObserver$
? await lastValueFrom(this.askInstalledVersionsObserver$)
: this.getInstalledVersions();

return !!versions.find(v =>
v.BSVersion === version.BSVersion
&& v.name === version.name
&& v.steam === version.steam
&& v.oculus === version.oculus
);
} catch (error) {
return false;
}
}

public async editVersion(version: BSVersion): Promise<BSVersion> {
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/services/static-configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ export class StaticConfigurationService {
return lastValueFrom(this.ipc.sendV2("static-configuration.set", { key, value }));
}

public delete<K extends StaticConfigKeys>(key: K): Promise<void> {
return lastValueFrom(this.ipc.sendV2("static-configuration.delete", key));
}

}
21 changes: 20 additions & 1 deletion src/renderer/windows/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { ConfigurationService } from "renderer/services/configuration.service";
import { OsDiagnosticService } from "renderer/services/os-diagnostic.service";
import { useService } from "renderer/hooks/use-service.hook";
import { SetupService } from "renderer/services/setup.service";
import { StaticConfigurationService } from "renderer/services/static-configuration.service";
import { BSVersionManagerService } from "renderer/services/bs-version-manager.service";

export default function App() {

Expand All @@ -34,17 +36,34 @@ export default function App() {
const notification = useService(NotificationService);
const config = useService(ConfigurationService);
const setup = useService(SetupService);
const staticConfig = useService(StaticConfigurationService);
const versionManager = useService(BSVersionManagerService);

const location = useLocation();
const navigate = useNavigate();

useEffect(() => {
setup.check()
.then(() => {
navigateToDefaultPage();
checkOneClicks();
})
});
}, []);

const navigateToDefaultPage = async () => {
const version = await staticConfig.get("last-version-launched");
if (!version) {
return;
}

if (!await versionManager.isVersionInstalled(version)) {
await staticConfig.delete("last-version-launched");
return;
}

navigate(`/bs-version/${version.BSVersion}`, { state: version });
};

const checkOneClicks = async () => {

if (config.get("not-remind-oneclick") === true) {
Expand Down
1 change: 1 addition & 0 deletions src/shared/models/ipc/ipc-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export interface IpcChannelMapping {
/* ** static-configuration.ipcs ** */
"static-configuration.get": StaticConfigGetIpcRequestResponse<StaticConfigKeys>;
"static-configuration.set": StaticConfigSetIpcRequest<StaticConfigKeys>;
"static-configuration.delete": { request: StaticConfigKeys; response: void };

/* ** linux.ipcs ** */
"linux.verify-proton-folder": { request: void, response: boolean };
Expand Down