mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f71d3006c | |||
| 120470de5e | |||
| 8efe5be63f | |||
| 7378b234eb | |||
| d256f2989f | |||
| 85d43639af | |||
| f849b0d570 | |||
| 34936f6666 | |||
| d8a4889298 | |||
| 21c7f9d225 | |||
| 1048ca6b9b |
@@ -218,7 +218,7 @@ https://user-images.githubusercontent.com/40648115/213435051-7feb815d-f32b-4135-
|
||||
<div>
|
||||
<h1><b>Credits</b></h1>
|
||||
<ul>
|
||||
<li><a href="https://github.com/Zagrios">Zagrios</a> - Founder & Lead Developer (Mathieu GRIES)</li>
|
||||
<li><a href="https://github.com/Zagrios">Zagrios</a> - Founder & Lead Developer</li>
|
||||
<li><a href="https://github.com/Iluhadesu">Iluhadesu</a> - Project Team & Developpement help</li>
|
||||
<li><a href="https://github.com/GaetanGrd">GaetanGrd</a> - Project Team & Developpement help</li>
|
||||
<li><a href="https://github.com/cheddZy">cheddZy</a> - Icon creator</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bs-manager",
|
||||
"version": "1.3.1-alpha.1",
|
||||
"version": "1.3.1-alpha.2",
|
||||
"description": "BSManager",
|
||||
"main": "./dist/main/main.js",
|
||||
"author": {
|
||||
|
||||
@@ -80,7 +80,7 @@ export class BSLauncherService {
|
||||
}
|
||||
|
||||
private buildBsLaunchArgs(launchOptions: LaunchOption): string[]{
|
||||
const launchArgs = [];
|
||||
const launchArgs = ["--no-yeet"];
|
||||
|
||||
if (launchOptions.oculus) {
|
||||
launchArgs.push("-vrmode");
|
||||
|
||||
@@ -38,11 +38,11 @@ export class InstallationLocationService {
|
||||
}
|
||||
|
||||
public async setInstallationDirectory(newDir: string): Promise<string> {
|
||||
newDir = path.basename(newDir) === this.INSTALLATION_FOLDER ? newDir : path.join(newDir, this.INSTALLATION_FOLDER);
|
||||
newDir = path.basename(newDir) === this.INSTALLATION_FOLDER ? path.join(newDir, "..") : newDir;
|
||||
const oldDir = await this.installationDirectory();
|
||||
|
||||
await ensureFolderExist(oldDir);
|
||||
await copyDirectoryWithJunctions(oldDir, newDir, { overwrite: true });
|
||||
await copyDirectoryWithJunctions(oldDir, path.join(newDir, this.INSTALLATION_FOLDER), { overwrite: true });
|
||||
|
||||
this._installationDirectory = newDir;
|
||||
this.installPathConfig.set(this.STORE_INSTALLATION_PATH_KEY, newDir);
|
||||
@@ -57,23 +57,27 @@ export class InstallationLocationService {
|
||||
}
|
||||
|
||||
public async installationDirectory(): Promise<string> {
|
||||
if(this._installationDirectory) {
|
||||
return this._installationDirectory;
|
||||
}
|
||||
|
||||
if(this.installPathConfig.has(this.STORE_INSTALLATION_PATH_KEY)) {
|
||||
this._installationDirectory = this.installPathConfig.get(this.STORE_INSTALLATION_PATH_KEY) as string;
|
||||
return this._installationDirectory;
|
||||
}
|
||||
|
||||
const oldPath = path.join(app.getPath("documents"), this.INSTALLATION_FOLDER);
|
||||
if(await pathExist(oldPath)){
|
||||
this._installationDirectory = oldPath;
|
||||
return this._installationDirectory;
|
||||
}
|
||||
const installParentPath = async () => {
|
||||
if(this._installationDirectory) {
|
||||
return this._installationDirectory;
|
||||
}
|
||||
|
||||
this._installationDirectory = path.join(app.getPath("home"), this.INSTALLATION_FOLDER);
|
||||
return this._installationDirectory;
|
||||
if(this.installPathConfig.has(this.STORE_INSTALLATION_PATH_KEY)) {
|
||||
return this.installPathConfig.get(this.STORE_INSTALLATION_PATH_KEY) as string;
|
||||
}
|
||||
|
||||
const oldPath = path.join(app.getPath("documents"), this.INSTALLATION_FOLDER);
|
||||
if(await pathExist(oldPath)){
|
||||
return app.getPath("documents");
|
||||
}
|
||||
|
||||
return app.getPath("home");
|
||||
};
|
||||
|
||||
this._installationDirectory = await installParentPath();
|
||||
|
||||
return path.join(this._installationDirectory, this.INSTALLATION_FOLDER);
|
||||
}
|
||||
|
||||
public async versionsDirectory(): Promise<string> {
|
||||
|
||||
@@ -20,13 +20,13 @@ export class LivService {
|
||||
|
||||
}
|
||||
|
||||
public isLivInstalled(): Promise<boolean> {
|
||||
public async isLivInstalled(): Promise<boolean> {
|
||||
return execOnOs({
|
||||
win32: async () => {
|
||||
const regRes = await regedit.promisified.list([this.livRegeditKey]).then(res => res[this.livRegeditKey]);
|
||||
return regRes?.exists;
|
||||
}
|
||||
});
|
||||
},
|
||||
}, true);
|
||||
}
|
||||
|
||||
public async createLivShortcut(entry: LivEntry): Promise<void> {
|
||||
|
||||
@@ -30,7 +30,7 @@ export function NavBar() {
|
||||
|
||||
if (downloadingVersion){ versions.push(downloadingVersion); }
|
||||
|
||||
const sorted = versions.sort((a, b) => +b.ReleaseDate - +a.ReleaseDate);
|
||||
const sorted = BSVersionManagerService.sortVersions(versions);
|
||||
|
||||
return BSVersionManagerService.removeDuplicateVersions(sorted);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ModalExitCode, ModalService } from "./modale.service";
|
||||
import { NotificationService } from "./notification.service";
|
||||
import { ProgressBarService } from "./progress-bar.service";
|
||||
import { EditVersionModal } from "renderer/components/modal/modal-types/edit-version-modal.component";
|
||||
import { swapElements } from "shared/helpers/array.helpers";
|
||||
import { popElement } from "shared/helpers/array.helpers";
|
||||
|
||||
export class BSVersionManagerService {
|
||||
private static instance: BSVersionManagerService;
|
||||
@@ -34,18 +34,7 @@ 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) {
|
||||
swapElements(steamIndex, 0, sorted);
|
||||
}
|
||||
if (oculusIndex > 0) {
|
||||
swapElements(oculusIndex, steamIndex >= 0 ? 1 : 0, sorted);
|
||||
}
|
||||
|
||||
const sorted = BSVersionManagerService.sortVersions(versions);
|
||||
this.installedVersions$.next(BSVersionManagerService.removeDuplicateVersions(sorted));
|
||||
}
|
||||
|
||||
@@ -123,6 +112,19 @@ export class BSVersionManagerService {
|
||||
return this.ipcService.sendV2("get-version-full-path", { args: version });
|
||||
}
|
||||
|
||||
public static sortVersions(versions: BSVersion[]): BSVersion[] {
|
||||
const steamVersion = popElement(v => v.steam, versions);
|
||||
const oculusVersion = popElement(v => v.oculus, versions);
|
||||
|
||||
const compare = (a: BSVersion, b: BSVersion) => ( +b.ReleaseDate - +a.ReleaseDate )
|
||||
|
||||
const sorted: BSVersion[] = versions.sort(compare);
|
||||
|
||||
sorted.unshift(...[steamVersion, oculusVersion].filter(Boolean).sort(compare));
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
public static removeDuplicateVersions(versions: BSVersion[]): BSVersion[] {
|
||||
return Array.from(new Map(versions.map(version => ([
|
||||
JSON.stringify([
|
||||
|
||||
@@ -10,3 +10,11 @@ export function swapElements<T = unknown>(from: number, to: number, arr: T[]): T
|
||||
[arr[from], arr[to]] = [arr[to], arr[from]];
|
||||
return arr;
|
||||
}
|
||||
|
||||
export function popElement<T = unknown>(func: (element: T) => boolean, arr: T[]): T {
|
||||
const index = arr.findIndex(func);
|
||||
if (index === -1) {
|
||||
return null;
|
||||
}
|
||||
return arr.splice(index, 1)[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user