mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Compare commits
17 Commits
v1.3.1-alpha.1
...
v1.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
| d61f59c714 | |||
| 64e3652b60 | |||
| 6f018e6a32 | |||
| da3b2b13a8 | |||
| 381daa80a4 | |||
| bdfe8ce535 | |||
| 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>
|
||||
|
||||
Generated
+7
-8
@@ -24,6 +24,7 @@
|
||||
"history": "^5.3.0",
|
||||
"jszip": "^3.10.1",
|
||||
"md5-file": "^5.0.0",
|
||||
"node-abi": "^3.47.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"ps-list": "^7.2.0",
|
||||
@@ -13509,10 +13510,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/node-abi": {
|
||||
"version": "3.28.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.28.0.tgz",
|
||||
"integrity": "sha512-fRlDb4I0eLcQeUvGq7IY3xHrSb0c9ummdvDSYWfT9+LKP+3jCKw/tKoqaM7r1BAoiAC6GtwyjaGnOz6B3OtF+A==",
|
||||
"dev": true,
|
||||
"version": "3.47.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.47.0.tgz",
|
||||
"integrity": "sha512-2s6B2CWZM//kPgwnuI0KrYwNjfdByE25zvAaEpq9IH4zcNsarH8Ihu/UuX6XMPEogDAxkuUFeZn60pXNHAqn3A==",
|
||||
"dependencies": {
|
||||
"semver": "^7.3.5"
|
||||
},
|
||||
@@ -29518,10 +29518,9 @@
|
||||
}
|
||||
},
|
||||
"node-abi": {
|
||||
"version": "3.28.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.28.0.tgz",
|
||||
"integrity": "sha512-fRlDb4I0eLcQeUvGq7IY3xHrSb0c9ummdvDSYWfT9+LKP+3jCKw/tKoqaM7r1BAoiAC6GtwyjaGnOz6B3OtF+A==",
|
||||
"dev": true,
|
||||
"version": "3.47.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.47.0.tgz",
|
||||
"integrity": "sha512-2s6B2CWZM//kPgwnuI0KrYwNjfdByE25zvAaEpq9IH4zcNsarH8Ihu/UuX6XMPEogDAxkuUFeZn60pXNHAqn3A==",
|
||||
"requires": {
|
||||
"semver": "^7.3.5"
|
||||
}
|
||||
|
||||
@@ -244,6 +244,7 @@
|
||||
"history": "^5.3.0",
|
||||
"jszip": "^3.10.1",
|
||||
"md5-file": "^5.0.0",
|
||||
"node-abi": "^3.47.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"ps-list": "^7.2.0",
|
||||
|
||||
Generated
+855
-246
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bs-manager",
|
||||
"version": "1.3.1-alpha.1",
|
||||
"version": "1.3.1",
|
||||
"description": "BSManager",
|
||||
"main": "./dist/main/main.js",
|
||||
"author": {
|
||||
@@ -14,8 +14,8 @@
|
||||
"postinstall": "npm run electron-rebuild && npm run link-modules"
|
||||
},
|
||||
"dependencies": {
|
||||
"@resvg/resvg-js": "^2.4.1",
|
||||
"ps-list": "^7.2.0"
|
||||
"ps-list": "^7.2.0",
|
||||
"sharp": "^0.32.6"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import log from "electron-log";
|
||||
import { Observable, of } from "rxjs";
|
||||
import { BsmProtocolService } from "./bsm-protocol.service";
|
||||
import { app, shell} from "electron";
|
||||
import { Resvg } from "@resvg/resvg-js";
|
||||
import Color from "color";
|
||||
import { ensureDir, writeFile } from "fs-extra";
|
||||
import toIco from "to-ico";
|
||||
@@ -20,6 +19,7 @@ import { WindowManagerService } from "./window-manager.service";
|
||||
import { IpcService } from "./ipc.service";
|
||||
import { BSVersionLibService } from "./bs-version-lib.service";
|
||||
import { execOnOs } from "../helpers/env.helpers";
|
||||
import sharp from "sharp";
|
||||
|
||||
export class BSLauncherService {
|
||||
private static instance: BSLauncherService;
|
||||
@@ -80,7 +80,7 @@ export class BSLauncherService {
|
||||
}
|
||||
|
||||
private buildBsLaunchArgs(launchOptions: LaunchOption): string[]{
|
||||
const launchArgs = [];
|
||||
const launchArgs = ["--no-yeet"];
|
||||
|
||||
if (launchOptions.oculus) {
|
||||
launchArgs.push("-vrmode");
|
||||
@@ -161,7 +161,7 @@ export class BSLauncherService {
|
||||
bsProcess.removeAllListeners("error");
|
||||
bsProcess.removeAllListeners("exit");
|
||||
resolve(-1);
|
||||
}, 15_000);
|
||||
}, 30_000);
|
||||
|
||||
}).then(exitCode => {
|
||||
log.info("BS process exit code", exitCode);
|
||||
@@ -224,19 +224,16 @@ export class BSLauncherService {
|
||||
return res;
|
||||
}
|
||||
|
||||
private createShortcutPngBuffer(color: Color): Buffer{
|
||||
private createShortcutPngBuffer(color: Color): Promise<Buffer>{
|
||||
|
||||
const svgIcon = `
|
||||
const svgBuffer = Buffer.from(`
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 406.4 406.4" height="406.4" width="406.4">
|
||||
<rect rx="69.453" height="406.4" width="406.4" fill="${color.hex()}"/>
|
||||
<path d="M65.467 60.6H336.4v33.867L200.933 162.2 65.467 94.467z" fill="#fff"/>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
return new Resvg(svgIcon, {
|
||||
fitTo: { mode: "width", value: 256 }
|
||||
}).render().asPng();
|
||||
`);
|
||||
|
||||
return sharp(svgBuffer).resize(256).png().toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +259,7 @@ export class BSLauncherService {
|
||||
* @returns {Promise<string>} Path of the icon
|
||||
*/
|
||||
private async createShortcutIco(color: Color): Promise<string>{
|
||||
const pngBuffer = this.createShortcutPngBuffer(color);
|
||||
const pngBuffer = await this.createShortcutPngBuffer(color);
|
||||
const icoBuffer = await toIco([pngBuffer]);
|
||||
|
||||
await ensureDir(IMAGE_CACHE_PATH);
|
||||
|
||||
@@ -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