From 871cdbd04df02b32dbdd07467720b6eb9537178a Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Wed, 22 Jan 2025 21:45:23 -0500 Subject: refactor, script status now displaying --- src/index.tsx | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 13 deletions(-) (limited to 'src/index.tsx') diff --git a/src/index.tsx b/src/index.tsx index 011ce22..afb3cdd 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,15 +1,30 @@ -import { useState } from "react"; -import { PanelSection, PanelSectionRow, ButtonItem } from "@decky/ui"; -import { callable, definePlugin } from "@decky/api"; +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"; -const runInstallFGMod = callable<[], { status: string; message?: string; output?: string }>("run_install_fgmod"); +// "run_install_fgmod" corresponds to the Python method run_install_fgmod() +const runInstallFGMod = callable< + [], + { status: string; message?: string; output?: string } +>("run_install_fgmod"); -function Content() { +// "get_installed_games" corresponds to the Python method get_installed_games() +const fetchInstalledGames = callable<[], string>("get_installed_games"); + +function FGModInstallerSection() { const [installing, setInstalling] = useState(false); - const [installResult, setInstallResult] = useState<{ status: string; output?: string; message?: string } | null>( - null - ); + const [installResult, setInstallResult] = useState<{ + status: string; + output?: string; + message?: string; + } | null>(null); const handleInstallClick = async () => { setInstalling(true); @@ -28,7 +43,9 @@ function Content() { {installResult && (
- Status: {installResult.status === "success" ? "Success" : "Error"}
+ Status:{" "} + {installResult.status === "success" ? "Success" : "Error"} +
{installResult.output && ( <> Output: @@ -47,12 +64,55 @@ function Content() { ); } +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: "FG Mod Installer", - titleView:
FG Mod Installer
, - content: , + name: "Framegen Plugin", + titleView:
Framegen Plugin
, + content: , icon: , onDismount() { - console.log("Plugin unmounted"); + console.log("Framegen Plugin unmounted"); }, })); \ No newline at end of file -- cgit v1.2.3