diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-18 20:59:47 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-18 20:59:47 -0400 |
| commit | fb3d3d4d3414394237cc9d664d65c14be179927f (patch) | |
| tree | a4f3bcc67983ef012893b6a14013150026b123db | |
| parent | b9302548a4def670c8600086ba8685c075ceac3d (diff) | |
| download | decky-lsfg-vk-fb3d3d4d3414394237cc9d664d65c14be179927f.tar.gz decky-lsfg-vk-fb3d3d4d3414394237cc9d664d65c14be179927f.zip | |
add nerd stuff modal with dll details
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/plugin.py | 62 | ||||
| -rw-r--r-- | src/api/lsfgApi.ts | 9 | ||||
| -rw-r--r-- | src/components/Content.tsx | 17 | ||||
| -rw-r--r-- | src/components/NerdStuffModal.tsx | 95 | ||||
| -rw-r--r-- | src/components/index.ts | 1 |
6 files changed, 184 insertions, 2 deletions
diff --git a/package.json b/package.json index d224bf6..54135fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lossless-scaling-vk", - "version": "0.6.1", + "version": "0.6.2", "description": "Use Lossless Scaling on the Steam Deck using the lsfg-vk vulkan layer", "type": "module", "scripts": { diff --git a/py_modules/lsfg_vk/plugin.py b/py_modules/lsfg_vk/plugin.py index a44840d..60eab8c 100644 --- a/py_modules/lsfg_vk/plugin.py +++ b/py_modules/lsfg_vk/plugin.py @@ -10,6 +10,7 @@ import json import subprocess import urllib.request import ssl +import hashlib from typing import Dict, Any from pathlib import Path @@ -101,6 +102,67 @@ class Plugin: return result_dict + async def get_dll_stats(self) -> Dict[str, Any]: + """Get detailed statistics about the detected DLL + + Returns: + Dict containing DLL path, SHA256 hash, and other stats + """ + try: + # First check if DLL is detected + dll_result = self.dll_detection_service.check_lossless_scaling_dll() + + if not dll_result.get("detected") or not dll_result.get("path"): + return { + "success": False, + "error": "DLL not detected", + "dll_path": None, + "dll_sha256": None + } + + dll_path = dll_result["path"] + if dll_path is None: + return { + "success": False, + "error": "DLL path is None", + "dll_path": None, + "dll_sha256": None + } + + dll_path_obj = Path(dll_path) + + # Calculate SHA256 hash + sha256_hash = hashlib.sha256() + try: + with open(dll_path_obj, "rb") as f: + # Read file in chunks to handle large files efficiently + for chunk in iter(lambda: f.read(4096), b""): + sha256_hash.update(chunk) + dll_sha256 = sha256_hash.hexdigest() + except Exception as e: + return { + "success": False, + "error": f"Failed to calculate SHA256: {str(e)}", + "dll_path": dll_path, + "dll_sha256": None + } + + return { + "success": True, + "dll_path": dll_path, + "dll_sha256": dll_sha256, + "dll_source": dll_result.get("source"), + "error": None + } + + except Exception as e: + return { + "success": False, + "error": f"Failed to get DLL stats: {str(e)}", + "dll_path": None, + "dll_sha256": None + } + # Configuration methods async def get_lsfg_config(self) -> Dict[str, Any]: """Read current lsfg script configuration diff --git a/src/api/lsfgApi.ts b/src/api/lsfgApi.ts index 5770c43..5bf2dc2 100644 --- a/src/api/lsfgApi.ts +++ b/src/api/lsfgApi.ts @@ -28,6 +28,14 @@ export interface DllDetectionResult { error?: string; } +export interface DllStatsResult { + success: boolean; + dll_path?: string; + dll_sha256?: string; + dll_source?: string; + error?: string; +} + // Use centralized configuration data type export type LsfgConfig = ConfigurationData; @@ -77,6 +85,7 @@ export const installLsfgVk = callable<[], InstallationResult>("install_lsfg_vk") export const uninstallLsfgVk = callable<[], InstallationResult>("uninstall_lsfg_vk"); export const checkLsfgVkInstalled = callable<[], InstallationStatus>("check_lsfg_vk_installed"); export const checkLosslessScalingDll = callable<[], DllDetectionResult>("check_lossless_scaling_dll"); +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"); diff --git a/src/components/Content.tsx b/src/components/Content.tsx index 613e722..9ce4c35 100644 --- a/src/components/Content.tsx +++ b/src/components/Content.tsx @@ -1,5 +1,5 @@ import { useEffect } from "react"; -import { PanelSection } from "@decky/ui"; +import { PanelSection, showModal, ButtonItem, PanelSectionRow } from "@decky/ui"; import { useInstallationStatus, useDllDetection, useLsfgConfig } from "../hooks/useLsfgHooks"; import { useInstallationActions } from "../hooks/useInstallationActions"; import { StatusDisplay } from "./StatusDisplay"; @@ -9,6 +9,7 @@ import { UsageInstructions } from "./UsageInstructions"; import { WikiButton } from "./WikiButton"; import { ClipboardButton } from "./ClipboardButton"; import { PluginUpdateChecker } from "./PluginUpdateChecker"; +import { NerdStuffModal } from "./NerdStuffModal"; import { ConfigurationData } from "../config/configSchema"; export function Content() { @@ -49,6 +50,10 @@ export function Content() { handleUninstall(setIsInstalled, setInstallationStatus); }; + const handleShowNerdStuff = () => { + showModal(<NerdStuffModal />); + }; + return ( <PanelSection> <InstallationButton @@ -81,6 +86,16 @@ export function Content() { {/* Plugin Update Checker */} <PluginUpdateChecker /> + + {/* Nerd Stuff Button */} + <PanelSectionRow> + <ButtonItem + layout="below" + onClick={handleShowNerdStuff} + > + Nerd Stuff + </ButtonItem> + </PanelSectionRow> </PanelSection> ); } diff --git a/src/components/NerdStuffModal.tsx b/src/components/NerdStuffModal.tsx new file mode 100644 index 0000000..4dd53b1 --- /dev/null +++ b/src/components/NerdStuffModal.tsx @@ -0,0 +1,95 @@ +import { useState, useEffect } from "react"; +import { + ModalRoot, + Field, + Focusable +} from "@decky/ui"; +import { getDllStats, DllStatsResult } from "../api/lsfgApi"; + +interface NerdStuffModalProps { + closeModal?: () => void; +} + +export function NerdStuffModal({ closeModal }: NerdStuffModalProps) { + const [dllStats, setDllStats] = useState<DllStatsResult | null>(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState<string | null>(null); + + useEffect(() => { + const loadDllStats = async () => { + try { + setLoading(true); + setError(null); + const result = await getDllStats(); + setDllStats(result); + } catch (err) { + setError(err instanceof Error ? err.message : "Failed to load DLL stats"); + } finally { + setLoading(false); + } + }; + + loadDllStats(); + }, []); + + const formatSHA256 = (hash: string) => { + // Format SHA256 hash for better readability (add spaces every 8 characters) + return hash.replace(/(.{8})/g, '$1 ').trim(); + }; + + const copyToClipboard = async (text: string) => { + try { + await navigator.clipboard.writeText(text); + // Could add a toast notification here if desired + } catch (err) { + console.error("Failed to copy to clipboard:", err); + } + }; + + return ( + <ModalRoot onCancel={closeModal} onOK={closeModal}> + {loading && ( + <div>Loading DLL information...</div> + )} + + {error && ( + <div>Error: {error}</div> + )} + + {!loading && !error && dllStats && ( + <> + {!dllStats.success ? ( + <div>{dllStats.error || "Failed to get DLL stats"}</div> + ) : ( + <div> + <Field label="DLL Path"> + <Focusable + onClick={() => dllStats.dll_path && copyToClipboard(dllStats.dll_path)} + onActivate={() => dllStats.dll_path && copyToClipboard(dllStats.dll_path)} + > + {dllStats.dll_path || "Not available"} + </Focusable> + </Field> + + <Field label="SHA256 Hash"> + <Focusable + onClick={() => dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)} + onActivate={() => dllStats.dll_sha256 && copyToClipboard(dllStats.dll_sha256)} + > + {dllStats.dll_sha256 ? formatSHA256(dllStats.dll_sha256) : "Not available"} + </Focusable> + </Field> + + {dllStats.dll_source && ( + <Field label="Detection Source"> + <div>{dllStats.dll_source}</div> + </Field> + )} + + </div> + )} + </> + )} + </ModalRoot> + ); +} diff --git a/src/components/index.ts b/src/components/index.ts index ed0b803..c0c4804 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -7,3 +7,4 @@ export { WikiButton } from "./WikiButton"; export { ClipboardButton } from "./ClipboardButton"; export { LaunchOptionInfo } from "./LaunchOptionInfo"; export { PluginUpdateChecker } from "./PluginUpdateChecker"; +export { NerdStuffModal } from "./NerdStuffModal"; |
