mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
Merge branch 'feature/profile-redesign' of github.com:hydralauncher/hydra into feature/profile-redesign
This commit is contained in:
commit
5432ef311a
9 changed files with 85 additions and 25 deletions
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
|
@ -72,6 +72,7 @@ declare global {
|
|||
) => Promise<void>;
|
||||
createGameShortcut: (id: number) => Promise<boolean>;
|
||||
updateExecutablePath: (id: number, executablePath: string) => Promise<void>;
|
||||
verifyExecutablePathInUse: (executablePath: string) => Promise<Game>;
|
||||
getLibrary: () => Promise<LibraryGame[]>;
|
||||
openGameInstaller: (gameId: number) => Promise<boolean>;
|
||||
openGameInstallerPath: (gameId: number) => Promise<boolean>;
|
||||
|
|
|
@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
|
|||
import * as styles from "./hero-panel-actions.css";
|
||||
|
||||
import { gameDetailsContext } from "@renderer/context";
|
||||
import { DownloadIcon } from "@renderer/components/sidebar/download-icon";
|
||||
|
||||
export function HeroPanelActions() {
|
||||
const [toggleLibraryGameDisabled, setToggleLibraryGameDisabled] =
|
||||
|
@ -25,6 +26,11 @@ export function HeroPanelActions() {
|
|||
selectGameExecutable,
|
||||
} = useContext(gameDetailsContext);
|
||||
|
||||
const { lastPacket } = useDownload();
|
||||
|
||||
const isGameDownloading =
|
||||
game?.status === "active" && lastPacket?.game.id === game?.id;
|
||||
|
||||
const { updateLibrary } = useLibrary();
|
||||
|
||||
const { t } = useTranslation("game_details");
|
||||
|
@ -84,6 +90,47 @@ export function HeroPanelActions() {
|
|||
</Button>
|
||||
);
|
||||
|
||||
const gameActionButton = () => {
|
||||
if (isGameRunning) {
|
||||
return (
|
||||
<Button
|
||||
onClick={closeGame}
|
||||
theme="outline"
|
||||
disabled={deleting}
|
||||
className={styles.heroPanelAction}
|
||||
>
|
||||
{t("close")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
if (game?.executablePath) {
|
||||
return (
|
||||
<Button
|
||||
onClick={openGame}
|
||||
theme="outline"
|
||||
disabled={deleting || isGameRunning}
|
||||
className={styles.heroPanelAction}
|
||||
>
|
||||
<PlayIcon />
|
||||
{t("play")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
onClick={() => setShowRepacksModal(true)}
|
||||
theme="outline"
|
||||
disabled={isGameDownloading || !repacks.length}
|
||||
className={styles.heroPanelAction}
|
||||
>
|
||||
<DownloadIcon isDownloading={false} />
|
||||
{t("download")}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
if (repacks.length && !game) {
|
||||
return (
|
||||
<>
|
||||
|
@ -96,26 +143,7 @@ export function HeroPanelActions() {
|
|||
if (game) {
|
||||
return (
|
||||
<div className={styles.actions}>
|
||||
{isGameRunning ? (
|
||||
<Button
|
||||
onClick={closeGame}
|
||||
theme="outline"
|
||||
disabled={deleting}
|
||||
className={styles.heroPanelAction}
|
||||
>
|
||||
{t("close")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
onClick={openGame}
|
||||
theme="outline"
|
||||
disabled={deleting || isGameRunning}
|
||||
className={styles.heroPanelAction}
|
||||
>
|
||||
<PlayIcon />
|
||||
{t("play")}
|
||||
</Button>
|
||||
)}
|
||||
{gameActionButton()}
|
||||
|
||||
<div className={styles.separator} />
|
||||
|
||||
|
|
|
@ -57,8 +57,17 @@ export function GameOptionsModal({
|
|||
const path = await selectGameExecutable();
|
||||
|
||||
if (path) {
|
||||
await window.electron.updateExecutablePath(game.id, path);
|
||||
updateGame();
|
||||
const gameUsingPath =
|
||||
await window.electron.verifyExecutablePathInUse(path);
|
||||
|
||||
if (gameUsingPath) {
|
||||
showErrorToast(
|
||||
t("executable_path_in_use", { game: gameUsingPath.title })
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
window.electron.updateExecutablePath(game.id, path).then(updateGame);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue