mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: show download button if game has no executable selected
This commit is contained in:
parent
939133fcc3
commit
e3fa401667
1 changed files with 48 additions and 20 deletions
|
@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
|
||||||
import * as styles from "./hero-panel-actions.css";
|
import * as styles from "./hero-panel-actions.css";
|
||||||
|
|
||||||
import { gameDetailsContext } from "@renderer/context";
|
import { gameDetailsContext } from "@renderer/context";
|
||||||
|
import { DownloadIcon } from "@renderer/components/sidebar/download-icon";
|
||||||
|
|
||||||
export function HeroPanelActions() {
|
export function HeroPanelActions() {
|
||||||
const [toggleLibraryGameDisabled, setToggleLibraryGameDisabled] =
|
const [toggleLibraryGameDisabled, setToggleLibraryGameDisabled] =
|
||||||
|
@ -25,6 +26,11 @@ export function HeroPanelActions() {
|
||||||
selectGameExecutable,
|
selectGameExecutable,
|
||||||
} = useContext(gameDetailsContext);
|
} = useContext(gameDetailsContext);
|
||||||
|
|
||||||
|
const { lastPacket } = useDownload();
|
||||||
|
|
||||||
|
const isGameDownloading =
|
||||||
|
game?.status === "active" && lastPacket?.game.id === game?.id;
|
||||||
|
|
||||||
const { updateLibrary } = useLibrary();
|
const { updateLibrary } = useLibrary();
|
||||||
|
|
||||||
const { t } = useTranslation("game_details");
|
const { t } = useTranslation("game_details");
|
||||||
|
@ -84,6 +90,47 @@ export function HeroPanelActions() {
|
||||||
</Button>
|
</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) {
|
if (repacks.length && !game) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -96,26 +143,7 @@ export function HeroPanelActions() {
|
||||||
if (game) {
|
if (game) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.actions}>
|
<div className={styles.actions}>
|
||||||
{isGameRunning ? (
|
{gameActionButton()}
|
||||||
<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>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className={styles.separator} />
|
<div className={styles.separator} />
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue