diff --git a/src/main/events/helpers/parse-launch-options.ts b/src/main/events/helpers/parse-launch-options.ts new file mode 100644 index 00000000..5db89567 --- /dev/null +++ b/src/main/events/helpers/parse-launch-options.ts @@ -0,0 +1,7 @@ +export const parseLaunchOptions = (params: string | null): string[] => { + if (!params) { + return []; + } + + return params.split(" "); +}; diff --git a/src/main/events/library/open-game.ts b/src/main/events/library/open-game.ts index cf73c810..736fde96 100644 --- a/src/main/events/library/open-game.ts +++ b/src/main/events/library/open-game.ts @@ -2,7 +2,9 @@ import { gameRepository } from "@main/repository"; import { registerEvent } from "../register-event"; import { shell } from "electron"; +import { spawn } from "child_process"; import { parseExecutablePath } from "../helpers/parse-executable-path"; +import { parseLaunchOptions } from "../helpers/parse-launch-options"; const openGame = async ( _event: Electron.IpcMainInvokeEvent, @@ -10,15 +12,20 @@ const openGame = async ( executablePath: string, launchOptions: string | null ) => { - // TODO: revisit this for launchOptions const parsedPath = parseExecutablePath(executablePath); + const parsedParams = parseLaunchOptions(launchOptions); await gameRepository.update( { id: gameId }, { executablePath: parsedPath, launchOptions } ); - shell.openPath(parsedPath); + if (parsedParams.length === 0) { + shell.openPath(parsedPath); + return; + } + + spawn(parsedPath, parsedParams, { shell: false, detached: true }); }; registerEvent("openGame", openGame); 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 b06de28a..10a2aeb2 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 @@ -169,8 +169,6 @@ export function GameOptionsModal({ } }; - const shouldShowLaunchOptionsConfiguration = false; - return ( <> )} - {shouldShowLaunchOptionsConfiguration && ( +

{t("launch_options")}

{t("launch_options_description")}

- - {t("clear")} - - ) - } - />
- )} + + + {t("clear")} + + ) + } + /> +

{t("downloads_secion_title")}