mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: add custom launch options to game
This commit is contained in:
parent
83e662f633
commit
520eb91a55
15 changed files with 155 additions and 8 deletions
|
@ -2,18 +2,37 @@ import { gameRepository } from "@main/repository";
|
|||
|
||||
import { registerEvent } from "../register-event";
|
||||
import { shell } from "electron";
|
||||
import { exec } from "child_process";
|
||||
import { parseExecutablePath } from "../helpers/parse-executable-path";
|
||||
import { parseLaunchOptions } from "../helpers/parse-launch-options";
|
||||
import { logger } from "@main/services";
|
||||
|
||||
const openGame = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
gameId: number,
|
||||
executablePath: string
|
||||
executablePath: string,
|
||||
launchOptions: string | null
|
||||
) => {
|
||||
const parsedPath = parseExecutablePath(executablePath);
|
||||
const parsedParams = parseLaunchOptions(launchOptions);
|
||||
const executeCommand = `"${parsedPath}" ${parsedParams}`;
|
||||
|
||||
await gameRepository.update({ id: gameId }, { executablePath: parsedPath });
|
||||
|
||||
shell.openPath(parsedPath);
|
||||
if (process.platform === "linux" || process.platform === "darwin") {
|
||||
shell.openPath(parsedPath);
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
exec(executeCommand.trim(), (err) => {
|
||||
if (err) {
|
||||
logger.error(
|
||||
`Error opening game #${gameId} with command ${executeCommand}`,
|
||||
err
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("openGame", openGame);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue