mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
Merge 8677402c06
into 42ae8e76a6
This commit is contained in:
commit
3243c7cdb8
3 changed files with 32 additions and 5 deletions
|
@ -224,8 +224,11 @@ export function GameDetailsContextProvider({
|
||||||
return window.electron.getDefaultDownloadsPath();
|
return window.electron.getDefaultDownloadsPath();
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectGameExecutable = async () => {
|
const selectGameExecutable = async (
|
||||||
const downloadsPath = await getDownloadsPath();
|
gameInstallerFolderIfExists?: string
|
||||||
|
) => {
|
||||||
|
const downloadsPath =
|
||||||
|
gameInstallerFolderIfExists ?? (await getDownloadsPath());
|
||||||
|
|
||||||
return window.electron
|
return window.electron
|
||||||
.showOpenDialog({
|
.showOpenDialog({
|
||||||
|
|
|
@ -24,7 +24,9 @@ export interface GameDetailsContext {
|
||||||
hasNSFWContentBlocked: boolean;
|
hasNSFWContentBlocked: boolean;
|
||||||
lastDownloadedOption: GameRepack | null;
|
lastDownloadedOption: GameRepack | null;
|
||||||
setGameColor: React.Dispatch<React.SetStateAction<string>>;
|
setGameColor: React.Dispatch<React.SetStateAction<string>>;
|
||||||
selectGameExecutable: () => Promise<string | null>;
|
selectGameExecutable: (
|
||||||
|
gameInstallerFolderIfExists?: string
|
||||||
|
) => Promise<string | null>;
|
||||||
updateGame: () => Promise<void>;
|
updateGame: () => Promise<void>;
|
||||||
setShowRepacksModal: React.Dispatch<React.SetStateAction<boolean>>;
|
setShowRepacksModal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
setShowGameOptionsModal: React.Dispatch<React.SetStateAction<boolean>>;
|
setShowGameOptionsModal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
PlusCircleIcon,
|
PlusCircleIcon,
|
||||||
} from "@primer/octicons-react";
|
} from "@primer/octicons-react";
|
||||||
import { Button } from "@renderer/components";
|
import { Button } from "@renderer/components";
|
||||||
import { useDownload, useLibrary } from "@renderer/hooks";
|
import { useAppSelector, useDownload, useLibrary } from "@renderer/hooks";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { gameDetailsContext } from "@renderer/context";
|
import { gameDetailsContext } from "@renderer/context";
|
||||||
|
@ -19,6 +19,10 @@ export function HeroPanelActions() {
|
||||||
|
|
||||||
const { isGameDeleting } = useDownload();
|
const { isGameDeleting } = useDownload();
|
||||||
|
|
||||||
|
const userPreferences = useAppSelector(
|
||||||
|
(state) => state.userPreferences.value
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
game,
|
game,
|
||||||
repacks,
|
repacks,
|
||||||
|
@ -92,7 +96,25 @@ export function HeroPanelActions() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gameExecutablePath = await selectGameExecutable();
|
let gameInstallerFolderIfExists
|
||||||
|
|
||||||
|
if (game && game.folderName) {
|
||||||
|
let downloadsPath = await window.electron.getDefaultDownloadsPath();
|
||||||
|
if (userPreferences?.downloadsPath)
|
||||||
|
downloadsPath = userPreferences.downloadsPath;
|
||||||
|
|
||||||
|
const folderSeparator =
|
||||||
|
window.electron.platform == "win32" ? "\\" : "/";
|
||||||
|
|
||||||
|
gameInstallerFolderIfExists =
|
||||||
|
(game.downloadPath ?? downloadsPath) +
|
||||||
|
folderSeparator +
|
||||||
|
game.folderName!;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gameExecutablePath = await selectGameExecutable(
|
||||||
|
gameInstallerFolderIfExists
|
||||||
|
);
|
||||||
if (gameExecutablePath)
|
if (gameExecutablePath)
|
||||||
window.electron.openGame(
|
window.electron.openGame(
|
||||||
game.shop,
|
game.shop,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue