diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-01-23 19:05:31 -0500 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-01-23 19:05:31 -0500 |
| commit | df47087cb3d43d0ebb808cc641e796341f941899 (patch) | |
| tree | 96589c82d16db4f84983981b27a7bff860ee868f | |
| parent | 4de16c13dc3e73766d63d931b19e7b8c60ef4a1f (diff) | |
| download | Decky-Framegen-df47087cb3d43d0ebb808cc641e796341f941899.tar.gz Decky-Framegen-df47087cb3d43d0ebb808cc641e796341f941899.zip | |
add patch and unpatch to gamepatcher section
| -rwxr-xr-x | src/index.tsx | 30 |
1 files changed, 26 insertions, 4 deletions
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<string | null>(null); + const [isPatched, setIsPatched] = useState<boolean>(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() { <div> {mainRunningApp ? ( <> - <span>Patch: {mainRunningApp.display_name}</span> + <span>{isPatched ? `UnPatch: ${mainRunningApp.display_name}` : `Patch: ${mainRunningApp.display_name}`}</span> <ButtonItem layout="below" onClick={handleSetLaunchOptions}> - Patch: {mainRunningApp.display_name} + {isPatched ? `UnPatch: ${mainRunningApp.display_name}` : `Patch: ${mainRunningApp.display_name}`} </ButtonItem> </> ) : ( |
