feat: migrating games to level

This commit is contained in:
Chubby Granny Chaser 2025-01-20 10:09:49 +00:00
parent 1f0e195854
commit d760d0139d
No known key found for this signature in database
47 changed files with 219 additions and 941 deletions

View file

@ -1,22 +1,31 @@
import { gameRepository } from "@main/repository";
import { registerEvent } from "../register-event";
import { shell } from "electron";
import { parseExecutablePath } from "../helpers/parse-executable-path";
import { levelKeys } from "@main/level";
import { gamesSublevel } from "@main/level";
import { GameShop } from "@types";
const openGame = async (
_event: Electron.IpcMainInvokeEvent,
gameId: number,
shop: GameShop,
objectId: string,
executablePath: string,
launchOptions: string | null
) => {
// TODO: revisit this for launchOptions
const parsedPath = parseExecutablePath(executablePath);
await gameRepository.update(
{ id: gameId },
{ executablePath: parsedPath, launchOptions }
);
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);
};