diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-01-26 22:45:57 -0500 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-01-26 22:45:57 -0500 |
| commit | 711ae9703616376c578fcfcd8c9bfff3bab869b0 (patch) | |
| tree | d5a02b453ca9d204d2778f55a0ba0e020164bebe | |
| parent | 30d0f3842591d3d1d18169863d640749df04e2e1 (diff) | |
| download | Decky-Framegen-711ae9703616376c578fcfcd8c9bfff3bab869b0.tar.gz Decky-Framegen-711ae9703616376c578fcfcd8c9bfff3bab869b0.zip | |
patch game from list on click
| -rwxr-xr-x | src/index.tsx | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/index.tsx b/src/index.tsx index 98611a2..37acfb1 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -231,16 +231,20 @@ function MainRunningApp() { } function InstalledGamesSection() { - const [games, setGames] = useState<{ appid: string; name: string }[]>([]); - const [clickedGame, setClickedGame] = useState<{ appid: string; name: string } | null>(null); + const [games, setGames] = useState<{ appid: number; name: string }[]>([]); + const [clickedGame, setClickedGame] = useState<{ appid: number; name: string } | null>(null); + const [result, setResult] = useState<string>(''); useEffect(() => { const fetchGames = async () => { const result = await listInstalledGames(); if (result.status === "success") { - const sortedGames = [...result.games].sort((a, b) => - a.name.toLowerCase().localeCompare(b.name.toLowerCase()) - ); + const sortedGames = [...result.games] + .map(game => ({ + ...game, + appid: parseInt(game.appid, 10) // Convert string to number + })) + .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())); setGames(sortedGames); } else { console.error("Failed to fetch games"); @@ -250,19 +254,33 @@ function InstalledGamesSection() { fetchGames(); }, []); + const handleGameClick = async (game: { appid: number; name: string }) => { + setClickedGame(game); + try { + await SteamClient.Apps.SetAppLaunchOptions(game.appid, '/home/deck/fgmod/fgmod %COMMAND%'); + setResult(`Launch options set successfully for ${game.name}. Restart the game to use FSR upscaling and frame gen.`); + } catch (error) { + if (error instanceof Error) { + setResult(`Error setting launch options: ${error.message}`); + } else { + setResult('Error setting launch options'); + } + } + }; + return ( <PanelSection title="Installed Games"> {games.map((game) => ( <PanelSectionRow key={game.appid}> <ButtonItem layout="below" - onClick={() => setClickedGame(game)} + onClick={() => handleGameClick(game)} > {game.name} (AppID: {game.appid}) </ButtonItem> {clickedGame?.appid === game.appid && ( <div style={{ padding: '8px' }}> - You clicked {game.name} with AppID: {game.appid} + {result} </div> )} </PanelSectionRow> |
