mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: using showItemInFolder to open exe and download paths
This commit is contained in:
parent
cead92d900
commit
08eda5573d
7 changed files with 28 additions and 21 deletions
|
@ -103,9 +103,9 @@
|
||||||
"select_executable": "Select executable",
|
"select_executable": "Select executable",
|
||||||
"no_executable_selected": "No executable selected",
|
"no_executable_selected": "No executable selected",
|
||||||
"open_folder": "Open folder",
|
"open_folder": "Open folder",
|
||||||
|
"open_download_location": "Abrir local de download",
|
||||||
"create_shortcut": "Create shortcut",
|
"create_shortcut": "Create shortcut",
|
||||||
"installer_path": "Installer path",
|
"remove_files": "Remove files"
|
||||||
"remove_installer": "Remove installer"
|
|
||||||
},
|
},
|
||||||
"activation": {
|
"activation": {
|
||||||
"title": "Activate Hydra",
|
"title": "Activate Hydra",
|
||||||
|
|
|
@ -100,9 +100,9 @@
|
||||||
"select_executable": "Selecionar executável",
|
"select_executable": "Selecionar executável",
|
||||||
"no_executable_selected": "Nenhum executável selecionado",
|
"no_executable_selected": "Nenhum executável selecionado",
|
||||||
"open_folder": "Abrir pasta",
|
"open_folder": "Abrir pasta",
|
||||||
|
"open_download_location": "Abrir local de download",
|
||||||
"create_shortcut": "Criar atalho",
|
"create_shortcut": "Criar atalho",
|
||||||
"installer_path": "Caminho do instalador",
|
"remove_files": "Remover arquivos"
|
||||||
"remove_installer": "Remover instalador"
|
|
||||||
},
|
},
|
||||||
"activation": {
|
"activation": {
|
||||||
"title": "Ativação",
|
"title": "Ativação",
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { shell } from "electron";
|
import { shell } from "electron";
|
||||||
import path from "node:path";
|
|
||||||
import { gameRepository } from "@main/repository";
|
import { gameRepository } from "@main/repository";
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
|
|
||||||
|
@ -11,12 +10,9 @@ const openGameExecutablePath = async (
|
||||||
where: { id: gameId, isDeleted: false },
|
where: { id: gameId, isDeleted: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!game || !game.executablePath) return true;
|
if (!game || !game.executablePath) return;
|
||||||
|
|
||||||
const gamePath = path.join(game.executablePath, "../");
|
shell.showItemInFolder(game.executablePath);
|
||||||
|
|
||||||
shell.openPath(gamePath);
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("openGameExecutablePath", openGameExecutablePath);
|
registerEvent("openGameExecutablePath", openGameExecutablePath);
|
||||||
|
|
|
@ -12,14 +12,14 @@ const openGameInstallerPath = async (
|
||||||
where: { id: gameId, isDeleted: false },
|
where: { id: gameId, isDeleted: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!game || !game.folderName) return true;
|
if (!game || !game.folderName || !game.downloadPath) return true;
|
||||||
|
|
||||||
const gamePath = path.join(
|
const gamePath = path.join(
|
||||||
game.downloadPath ?? (await getDownloadsPath()),
|
game.downloadPath ?? (await getDownloadsPath()),
|
||||||
game.folderName!
|
game.folderName!
|
||||||
);
|
);
|
||||||
|
|
||||||
shell.openPath(gamePath);
|
shell.showItemInFolder(gamePath);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
2
src/renderer/src/declaration.d.ts
vendored
2
src/renderer/src/declaration.d.ts
vendored
|
@ -63,7 +63,7 @@ declare global {
|
||||||
getLibrary: () => Promise<LibraryGame[]>;
|
getLibrary: () => Promise<LibraryGame[]>;
|
||||||
openGameInstaller: (gameId: number) => Promise<boolean>;
|
openGameInstaller: (gameId: number) => Promise<boolean>;
|
||||||
openGameInstallerPath: (gameId: number) => Promise<boolean>;
|
openGameInstallerPath: (gameId: number) => Promise<boolean>;
|
||||||
openGameExecutablePath: (gameId: number) => Promise<boolean>;
|
openGameExecutablePath: (gameId: number) => Promise<void>;
|
||||||
openGame: (gameId: number, executablePath: string) => Promise<void>;
|
openGame: (gameId: number, executablePath: string) => Promise<void>;
|
||||||
closeGame: (gameId: number) => Promise<boolean>;
|
closeGame: (gameId: number) => Promise<boolean>;
|
||||||
removeGameFromLibrary: (gameId: number) => Promise<void>;
|
removeGameFromLibrary: (gameId: number) => Promise<void>;
|
||||||
|
|
|
@ -140,7 +140,7 @@ export function HeroPanelActions() {
|
||||||
setShowGameOptionsModal(true);
|
setShowGameOptionsModal(true);
|
||||||
}}
|
}}
|
||||||
theme="outline"
|
theme="outline"
|
||||||
disabled={deleting}
|
disabled={deleting || isGameRunning}
|
||||||
className={styles.heroPanelAction}
|
className={styles.heroPanelAction}
|
||||||
>
|
>
|
||||||
<GearIcon />
|
<GearIcon />
|
||||||
|
|
|
@ -21,6 +21,8 @@ export function GameOptionsModal({
|
||||||
onClose,
|
onClose,
|
||||||
selectGameExecutable,
|
selectGameExecutable,
|
||||||
}: GameOptionsModalProps) {
|
}: GameOptionsModalProps) {
|
||||||
|
const { t } = useTranslation("game_details");
|
||||||
|
|
||||||
const { updateGame, openRepacksModal } = useContext(gameDetailsContext);
|
const { updateGame, openRepacksModal } = useContext(gameDetailsContext);
|
||||||
|
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
|
@ -30,7 +32,10 @@ export function GameOptionsModal({
|
||||||
|
|
||||||
const deleting = game ? isGameDeleting(game?.id) : false;
|
const deleting = game ? isGameDeleting(game?.id) : false;
|
||||||
|
|
||||||
const { t } = useTranslation("game_details");
|
const { lastPacket } = useDownload();
|
||||||
|
|
||||||
|
const isGameDownloading =
|
||||||
|
game?.status === "active" && lastPacket?.game.id === game?.id;
|
||||||
|
|
||||||
const handleRemoveGameFromLibrary = async () => {
|
const handleRemoveGameFromLibrary = async () => {
|
||||||
await removeGameFromLibrary(game.id);
|
await removeGameFromLibrary(game.id);
|
||||||
|
@ -51,6 +56,10 @@ export function GameOptionsModal({
|
||||||
await window.electron.createGameShortcut(game.id);
|
await window.electron.createGameShortcut(game.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleOpenDownloadFolder = async () => {
|
||||||
|
await window.electron.openGameInstallerPath(game.id);
|
||||||
|
};
|
||||||
|
|
||||||
const handleDeleteGame = async () => {
|
const handleDeleteGame = async () => {
|
||||||
await removeGameInstaller(game.id);
|
await removeGameInstaller(game.id);
|
||||||
updateGame();
|
updateGame();
|
||||||
|
@ -84,12 +93,12 @@ export function GameOptionsModal({
|
||||||
{t("open_download_options")}
|
{t("open_download_options")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleCreateShortcut}
|
onClick={handleOpenDownloadFolder}
|
||||||
style={{ alignSelf: "flex-end" }}
|
style={{ alignSelf: "flex-end" }}
|
||||||
theme="outline"
|
theme="outline"
|
||||||
disabled={deleting || !game.downloadPath}
|
disabled={deleting || !game.downloadPath}
|
||||||
>
|
>
|
||||||
{"Abrir local de download"}
|
{t("open_download_location")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleCreateShortcut}
|
onClick={handleCreateShortcut}
|
||||||
|
@ -129,13 +138,15 @@ export function GameOptionsModal({
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.gameOptionRow}>
|
<div className={styles.gameOptionRow}>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleCreateShortcut}
|
onClick={() => {
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
}}
|
||||||
style={{ alignSelf: "flex-end" }}
|
style={{ alignSelf: "flex-end" }}
|
||||||
theme="outline"
|
theme="outline"
|
||||||
disabled={deleting || !game.downloadPath}
|
disabled={isGameDownloading || deleting || !game.downloadPath}
|
||||||
>
|
>
|
||||||
<TrashIcon />
|
<TrashIcon />
|
||||||
Remover arquivos
|
{t("remove_files")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -145,7 +156,7 @@ export function GameOptionsModal({
|
||||||
disabled={deleting}
|
disabled={deleting}
|
||||||
>
|
>
|
||||||
<NoEntryIcon />
|
<NoEntryIcon />
|
||||||
Remover da biblioteca
|
{t("remove_from_library")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue