Files
hydra/src/main/events/library/open-game.ts
Chubby Granny Chaser 0f0a67b55e chore: merge with main
2025-01-21 10:44:43 +00:00

33 lines
819 B
TypeScript

import { registerEvent } from "../register-event";
import { shell } from "electron";
import { parseExecutablePath } from "../helpers/parse-executable-path";
import { gamesSublevel, levelKeys } from "@main/level";
import { GameShop } from "@types";
const openGame = async (
_event: Electron.IpcMainInvokeEvent,
shop: GameShop,
objectId: string,
executablePath: string,
launchOptions?: string | null
) => {
// TODO: revisit this for launchOptions
const parsedPath = parseExecutablePath(executablePath);
const gameKey = levelKeys.game(shop, objectId);
const game = await gamesSublevel.get(gameKey);
if (!game) return;
await gamesSublevel.put(gameKey, {
...game,
executablePath: parsedPath,
launchOptions,
});
shell.openPath(parsedPath);
};
registerEvent("openGame", openGame);