From df47087cb3d43d0ebb808cc641e796341f941899 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Thu, 23 Jan 2025 19:05:31 -0500 Subject: add patch and unpatch to gamepatcher section --- src/index.tsx | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/index.tsx') diff --git a/src/index.tsx b/src/index.tsx index 0d1aacc..bd0f717 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -160,12 +160,34 @@ function FGModInstallerSection() { function MainRunningApp() { const mainRunningApp = Router.MainRunningApp; const [result, setResult] = useState(null); + const [isPatched, setIsPatched] = useState(false); + + useEffect(() => { + const checkLaunchOptions = async () => { + if (mainRunningApp) { + try { + const currentOptions = await SteamClient.Apps.GetLaunchOptionsForApp(mainRunningApp.appid); + setIsPatched(currentOptions.includes('/home/deck/fgmod/fgmod %COMMAND%')); + } catch (error) { + console.error('Error checking launch options:', error); + } + } + }; + + checkLaunchOptions(); + }, [mainRunningApp]); const handleSetLaunchOptions = async () => { if (mainRunningApp) { try { - const response = await SteamClient.Apps.SetAppLaunchOptions(mainRunningApp.appid, '/home/deck/fgmod/fgmod %COMMAND%'); - setResult(`Launch options set successfully: ${response}`); + if (isPatched) { + await SteamClient.Apps.SetAppLaunchOptions(mainRunningApp.appid, ''); + setResult(`Launch options cleared successfully.`); + } else { + await SteamClient.Apps.SetAppLaunchOptions(mainRunningApp.appid, '/home/deck/fgmod/fgmod %COMMAND%'); + setResult(`Launch options set successfully, restart the game to use FSR via DLSS.`); + } + setIsPatched(!isPatched); } catch (error) { if (error instanceof Error) { setResult(`Error setting launch options: ${error.message}`); @@ -182,9 +204,9 @@ function MainRunningApp() {
{mainRunningApp ? ( <> - Patch: {mainRunningApp.display_name} + {isPatched ? `UnPatch: ${mainRunningApp.display_name}` : `Patch: ${mainRunningApp.display_name}`} - Patch: {mainRunningApp.display_name} + {isPatched ? `UnPatch: ${mainRunningApp.display_name}` : `Patch: ${mainRunningApp.display_name}`} ) : ( -- cgit v1.2.3