organize ui

This commit is contained in:
Zamitto 2024-06-05 20:29:42 -03:00
parent 45d8923561
commit e8b28ccf90
5 changed files with 89 additions and 98 deletions

View file

@ -11,8 +11,7 @@ const addGameToLibrary = async (
_event: Electron.IpcMainInvokeEvent, _event: Electron.IpcMainInvokeEvent,
objectID: string, objectID: string,
title: string, title: string,
shop: GameShop, shop: GameShop
executablePath: string | null
) => { ) => {
return gameRepository return gameRepository
.update( .update(
@ -22,7 +21,6 @@ const addGameToLibrary = async (
{ {
shop, shop,
status: null, status: null,
executablePath,
isDeleted: false, isDeleted: false,
} }
) )
@ -42,7 +40,6 @@ const addGameToLibrary = async (
iconUrl, iconUrl,
objectID, objectID,
shop, shop,
executablePath,
}) })
.then(() => { .then(() => {
if (iconUrl) { if (iconUrl) {

View file

@ -61,19 +61,8 @@ contextBridge.exposeInMainWorld("electron", {
syncDownloadSources: () => ipcRenderer.invoke("syncDownloadSources"), syncDownloadSources: () => ipcRenderer.invoke("syncDownloadSources"),
/* Library */ /* Library */
addGameToLibrary: ( addGameToLibrary: (objectID: string, title: string, shop: GameShop) =>
objectID: string, ipcRenderer.invoke("addGameToLibrary", objectID, title, shop),
title: string,
shop: GameShop,
executablePath: string
) =>
ipcRenderer.invoke(
"addGameToLibrary",
objectID,
title,
shop,
executablePath
),
createGameShortcut: (id: number) => createGameShortcut: (id: number) =>
ipcRenderer.invoke("createGameShortcut", id), ipcRenderer.invoke("createGameShortcut", id),
updateExecutablePath: (id: number, executablePath: string) => updateExecutablePath: (id: number, executablePath: string) =>

View file

@ -56,8 +56,7 @@ declare global {
addGameToLibrary: ( addGameToLibrary: (
objectID: string, objectID: string,
title: string, title: string,
shop: GameShop, shop: GameShop
executablePath: string | null
) => Promise<void>; ) => Promise<void>;
createGameShortcut: (id: number) => Promise<boolean>; createGameShortcut: (id: number) => Promise<boolean>;
updateExecutablePath: (id: number, executablePath: string) => Promise<void>; updateExecutablePath: (id: number, executablePath: string) => Promise<void>;

View file

@ -79,12 +79,7 @@ export function HeroPanelActions() {
if (game) { if (game) {
await removeGameFromLibrary(game.id); await removeGameFromLibrary(game.id);
} else { } else {
await window.electron.addGameToLibrary( await window.electron.addGameToLibrary(objectID!, gameTitle, "steam");
objectID!,
gameTitle,
"steam",
null
);
} }
updateLibrary(); updateLibrary();

View file

@ -11,6 +11,7 @@ import { gameDetailsContext } from "../game-details.context";
import { import {
FileDirectoryOpenFillIcon, FileDirectoryOpenFillIcon,
FileSymlinkFileIcon, FileSymlinkFileIcon,
PencilIcon,
TrashIcon, TrashIcon,
} from "@primer/octicons-react"; } from "@primer/octicons-react";
import { DeleteGameModal } from "@renderer/pages/downloads/delete-game-modal"; import { DeleteGameModal } from "@renderer/pages/downloads/delete-game-modal";
@ -54,6 +55,7 @@ export function GameOptionsModal({
const handleDeleteGame = async () => { const handleDeleteGame = async () => {
await removeGameInstaller(game.id); await removeGameInstaller(game.id);
updateGame();
}; };
const handleOpenGameInstallerPath = async () => { const handleOpenGameInstallerPath = async () => {
@ -78,81 +80,9 @@ export function GameOptionsModal({
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
gap: `${SPACING_UNIT}px`, gap: `${SPACING_UNIT}px`,
width: "700px", width: "100%",
}} }}
> >
<div className={styles.downloadSourceField}>
<TextField
label="Caminho do executável"
value={game.executablePath || ""}
readOnly
theme="dark"
disabled
placeholder="Selecione um executável"
/>
</div>
<div className={styles.downloadSourceField}>
<Button
type="button"
theme="outline"
style={{ alignSelf: "flex-end" }}
onClick={handleOpenGameExecutablePath}
>
<FileDirectoryOpenFillIcon />
{"Abrir pasta"}
</Button>
<Button
type="button"
theme="outline"
style={{ alignSelf: "flex-end" }}
onClick={handleChangeExecutableLocation}
>
<FileSymlinkFileIcon />
{"Alterar"}
</Button>
<Button
onClick={handleCreateShortcut}
theme="outline"
disabled={deleting}
>
{"Criar atalho"}
</Button>
</div>
<div className={styles.downloadSourceField}>
<TextField
label="Caminho do instalador"
value={`${game.downloadPath}\\${game.folderName}`}
readOnly
theme="dark"
disabled
placeholder=""
/>
<Button
type="button"
theme="outline"
style={{ alignSelf: "flex-end" }}
onClick={handleOpenGameInstallerPath}
>
<FileDirectoryOpenFillIcon />
{"Abrir pasta"}
</Button>
<Button
type="button"
theme="outline"
style={{ alignSelf: "flex-end" }}
onClick={() => {
setShowDeleteModal(true);
}}
>
<TrashIcon />
{"Remover"}
</Button>
</div>
<div className={styles.downloadSourceField}> <div className={styles.downloadSourceField}>
<Button <Button
onClick={openRepacksModal} onClick={openRepacksModal}
@ -162,6 +92,87 @@ export function GameOptionsModal({
{t("open_download_options")} {t("open_download_options")}
</Button> </Button>
</div> </div>
<div className={styles.downloadSourceField}>
<TextField
label="Caminho do executável"
value={game.executablePath || ""}
readOnly
theme="dark"
disabled
placeholder="Selecione um executável"
/>
<Button
type="button"
theme="outline"
style={{ alignSelf: "flex-end" }}
onClick={handleChangeExecutableLocation}
title={
game.executablePath
? "Trocar executável"
: "Selecionar executável"
}
>
<PencilIcon />
</Button>
<Button
type="button"
theme="outline"
style={{ alignSelf: "flex-end" }}
onClick={handleOpenGameExecutablePath}
disabled={!game.executablePath}
title={"Abrir pasta"}
>
<FileDirectoryOpenFillIcon />
</Button>
<Button
onClick={handleCreateShortcut}
style={{ alignSelf: "flex-end" }}
theme="outline"
disabled={deleting || !game.executablePath}
title={"Criar atalho"}
>
<FileSymlinkFileIcon />
</Button>
</div>
<div className={styles.downloadSourceField}></div>
{game.folderName && (
<div className={styles.downloadSourceField}>
<TextField
label="Caminho do instalador"
value={`${game.downloadPath}\\${game.folderName}`}
readOnly
theme="dark"
disabled
placeholder=""
/>
<Button
type="button"
theme="outline"
style={{ alignSelf: "flex-end" }}
onClick={handleOpenGameInstallerPath}
disabled={!game.downloadPath}
title={"Abrir pasta"}
>
<FileDirectoryOpenFillIcon />
</Button>
<Button
type="button"
theme="outline"
style={{ alignSelf: "flex-end" }}
disabled={!game.downloadPath}
onClick={() => {
setShowDeleteModal(true);
}}
title={"Remover instalador"}
>
<TrashIcon />
</Button>
</div>
)}
</div> </div>
</Modal> </Modal>
</> </>