[feat-578] setup protonFolder on startup

This commit is contained in:
silentrald
2024-09-22 15:21:19 +08:00
parent 0398a957ad
commit de7a054f89
19 changed files with 275 additions and 16 deletions
@@ -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"),
+36
View File
@@ -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");
}