mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feat-578] setup protonFolder on startup
This commit is contained in:
@@ -16,3 +16,12 @@ export const CACHE_PATH = path.join(app.getPath("userData"), "CachedData");
|
||||
export const IMAGE_CACHE_PATH = path.join(CACHE_PATH, "imagescache");
|
||||
|
||||
export const HTTP_STATUS_CODES = constants;
|
||||
|
||||
// Linux related stuff
|
||||
|
||||
export const PROTON_BINARY_PREFIX = "proton";
|
||||
export const WINE_BINARY_PREFIX = path.join(
|
||||
"files", "bin", "wine"
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -14,3 +14,4 @@ import "./model-saber.ipcs";
|
||||
import "./bs-model-ipcs";
|
||||
import "./bs-version-download/bs-download-ipcs";
|
||||
import "./static-configuration.ipcs";
|
||||
import "./linux.ipcs.ts";
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { LinuxService } from "main/services/linux.service";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { of } from "rxjs";
|
||||
|
||||
const ipc = IpcService.getInstance();
|
||||
const linuxService = LinuxService.getInstance();
|
||||
|
||||
ipc.on("linux.verify-proton-folder", (_, reply) => {
|
||||
reply(of(linuxService.verifyProtonPath()));
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { StoreLauncherInterface } from "./store-launcher.interface";
|
||||
import { pathExists, pathExistsSync, rename } from "fs-extra";
|
||||
import { SteamService } from "../steam.service";
|
||||
import path from "path";
|
||||
import { BS_APP_ID, BS_EXECUTABLE, STEAMVR_APP_ID } from "../../constants";
|
||||
import { BS_APP_ID, BS_EXECUTABLE, PROTON_BINARY_PREFIX, STEAMVR_APP_ID } from "../../constants";
|
||||
import log from "electron-log";
|
||||
import { AbstractLauncherService } from "./abstract-launcher.service";
|
||||
import { CustomError } from "../../../shared/models/exceptions/custom-error.class";
|
||||
@@ -135,7 +135,7 @@ export class SteamLauncherService extends AbstractLauncherService implements Sto
|
||||
if (!this.staticConfig.has("proton-folder")) {
|
||||
throw CustomError.fromError(new Error("Proton folder not set"), BSLaunchError.PROTON_NOT_SET);
|
||||
}
|
||||
exePath = path.join(this.staticConfig.get("proton-folder"), "proton");
|
||||
exePath = path.join(this.staticConfig.get("proton-folder"), PROTON_BINARY_PREFIX);
|
||||
if (!pathExistsSync(exePath)) {
|
||||
throw CustomError.fromError(
|
||||
new Error("Could not locate proton binary"),
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import path from "path";
|
||||
import { StaticConfigurationService } from "./static-configuration.service";
|
||||
import { pathExistsSync } from "fs-extra";
|
||||
import { PROTON_BINARY_PREFIX, WINE_BINARY_PREFIX } from "main/constants";
|
||||
|
||||
|
||||
// Linux handling
|
||||
export class LinuxService {
|
||||
private static instance: LinuxService;
|
||||
|
||||
public static getInstance(): LinuxService {
|
||||
if (!LinuxService.instance) {
|
||||
LinuxService.instance = new LinuxService();
|
||||
}
|
||||
return LinuxService.instance;
|
||||
}
|
||||
|
||||
private readonly staticConfig: StaticConfigurationService;
|
||||
|
||||
private constructor() {
|
||||
this.staticConfig = StaticConfigurationService.getInstance();
|
||||
}
|
||||
|
||||
public verifyProtonPath(): boolean {
|
||||
if (!this.staticConfig.has("proton-folder")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const protonFolder = this.staticConfig.get("proton-folder");
|
||||
const protonPath = path.join(protonFolder, PROTON_BINARY_PREFIX);
|
||||
const winePath = path.join(protonFolder, WINE_BINARY_PREFIX);
|
||||
|
||||
return pathExistsSync(protonPath) && pathExistsSync(winePath);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import path from "path";
|
||||
import md5File from "md5-file";
|
||||
import { RequestService } from "../request.service";
|
||||
import { spawn } from "child_process";
|
||||
import { BS_EXECUTABLE } from "../../constants";
|
||||
import { BS_EXECUTABLE, WINE_BINARY_PREFIX } from "../../constants";
|
||||
import log from "electron-log";
|
||||
import { deleteFolder, pathExist, Progression, unlinkPath } from "../../helpers/fs.helpers";
|
||||
import { lastValueFrom, Observable } from "rxjs";
|
||||
@@ -153,7 +153,7 @@ export class BsModsManagerService {
|
||||
|
||||
winePath = path.join(
|
||||
this.staticConfig.get("proton-folder"),
|
||||
"files", "bin", "wine"
|
||||
WINE_BINARY_PREFIX
|
||||
);
|
||||
|
||||
if (!pathExistsSync(winePath)) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import ElectronStore from "electron-store";
|
||||
import { pathExistsSync } from "fs-extra";
|
||||
import path from "path";
|
||||
import { PROTON_BINARY_PREFIX, WINE_BINARY_PREFIX } from "main/constants";
|
||||
import { Observable, Subject } from "rxjs";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { CustomError } from "shared/models/exceptions/custom-error.class";
|
||||
@@ -58,8 +59,8 @@ export class StaticConfigurationService {
|
||||
// Setters with validation
|
||||
|
||||
private validateProtonFolder(protonFolder: string): void {
|
||||
const protonPath = path.join(protonFolder, "proton");
|
||||
const winePath = path.join(protonFolder, "files", "bin", "wine");
|
||||
const protonPath = path.join(protonFolder, PROTON_BINARY_PREFIX);
|
||||
const winePath = path.join(protonFolder, WINE_BINARY_PREFIX);
|
||||
if (!pathExistsSync(protonPath) || !pathExistsSync(winePath)) {
|
||||
throw new CustomError("Invalid proton folder path", "invalid-folder");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user