From ee1a06086337253947508d1a3a80ca1a3c43290c Mon Sep 17 00:00:00 2001 From: Ariel Juodziukynas Date: Mon, 4 Sep 2023 20:47:42 -0300 Subject: [PATCH] [Improv]: Confirm installing broken anticheat games (#2981) * Ask the user to confirm the installation of broken anticheat games * Ask the user to confirm the installation of broken anticheat games --- public/locales/en/gamepage.json | 6 +++ .../components/UI/Anticheat/index.tsx | 24 ++---------- src/frontend/hooks/hasAnticheatInfo.ts | 22 +++++++++++ src/frontend/screens/Game/GamePage/index.tsx | 5 ++- .../InstallModal/DownloadDialog/index.tsx | 37 ++++++++++++++++++- 5 files changed, 71 insertions(+), 23 deletions(-) create mode 100644 src/frontend/hooks/hasAnticheatInfo.ts diff --git a/public/locales/en/gamepage.json b/public/locales/en/gamepage.json index 66bfc102f6..39a6e262f0 100644 --- a/public/locales/en/gamepage.json +++ b/public/locales/en/gamepage.json @@ -125,6 +125,12 @@ "version": "Version" }, "install": { + "anticheat-warning": { + "cancel": "No", + "install": "Yes (I understand it will not work)", + "message": "The anticheat support is broken or denied. The game will not work. Do you want to install it anyway?", + "title": "Anticheat Broken/Denied" + }, "disk-space-left": "Space Available", "not-enough-disk-space": "Not enough disk space", "path": "Select Install Path", diff --git a/src/frontend/components/UI/Anticheat/index.tsx b/src/frontend/components/UI/Anticheat/index.tsx index 3c60e66538..1f2f0d3bc4 100644 --- a/src/frontend/components/UI/Anticheat/index.tsx +++ b/src/frontend/components/UI/Anticheat/index.tsx @@ -1,5 +1,5 @@ -import React, { MouseEvent, useEffect, useState } from 'react' -import { AntiCheatInfo, GameInfo } from 'common/types' +import React, { MouseEvent } from 'react' +import { AntiCheatInfo } from 'common/types' import { createNewWindow } from 'frontend/helpers' import { ReactComponent as InfoIcon } from 'frontend/assets/info_icon.svg' @@ -10,30 +10,14 @@ import './index.scss' import { useTranslation } from 'react-i18next' type Props = { - gameInfo: GameInfo + anticheatInfo: AntiCheatInfo | null } const awacyUrl = 'https://areweanticheatyet.com/' -export default function Anticheat({ gameInfo }: Props) { +export default function Anticheat({ anticheatInfo }: Props) { const { t } = useTranslation() - const [anticheatInfo, setAnticheatInfo] = useState(null) - - useEffect(() => { - if ( - gameInfo.runner !== 'sideload' && - gameInfo.title && - gameInfo.namespace !== undefined - ) { - window.api - .getAnticheatInfo(gameInfo.namespace) - .then((anticheatInfo: AntiCheatInfo | null) => { - setAnticheatInfo(anticheatInfo) - }) - } - }, [gameInfo]) - if (!anticheatInfo) { return null } diff --git a/src/frontend/hooks/hasAnticheatInfo.ts b/src/frontend/hooks/hasAnticheatInfo.ts new file mode 100644 index 0000000000..f6b9c93de0 --- /dev/null +++ b/src/frontend/hooks/hasAnticheatInfo.ts @@ -0,0 +1,22 @@ +import { useEffect, useState } from 'react' +import { AntiCheatInfo, GameInfo } from 'common/types' + +export const hasAnticheatInfo = (gameInfo: GameInfo) => { + const [anticheatInfo, setAnticheatInfo] = useState(null) + + useEffect(() => { + if ( + gameInfo.runner !== 'sideload' && + gameInfo.title && + gameInfo.namespace !== undefined + ) { + window.api + .getAnticheatInfo(gameInfo.namespace) + .then((anticheatInfo: AntiCheatInfo | null) => { + setAnticheatInfo(anticheatInfo) + }) + } + }, [gameInfo]) + + return anticheatInfo +} diff --git a/src/frontend/screens/Game/GamePage/index.tsx b/src/frontend/screens/Game/GamePage/index.tsx index 2838ad46bf..508709283e 100644 --- a/src/frontend/screens/Game/GamePage/index.tsx +++ b/src/frontend/screens/Game/GamePage/index.tsx @@ -82,6 +82,7 @@ import HowLongToBeat from 'frontend/components/UI/WikiGameInfo/components/HowLon import GameScore from 'frontend/components/UI/WikiGameInfo/components/GameScore' import DLCList from 'frontend/components/UI/DLCList' import { NileInstallInfo } from 'common/types/nile' +import { hasAnticheatInfo } from 'frontend/hooks/hasAnticheatInfo' export default React.memo(function GamePage(): JSX.Element | null { const { appName, runner } = useParams() as { appName: string; runner: Runner } @@ -130,6 +131,8 @@ export default React.memo(function GamePage(): JSX.Element | null { const [showRequirements, setShowRequirements] = useState(false) const [showDlcs, setShowDlcs] = useState(false) + const anticheatInfo = hasAnticheatInfo(gameInfo) + const isWin = platform === 'win32' const isLinux = platform === 'linux' const isMac = platform === 'darwin' @@ -760,7 +763,7 @@ export default React.memo(function GamePage(): JSX.Element | null { ))} )} - + {is_installed && !isQueued && (