mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
clicking 'play' now redirects to the same folder as the installer
This commit is contained in:
parent
8fad9b05e6
commit
d4aebf7d99
3 changed files with 24 additions and 5 deletions
|
@ -131,8 +131,9 @@ export function GameDetailsContextProvider({
|
||||||
return window.electron.getDefaultDownloadsPath();
|
return window.electron.getDefaultDownloadsPath();
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectGameExecutable = async () => {
|
const selectGameExecutable = async (gameInstallerFolderIfExists: string | null) => {
|
||||||
const downloadsPath = await getDownloadsPath();
|
|
||||||
|
const downloadsPath = gameInstallerFolderIfExists ?? await getDownloadsPath();
|
||||||
|
|
||||||
return window.electron
|
return window.electron
|
||||||
.showOpenDialog({
|
.showOpenDialog({
|
||||||
|
|
|
@ -13,7 +13,7 @@ export interface GameDetailsContext {
|
||||||
showRepacksModal: boolean;
|
showRepacksModal: boolean;
|
||||||
showGameOptionsModal: boolean;
|
showGameOptionsModal: boolean;
|
||||||
setGameColor: React.Dispatch<React.SetStateAction<string>>;
|
setGameColor: React.Dispatch<React.SetStateAction<string>>;
|
||||||
selectGameExecutable: () => Promise<string | null>;
|
selectGameExecutable: (gameInstallerFolderIfExists: string | null) => 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>>;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { GearIcon, PlayIcon, PlusCircleIcon } from "@primer/octicons-react";
|
import { GearIcon, PlayIcon, PlusCircleIcon } 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 * as styles from "./hero-panel-actions.css";
|
import * as styles from "./hero-panel-actions.css";
|
||||||
|
@ -13,6 +13,10 @@ export function HeroPanelActions() {
|
||||||
|
|
||||||
const { isGameDeleting } = useDownload();
|
const { isGameDeleting } = useDownload();
|
||||||
|
|
||||||
|
const userPreferences = useAppSelector(
|
||||||
|
(state) => state.userPreferences.value
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
game,
|
game,
|
||||||
repacks,
|
repacks,
|
||||||
|
@ -49,7 +53,21 @@ export function HeroPanelActions() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gameExecutablePath = await selectGameExecutable();
|
let gameInstallerFolderIfExists: string | null = null
|
||||||
|
|
||||||
|
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(game.id, gameExecutablePath);
|
window.electron.openGame(game.id, gameExecutablePath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue