From 5d40bc1aac21d07c8af16615d8311e679ef50667 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Sun, 26 Jan 2025 15:17:01 -0500 Subject: groundwork for games list, next step patch on button press --- main.py | 43 +++++++++++++++++++++++++++++++++++++++++-- src/index.tsx | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 944eaf7..224a723 100644 --- a/main.py +++ b/main.py @@ -23,7 +23,6 @@ class Plugin: except subprocess.CalledProcessError as e: return {"status": "error", "message": str(e), "output": e.output} - # Public method: front end can call this via callable("run_install_fgmod") async def run_install_fgmod(self) -> dict: try: assets_dir = Path("/home/deck/homebrew/plugins/Decky-Framegen/assets") @@ -115,4 +114,44 @@ class Plugin: return {"exists": False} return {"exists": True} else: - return {"exists": False} \ No newline at end of file + return {"exists": False} + + # New method to list installed Steam games + async def list_installed_games(self) -> dict: + try: + steam_root = "/home/deck/.steam/steam" + library_file = Path(steam_root) / "steamapps" / "libraryfolders.vdf" + + if not library_file.exists(): + return {"status": "error", "message": "libraryfolders.vdf not found"} + + # Parse libraryfolders.vdf to get library paths + library_paths = [] + with open(library_file, "r", encoding="utf-8") as file: + for line in file: + if '"path"' in line: + path = line.split('"path"')[1].strip().strip('"').replace("\\\\", "/") + library_paths.append(path) + + # Extract game info from appmanifest files + games = [] + for library_path in library_paths: + steamapps_path = Path(library_path) / "steamapps" + if not steamapps_path.exists(): + continue + + for appmanifest in steamapps_path.glob("appmanifest_*.acf"): + with open(appmanifest, "r", encoding="utf-8") as file: + game_info = {"appid": None, "name": None} + for line in file: + if '"appid"' in line: + game_info["appid"] = line.split('"appid"')[1].strip().strip('"') + if '"name"' in line: + game_info["name"] = line.split('"name"')[1].strip().strip('"') + if game_info["appid"] and game_info["name"]: + games.append(game_info) + + return {"status": "success", "games": games} + + except Exception as e: + return {"status": "error", "message": str(e)} \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index f7e1f24..b2586dc 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -23,6 +23,11 @@ const checkFGModPath = callable< { exists: boolean } >("check_fgmod_path"); +const listInstalledGames = callable< + [], + { status: string; games: { appid: string; name: string }[] } +>("list_installed_games"); + function FGModInstallerSection() { const [installing, setInstalling] = useState(false); const [uninstalling, setUninstalling] = useState(false); @@ -225,6 +230,35 @@ function MainRunningApp() { ); } +function InstalledGamesSection() { + const [games, setGames] = useState<{ appid: string; name: string }[]>([]); + + useEffect(() => { + const fetchGames = async () => { + const result = await listInstalledGames(); + if (result.status === "success") { + setGames(result.games); + } else { + console.error("Failed to fetch games"); + } + }; + + fetchGames(); + }, []); + + return ( + + {games.map((game) => ( + + + {game.name} (AppID: {game.appid}) + + + ))} + + ); +} + export default definePlugin(() => ({ name: "Framegen Plugin", titleView:
Decky Framegen
, @@ -233,6 +267,7 @@ export default definePlugin(() => ({ <> + ), -- cgit v1.2.3