From 3fdf564138e09500c54ed9b3b6f100dfd005efe3 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Wed, 22 Jan 2025 23:24:03 -0500 Subject: add installation path detection on plugin open --- src/index.tsx | 83 +++++++++++++++++++++-------------------------------------- 1 file changed, 30 insertions(+), 53 deletions(-) (limited to 'src/index.tsx') diff --git a/src/index.tsx b/src/index.tsx index b0c1e15..2b305ee 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,25 +1,21 @@ -import { - useState, - // useEffect -} from "react"; +import { useState, useEffect } from "react"; import { PanelSection, PanelSectionRow, ButtonItem, - // Dropdown, - // DropdownOption } from "@decky/ui"; import { definePlugin, callable } from "@decky/api"; import { FaShip } from "react-icons/fa"; -// "run_install_fgmod" corresponds to the Python method run_install_fgmod() const runInstallFGMod = callable< [], { status: string; message?: string; output?: string } >("run_install_fgmod"); -// "get_installed_games" corresponds to the Python method get_installed_games() -// const fetchInstalledGames = callable<[], string>("get_installed_games"); +const checkFGModPath = callable< + [], + { exists: boolean } +>("check_fgmod_path"); function FGModInstallerSection() { const [installing, setInstalling] = useState(false); @@ -28,6 +24,15 @@ function FGModInstallerSection() { output?: string; message?: string; } | null>(null); + const [pathExists, setPathExists] = useState(null); + + useEffect(() => { + const checkPath = async () => { + const result = await checkFGModPath(); + setPathExists(result.exists); + }; + checkPath(); + }, []); const handleInstallClick = async () => { setInstalling(true); @@ -63,53 +68,17 @@ function FGModInstallerSection() { )} + {pathExists !== null && ( + +
+ {pathExists ? "Path exists" : "Path does not exist"} +
+
+ )} ); } -// function GameSelectorSection() { -// const [games, setGames] = useState([]); -// const [selectedGame, setSelectedGame] = useState(null); - -// useEffect(() => { -// const loadGames = async () => { -// const result = await fetchInstalledGames(); -// const gameList = JSON.parse(result) as { appid: string; name: string }[]; -// setGames(gameList.map((g) => ({ data: g.appid, label: g.name }))); -// }; - -// loadGames(); -// }, []); - -// return ( -// -// -// setSelectedGame(option)} -// strDefaultLabel="Select a game" -// /> -// -// {selectedGame && ( -// -//
You selected: {selectedGame.label}
-//
-// )} -//
-// ); -// } - -function MainContent() { - return ( - <> - - {/* */} - - ); -} - -// One default export, one plugin export default definePlugin(() => ({ name: "Framegen Plugin", titleView:
Framegen Plugin
, @@ -118,4 +87,12 @@ export default definePlugin(() => ({ onDismount() { console.log("Framegen Plugin unmounted"); }, -})); \ No newline at end of file +})); + +function MainContent() { + return ( + <> + + + ); +} \ No newline at end of file -- cgit v1.2.3