mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feat-578] open steam common folder for selecting a proton folder
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { shell, dialog, app, BrowserWindow } from "electron";
|
||||
import { shell, dialog, app, BrowserWindow, OpenDialogOptions } from "electron";
|
||||
import { NotificationService } from "../services/notification.service";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { from, of } from "rxjs";
|
||||
import { readFileSync } from "fs-extra";
|
||||
import log from "electron-log";
|
||||
import path from "path";
|
||||
|
||||
// TODO IMPROVE WINDOW CONTROL BY USING WINDOW SERVICE
|
||||
|
||||
@@ -19,7 +20,20 @@ ipc.on("open-dialog", (args, reply) => {
|
||||
})
|
||||
|
||||
ipc.on("choose-folder", (args, reply) => {
|
||||
reply(from(dialog.showOpenDialog({ properties: ["openDirectory"], defaultPath: args ?? "" })));
|
||||
const options: OpenDialogOptions = {
|
||||
properties: ["openDirectory"],
|
||||
defaultPath: args?.defaultPath ?? ""
|
||||
};
|
||||
|
||||
if (args?.showHidden) {
|
||||
options.properties.push("showHiddenFiles");
|
||||
}
|
||||
|
||||
if (args?.parent) {
|
||||
options.defaultPath = path.join(app.getPath(args.parent), options.defaultPath);
|
||||
}
|
||||
|
||||
reply(from(dialog.showOpenDialog(options)));
|
||||
});
|
||||
|
||||
ipc.on("choose-file", async (args, reply) => {
|
||||
|
||||
@@ -25,7 +25,11 @@ export const LinuxSetupModal: ModalComponent<{}, {}> = ({ resolver }) => {
|
||||
}
|
||||
|
||||
const selectProtonPath = async () => {
|
||||
const response = await lastValueFrom(ipcService.sendV2("choose-folder"));
|
||||
const response = await lastValueFrom(ipcService.sendV2("choose-folder", {
|
||||
parent: "home",
|
||||
defaultPath: ".local/share/Steam/steamapps/common",
|
||||
showHidden: true,
|
||||
}));
|
||||
if (response.canceled || !response.filePaths?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,9 @@ export const ShareFoldersModal: ModalComponent<void, BSVersion> = ({ options: {d
|
||||
|
||||
const addFolder = async () => {
|
||||
const versionPath = await lastValueFrom(versionManager.getVersionPath(data));
|
||||
const folder = await lastValueFrom(ipc.sendV2("choose-folder", versionPath));
|
||||
const folder = await lastValueFrom(ipc.sendV2("choose-folder", {
|
||||
defaultPath: versionPath
|
||||
}));
|
||||
|
||||
if (!folder || folder.canceled || !folder.filePaths?.length) {
|
||||
return;
|
||||
|
||||
@@ -185,7 +185,11 @@ export function SettingsPage() {
|
||||
}
|
||||
|
||||
try {
|
||||
const pathResponse = await lastValueFrom(ipcService.sendV2("choose-folder"));
|
||||
const pathResponse = await lastValueFrom(ipcService.sendV2("choose-folder", {
|
||||
parent: "home",
|
||||
defaultPath: ".local/share/Steam/steamapps/common",
|
||||
showHidden: true,
|
||||
}));
|
||||
if (
|
||||
pathResponse.canceled
|
||||
|| !pathResponse.filePaths
|
||||
|
||||
@@ -124,7 +124,7 @@ export interface IpcChannelMapping {
|
||||
/* ** os-controls-ipcs ** */
|
||||
"new-window": { request: string, response: void };
|
||||
"open-dialog": { request: OpenDialogOptions, response: OpenDialogReturnValue };
|
||||
"choose-folder": { request: string, response: OpenDialogReturnValue };
|
||||
"choose-folder": { request: { defaultPath?: string, parent?: "home", showHidden?: boolean }, response: OpenDialogReturnValue };
|
||||
"choose-file": { request: string, response: OpenDialogReturnValue }
|
||||
"choose-image": { request: { multiple?: boolean, base64?: boolean }, response: string[] }
|
||||
"window.progression": { request: number, response: void };
|
||||
|
||||
Reference in New Issue
Block a user