Merge branch 'main' into feat/HYD-822

This commit is contained in:
Zamitto
2025-05-14 19:55:43 -03:00
17 changed files with 408 additions and 33 deletions

View File

@@ -179,6 +179,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;
@@ -45,6 +47,7 @@ export function GameOptionsModal({
const [automaticCloudSync, setAutomaticCloudSync] = useState(
game.automaticCloudSync ?? false
);
const [creatingSteamShortcut, setCreatingSteamShortcut] = useState(false);
const {
removeGameInstaller,
@@ -107,6 +110,25 @@ export function GameOptionsModal({
}
};
const handleCreateSteamShortcut = async () => {
try {
setCreatingSteamShortcut(true);
await window.electron.createSteamShortcut(game.shop, game.objectId);
showSuccessToast(
t("create_shortcut_success"),
t("you_might_need_to_restart_steam")
);
updateGame();
} catch (error: unknown) {
logger.error("Failed to create Steam shortcut", error);
showErrorToast(t("create_shortcut_error"));
} finally {
setCreatingSteamShortcut(false);
}
};
const handleCreateShortcut = async (location: ShortcutLocation) => {
window.electron
.createGameShortcut(game.shop, game.objectId, location)
@@ -142,9 +164,12 @@ export function GameOptionsModal({
};
const handleChangeWinePrefixPath = async () => {
const defaultPath =
await window.electron.getDefaultWinePrefixSelectionPath();
const { filePaths } = await window.electron.showOpenDialog({
properties: ["openDirectory"],
defaultPath: await window.electron.getDefaultWinePrefixSelectionPath(),
defaultPath: defaultPath ?? game?.winePrefixPath ?? "",
});
if (filePaths && filePaths.length > 0) {
@@ -298,6 +323,14 @@ export function GameOptionsModal({
>
{t("create_shortcut")}
</Button>
<Button
onClick={handleCreateSteamShortcut}
theme="outline"
disabled={creatingSteamShortcut}
>
<SteamLogo />
{t("create_steam_shortcut")}
</Button>
{shouldShowCreateStartMenuShortcut && (
<Button
onClick={() => handleCreateShortcut("start_menu")}