feat: adding possibility to create steam shortcut

This commit is contained in:
Chubby Granny Chaser
2025-05-13 22:57:33 +01:00
parent 00065ab0c9
commit 86de5aa89e
14 changed files with 342 additions and 24 deletions

View File

@@ -180,6 +180,7 @@ declare global {
cb: (shop: GameShop, objectId: string) => void
) => () => Electron.IpcRenderer;
getDefaultWinePrefixSelectionPath: () => Promise<string | null>;
createSteamShortcut: (shop: GameShop, objectId: string) => Promise<void>;
/* Download sources */
putDownloadSource: (

View File

@@ -8,8 +8,10 @@ import { useDownload, useToast, useUserDetails } from "@renderer/hooks";
import { RemoveGameFromLibraryModal } from "./remove-from-library-modal";
import { ResetAchievementsModal } from "./reset-achievements-modal";
import { FileDirectoryIcon, FileIcon } from "@primer/octicons-react";
import SteamLogo from "@renderer/assets/steam-logo.svg?react";
import { debounce } from "lodash-es";
import "./game-options-modal.scss";
import { logger } from "@renderer/logger";
export interface GameOptionsModalProps {
visible: boolean;
@@ -107,6 +109,20 @@ export function GameOptionsModal({
}
};
const handleCreateSteamShortcut = async () => {
try {
await window.electron.createSteamShortcut(game.shop, game.objectId);
showSuccessToast(
t("create_shortcut_success"),
t("you_might_need_to_restart_steam")
);
} catch (error: unknown) {
logger.error("Failed to create Steam shortcut", error);
showErrorToast(t("create_shortcut_error"));
}
};
const handleCreateShortcut = async (location: ShortcutLocation) => {
window.electron
.createGameShortcut(game.shop, game.objectId, location)
@@ -298,6 +314,10 @@ export function GameOptionsModal({
>
{t("create_shortcut")}
</Button>
<Button onClick={handleCreateSteamShortcut} theme="outline">
<SteamLogo className="game-card__shop-icon" />
{t("create_steam_shortcut")}
</Button>
{shouldShowCreateStartMenuShortcut && (
<Button
onClick={() => handleCreateShortcut("start_menu")}