From 9e4dcc39af0aeacf47e1fb1cd8ec22635040d2ae Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Tue, 21 Jan 2025 22:51:09 -0500 Subject: trying script approach? --- src/index.tsx | 59 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/index.tsx b/src/index.tsx index e8db057..011ce22 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,37 +1,46 @@ -import { useState, useEffect } from "react"; -import { PanelSection, PanelSectionRow, Dropdown, DropdownOption } from "@decky/ui"; +import { useState } from "react"; +import { PanelSection, PanelSectionRow, ButtonItem } from "@decky/ui"; import { callable, definePlugin } from "@decky/api"; import { FaShip } from "react-icons/fa"; -const fetchInstalledGames = callable<[], string>("get_installed_games"); +const runInstallFGMod = callable<[], { status: string; message?: string; output?: string }>("run_install_fgmod"); function Content() { - 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(game => ({ data: game.appid, label: game.name }))); - }; + const [installing, setInstalling] = useState(false); + const [installResult, setInstallResult] = useState<{ status: string; output?: string; message?: string } | null>( + null + ); - loadGames(); - }, []); + const handleInstallClick = async () => { + setInstalling(true); + const result = await runInstallFGMod(); + setInstalling(false); + setInstallResult(result); + }; return ( - + - setSelectedGame(option)} - strDefaultLabel="Select a game" // Placeholder equivalent - /> + + {installing ? "Installing..." : "Install FG Mod"} + - {selectedGame && ( + {installResult && ( -
You selected: {selectedGame.label}
+
+ Status: {installResult.status === "success" ? "Success" : "Error"}
+ {installResult.output && ( + <> + Output: +
{installResult.output}
+ + )} + {installResult.message && ( + <> + Error: {installResult.message} + + )} +
)}
@@ -39,8 +48,8 @@ function Content() { } export default definePlugin(() => ({ - name: "Game Selector Plugin", - titleView:
Game Selector Plugin
, + name: "FG Mod Installer", + titleView:
FG Mod Installer
, content: , icon: , onDismount() { -- cgit v1.2.3