diff --git a/src/main/events/library/create-steam-shortcut.ts b/src/main/events/library/create-steam-shortcut.ts index 436d4ac1..df139403 100644 --- a/src/main/events/library/create-steam-shortcut.ts +++ b/src/main/events/library/create-steam-shortcut.ts @@ -61,36 +61,30 @@ const createSteamShortcut = async ( return; } + const icon = await downloadAsset( + path.join( + SystemPath.getPath("userData"), + "Icons", + `${game.shop}-${game.objectId}.ico` + ), + assets?.iconUrl + ); + + const newShortcut = composeSteamShortcut( + game.title, + game.executablePath, + icon + ); + for (const steamUserId of steamUserIds) { logger.info("Adding shortcut for Steam user", steamUserId); const steamShortcuts = await getSteamShortcuts(steamUserId); - if ( - steamShortcuts.some( - (shortcut) => - shortcut.Exe === game.executablePath && - shortcut.appname === game.title - ) - ) { + if (steamShortcuts.some((shortcut) => shortcut.appname === game.title)) { continue; } - const icon = await downloadAsset( - path.join( - SystemPath.getPath("userData"), - "Icons", - `${game.shop}-${game.objectId}.ico` - ), - assets?.iconUrl - ); - - const newShortcut = composeSteamShortcut( - game.title, - game.executablePath, - icon - ); - const gridPath = path.join( await getSteamLocation(), "userdata", @@ -127,6 +121,26 @@ const createSteamShortcut = async ( await writeSteamShortcuts(steamUserId, steamShortcuts); } + + if (process.platform === "linux" && !game.winePrefixPath) { + const steamWinePrefixes = path.join( + SystemPath.getPath("home"), + ".local", + "share", + "Steam", + "steamapps", + "compatdata" + ); + + await gamesSublevel.put(gameKey, { + ...game, + winePrefixPath: path.join( + steamWinePrefixes, + newShortcut.appid.toString(), + "pfx" + ), + }); + } } }; diff --git a/src/main/events/library/get-default-wine-prefix-selection-path.ts b/src/main/events/library/get-default-wine-prefix-selection-path.ts index 94f57d38..67f5a82e 100644 --- a/src/main/events/library/get-default-wine-prefix-selection-path.ts +++ b/src/main/events/library/get-default-wine-prefix-selection-path.ts @@ -16,11 +16,7 @@ const getDefaultWinePrefixSelectionPath = async ( "compatdata" ); - if (fs.existsSync(steamWinePrefixes)) { - return fs.promises.realpath(steamWinePrefixes); - } - - return null; + return await fs.promises.realpath(steamWinePrefixes); } catch (err) { logger.error("Failed to get default wine prefix selection path", err); diff --git a/src/renderer/src/pages/game-details/modals/game-options-modal.tsx b/src/renderer/src/pages/game-details/modals/game-options-modal.tsx index 2087e264..6ccfb627 100644 --- a/src/renderer/src/pages/game-details/modals/game-options-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/game-options-modal.tsx @@ -119,6 +119,8 @@ export function GameOptionsModal({ t("create_shortcut_success"), t("you_might_need_to_restart_steam") ); + + updateGame(); } catch (error: unknown) { logger.error("Failed to create Steam shortcut", error); showErrorToast(t("create_shortcut_error")); @@ -162,9 +164,12 @@ export function GameOptionsModal({ }; const handleChangeWinePrefixPath = async () => { + const defaultPath = + await window.electron.getDefaultWinePrefixSelectionPath(); + const { filePaths } = await window.electron.showOpenDialog({ properties: ["openDirectory"], - defaultPath: await window.electron.getDefaultWinePrefixSelectionPath(), + defaultPath: defaultPath ?? game?.winePrefixPath ?? "", }); if (filePaths && filePaths.length > 0) {