From 1fad610f29ba00c2281ab6b163ef217e5fb2b93b Mon Sep 17 00:00:00 2001 From: Fhilipe Coelho Date: Sun, 14 Apr 2024 13:32:01 -0300 Subject: [PATCH] feat: add modal to warning user about wine/lutris binaries --- src/locales/en/translation.json | 5 ++++ src/locales/es/translation.json | 5 ++++ src/locales/pt/translation.json | 5 ++++ src/renderer/declaration.d.ts | 2 +- src/renderer/pages/downloads/downloads.tsx | 6 ++++- .../pages/game-details/hero-panel.tsx | 9 +++++-- .../shared-modals/binary-not-found-modal.tsx | 25 +++++++++++++++++++ 7 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 src/renderer/pages/shared-modals/binary-not-found-modal.tsx diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 207613fd..668b51a3 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -107,5 +107,10 @@ }, "game_card": { "no_downloads": "No downloads available" + }, + "binary_not_found_modal": { + "title": "Programs not installed", + "description": "Wine or Lutris executables were not found on your system", + "instructions": "Check the correct way to install any of them on your Linux distro so that the game can run normally" } } diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json index 0153de88..eba09ae9 100644 --- a/src/locales/es/translation.json +++ b/src/locales/es/translation.json @@ -107,5 +107,10 @@ }, "game_card": { "no_downloads": "No hay descargas disponibles" + }, + "binary_not_found_modal": { + "title": "Programas no instalados", + "description": "Los ejecutables de Wine o Lutris no se encontraron en su sistema", + "instructions": "Comprueba la forma correcta de instalar cualquiera de ellos en tu distro Linux para que el juego pueda ejecutarse con normalidad" } } diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json index 722e7145..a2548bd3 100644 --- a/src/locales/pt/translation.json +++ b/src/locales/pt/translation.json @@ -107,5 +107,10 @@ }, "game_card": { "no_downloads": "Sem downloads disponíveis" + }, + "binary_not_found_modal": { + "title": "Programas não instalados", + "description": "Não foram encontrados no seu sistema os executáveis do Wine ou Lutris", + "instructions": "Verifique a forma correta de instalar algum deles na sua distro Linux para que o jogo possa ser executado normalmente" } } diff --git a/src/renderer/declaration.d.ts b/src/renderer/declaration.d.ts index 337e3084..aff5f227 100644 --- a/src/renderer/declaration.d.ts +++ b/src/renderer/declaration.d.ts @@ -43,7 +43,7 @@ declare global { /* Library */ getLibrary: () => Promise; getRepackersFriendlyNames: () => Promise>; - openGame: (gameId: number) => Promise; + openGame: (gameId: number) => Promise; removeGame: (gameId: number) => Promise; deleteGameFolder: (gameId: number) => Promise; getGameByObjectID: (objectID: string) => Promise; diff --git a/src/renderer/pages/downloads/downloads.tsx b/src/renderer/pages/downloads/downloads.tsx index f0fd8038..813b888d 100644 --- a/src/renderer/pages/downloads/downloads.tsx +++ b/src/renderer/pages/downloads/downloads.tsx @@ -9,6 +9,7 @@ import type { Game } from "@types"; import * as styles from "./downloads.css"; import { useEffect, useState } from "react"; +import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal"; export function Downloads() { const { library, updateLibrary } = useLibrary(); @@ -18,6 +19,7 @@ export function Downloads() { const navigate = useNavigate(); const [filteredLibrary, setFilteredLibrary] = useState([]); + const [showBinaryNotFoundModal, setShowBinaryNotFoundModal] = useState(false); const { game: gameDownloading, @@ -37,7 +39,8 @@ export function Downloads() { }, [library]); const openGame = (gameId: number) => - window.electron.openGame(gameId).then(() => { + window.electron.openGame(gameId).then(res => { + if (!res) setShowBinaryNotFoundModal(true); updateLibrary(); }); @@ -202,6 +205,7 @@ export function Downloads() { return (
+ setShowBinaryNotFoundModal(false)} />
    diff --git a/src/renderer/pages/game-details/hero-panel.tsx b/src/renderer/pages/game-details/hero-panel.tsx index 6189a261..71ff506a 100644 --- a/src/renderer/pages/game-details/hero-panel.tsx +++ b/src/renderer/pages/game-details/hero-panel.tsx @@ -1,4 +1,4 @@ -import { useMemo } from "react"; +import { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import prettyBytes from "pretty-bytes"; import { format } from "date-fns"; @@ -9,6 +9,7 @@ import type { Game, ShopDetails } from "@types"; import * as styles from "./hero-panel.css"; import { formatDownloadProgress } from "@renderer/helpers"; +import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal"; export interface HeroPanelProps { game: Game | null; @@ -27,6 +28,8 @@ export function HeroPanel({ }: HeroPanelProps) { const { t } = useTranslation("game_details"); + const [showBinaryNotFoundModal, setShowBinaryNotFoundModal] = useState(false); + const { game: gameDownloading, isDownloading, @@ -46,7 +49,8 @@ export function HeroPanel({ const isGameDownloading = isDownloading && gameDownloading?.id === game?.id; const openGame = (gameId: number) => - window.electron.openGame(gameId).then(() => { + window.electron.openGame(gameId).then(res => { + if (!res) setShowBinaryNotFoundModal(true); updateLibrary(); }); @@ -202,6 +206,7 @@ export function HeroPanel({ return (
    + setShowBinaryNotFoundModal(false)} />
    {getInfo()}
    {getActions()}
    diff --git a/src/renderer/pages/shared-modals/binary-not-found-modal.tsx b/src/renderer/pages/shared-modals/binary-not-found-modal.tsx new file mode 100644 index 00000000..2f37f346 --- /dev/null +++ b/src/renderer/pages/shared-modals/binary-not-found-modal.tsx @@ -0,0 +1,25 @@ +import { Modal } from "@renderer/components" +import { useTranslation } from "react-i18next"; + +interface BinaryNotFoundModalProps { + visible: boolean; + onClose: () => void; +} + +export const BinaryNotFoundModal = ({ + visible, + onClose +}: BinaryNotFoundModalProps) => { + const { t } = useTranslation("binary_not_found_modal"); + + return ( + + {t("instructions")} + + ) +} \ No newline at end of file