feat: create game options modal

fix error when getSteamAppDetails fails

dont set game as removed when deleting instalation folder

fix game not deleting installation folder

organize code

feat: add open game executable path and installer path
This commit is contained in:
Zamitto
2024-06-04 17:33:21 -03:00
parent 2c26fed478
commit 48b6d1c941
9 changed files with 283 additions and 1 deletions

View File

@@ -15,7 +15,10 @@ import "./library/delete-game-folder";
import "./library/get-game-by-object-id";
import "./library/get-library";
import "./library/open-game";
import "./library/open-game-executable-path";
import "./library/open-game-installer";
import "./library/open-game-installer-path";
import "./library/update-executable-path";
import "./library/remove-game";
import "./library/remove-game-from-library";
import "./misc/open-external";

View File

@@ -0,0 +1,22 @@
import { shell } from "electron";
import path from "node:path";
import { gameRepository } from "@main/repository";
import { registerEvent } from "../register-event";
const openGameExecutablePath = async (
_event: Electron.IpcMainInvokeEvent,
gameId: number
) => {
const game = await gameRepository.findOne({
where: { id: gameId, isDeleted: false },
});
if (!game || !game.executablePath) return true;
const gamePath = path.join(game.executablePath, "../");
shell.openPath(gamePath);
return true;
};
registerEvent("openGameExecutablePath", openGameExecutablePath);

View File

@@ -0,0 +1,27 @@
import { shell } from "electron";
import path from "node:path";
import { gameRepository } from "@main/repository";
import { getDownloadsPath } from "../helpers/get-downloads-path";
import { registerEvent } from "../register-event";
const openGameInstallerPath = async (
_event: Electron.IpcMainInvokeEvent,
gameId: number
) => {
const game = await gameRepository.findOne({
where: { id: gameId, isDeleted: false },
});
if (!game || !game.folderName) return true;
const gamePath = path.join(
game.downloadPath ?? (await getDownloadsPath()),
game.folderName!
);
shell.openPath(gamePath);
return true;
};
registerEvent("openGameInstallerPath", openGameInstallerPath);

View File

@@ -0,0 +1,20 @@
import { gameRepository } from "@main/repository";
import { registerEvent } from "../register-event";
const updateExecutablePath = async (
_event: Electron.IpcMainInvokeEvent,
id: number,
executablePath: string
) => {
return gameRepository.update(
{
id,
},
{
executablePath,
}
);
};
registerEvent("updateExecutablePath", updateExecutablePath);