From bf042515f4c90b951bcd323eb21a54c8ac8fada2 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Sat, 19 Jul 2025 13:33:22 -0400 Subject: add script and conf views to nerd modal --- src/api/lsfgApi.ts | 9 +++ src/components/NerdStuffModal.tsx | 149 +++++++++++++++++++++++++++++--------- 2 files changed, 122 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/api/lsfgApi.ts b/src/api/lsfgApi.ts index 4c23955..74caa57 100644 --- a/src/api/lsfgApi.ts +++ b/src/api/lsfgApi.ts @@ -80,6 +80,13 @@ export interface LaunchOptionResult { explanation: string; } +export interface FileContentResult { + success: boolean; + content?: string; + path?: string; + error?: string; +} + // API functions export const installLsfgVk = callable<[], InstallationResult>("install_lsfg_vk"); export const uninstallLsfgVk = callable<[], InstallationResult>("uninstall_lsfg_vk"); @@ -89,6 +96,8 @@ export const getDllStats = callable<[], DllStatsResult>("get_dll_stats"); export const getLsfgConfig = callable<[], ConfigResult>("get_lsfg_config"); export const getConfigSchema = callable<[], ConfigSchemaResult>("get_config_schema"); export const getLaunchOption = callable<[], LaunchOptionResult>("get_launch_option"); +export const getConfigFileContent = callable<[], FileContentResult>("get_config_file_content"); +export const getLaunchScriptContent = callable<[], FileContentResult>("get_launch_script_content"); // Updated config function using centralized configuration export const updateLsfgConfig = callable< diff --git a/src/components/NerdStuffModal.tsx b/src/components/NerdStuffModal.tsx index 4dd53b1..104e772 100644 --- a/src/components/NerdStuffModal.tsx +++ b/src/components/NerdStuffModal.tsx @@ -4,7 +4,7 @@ import { Field, Focusable } from "@decky/ui"; -import { getDllStats, DllStatsResult } from "../api/lsfgApi"; +import { getDllStats, DllStatsResult, getConfigFileContent, getLaunchScriptContent, FileContentResult } from "../api/lsfgApi"; interface NerdStuffModalProps { closeModal?: () => void; @@ -12,24 +12,35 @@ interface NerdStuffModalProps { export function NerdStuffModal({ closeModal }: NerdStuffModalProps) { const [dllStats, setDllStats] = useState(null); + const [configContent, setConfigContent] = useState(null); + const [scriptContent, setScriptContent] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { - const loadDllStats = async () => { + const loadData = async () => { try { setLoading(true); setError(null); - const result = await getDllStats(); - setDllStats(result); + + // Load all data in parallel + const [dllResult, configResult, scriptResult] = await Promise.all([ + getDllStats(), + getConfigFileContent(), + getLaunchScriptContent() + ]); + + setDllStats(dllResult); + setConfigContent(configResult); + setScriptContent(scriptResult); } catch (err) { - setError(err instanceof Error ? err.message : "Failed to load DLL stats"); + setError(err instanceof Error ? err.message : "Failed to load data"); } finally { setLoading(false); } }; - loadDllStats(); + loadData(); }, []); const formatSHA256 = (hash: string) => { @@ -49,44 +60,110 @@ export function NerdStuffModal({ closeModal }: NerdStuffModalProps) { return ( {loading && ( -
Loading DLL information...
+
Loading information...
)} {error && (
Error: {error}
)} - {!loading && !error && dllStats && ( + {!loading && !error && ( <> - {!dllStats.success ? ( -
{dllStats.error || "Failed to get DLL stats"}
- ) : ( -
- - dllStats.dll_path && copyToClipboard(dllStats.dll_path)} - onActivate={() => dllStats.dll_path && copyToClipboard(dllStats.dll_path)} - > - {dllStats.dll_path || "Not available"} - - - - - dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)} - onActivate={() => dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)} - > - {dllStats.dll_sha256 ? formatSHA256(dllStats.dll_sha256) : "Not available"} - - - - {dllStats.dll_source && ( - -
{dllStats.dll_source}
-
+ {/* DLL Stats Section */} + {dllStats && ( + <> + {!dllStats.success ? ( +
{dllStats.error || "Failed to get DLL stats"}
+ ) : ( +
+ + dllStats.dll_path && copyToClipboard(dllStats.dll_path)} + onActivate={() => dllStats.dll_path && copyToClipboard(dllStats.dll_path)} + > + {dllStats.dll_path || "Not available"} + + + + + dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)} + onActivate={() => dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)} + > + {dllStats.dll_sha256 ? formatSHA256(dllStats.dll_sha256) : "Not available"} + + + + {dllStats.dll_source && ( + +
{dllStats.dll_source}
+
+ )} +
)} - -
+ + )} + + {/* Launch Script Section */} + {scriptContent && ( + + {!scriptContent.success ? ( +
Script not found: {scriptContent.error}
+ ) : ( +
+
+ Path: {scriptContent.path} +
+ scriptContent.content && copyToClipboard(scriptContent.content)} + onActivate={() => scriptContent.content && copyToClipboard(scriptContent.content)} + > +
+                      {scriptContent.content || "No content"}
+                    
+
+
+ )} +
+ )} + + {/* Config File Section */} + {configContent && ( + + {!configContent.success ? ( +
Config not found: {configContent.error}
+ ) : ( +
+
+ Path: {configContent.path} +
+ configContent.content && copyToClipboard(configContent.content)} + onActivate={() => configContent.content && copyToClipboard(configContent.content)} + > +
+                      {configContent.content || "No content"}
+                    
+
+
+ )} +
)} )} -- cgit v1.2.3