diff --git a/src/renderer/src/context/game-details/game-details.context.tsx b/src/renderer/src/context/game-details/game-details.context.tsx index 9242d9a6a..62ab3f93c 100644 --- a/src/renderer/src/context/game-details/game-details.context.tsx +++ b/src/renderer/src/context/game-details/game-details.context.tsx @@ -222,8 +222,11 @@ export function GameDetailsContextProvider({ return window.electron.getDefaultDownloadsPath(); }; - const selectGameExecutable = async () => { - const downloadsPath = await getDownloadsPath(); + const selectGameExecutable = async ( + gameInstallerFolderIfExists?: string + ) => { + const downloadsPath = + gameInstallerFolderIfExists ?? (await getDownloadsPath()); return window.electron .showOpenDialog({ diff --git a/src/renderer/src/context/game-details/game-details.context.types.ts b/src/renderer/src/context/game-details/game-details.context.types.ts index 49718430f..7584d9018 100644 --- a/src/renderer/src/context/game-details/game-details.context.types.ts +++ b/src/renderer/src/context/game-details/game-details.context.types.ts @@ -24,7 +24,9 @@ export interface GameDetailsContext { hasNSFWContentBlocked: boolean; lastDownloadedOption: GameRepack | null; setGameColor: React.Dispatch>; - selectGameExecutable: () => Promise; + selectGameExecutable: ( + gameInstallerFolderIfExists?: string + ) => Promise; updateGame: () => Promise; setShowRepacksModal: React.Dispatch>; setShowGameOptionsModal: React.Dispatch>; diff --git a/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx b/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx index 7027d1139..591384523 100644 --- a/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx +++ b/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx @@ -5,7 +5,7 @@ import { PlusCircleIcon, } from "@primer/octicons-react"; import { Button } from "@renderer/components"; -import { useDownload, useLibrary } from "@renderer/hooks"; +import { useAppSelector, useDownload, useLibrary } from "@renderer/hooks"; import { useContext, useState } from "react"; import { useTranslation } from "react-i18next"; import * as styles from "./hero-panel-actions.css"; @@ -18,6 +18,10 @@ export function HeroPanelActions() { const { isGameDeleting } = useDownload(); + const userPreferences = useAppSelector( + (state) => state.userPreferences.value + ); + const { game, repacks, @@ -63,7 +67,25 @@ export function HeroPanelActions() { return; } - const gameExecutablePath = await selectGameExecutable(); + let gameInstallerFolderIfExists + + if (game && game.folderName) { + let downloadsPath = await window.electron.getDefaultDownloadsPath(); + if (userPreferences?.downloadsPath) + downloadsPath = userPreferences.downloadsPath; + + const folderSeparator = + window.electron.platform == "win32" ? "\\" : "/"; + + gameInstallerFolderIfExists = + (game.downloadPath ?? downloadsPath) + + folderSeparator + + game.folderName!; + } + + const gameExecutablePath = await selectGameExecutable( + gameInstallerFolderIfExists + ); if (gameExecutablePath) window.electron.openGame( game.id,