From 234ac6e00c4e9e337e4c88829deee665d1a5303c Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Mon, 18 Aug 2025 12:08:21 -0400 Subject: lock profile selection if game is running --- package.json | 2 +- src/components/ProfileManagement.tsx | 47 +++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 9751add..7fcd3bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "decky-lossless-scaling-vk", - "version": "0.10.1", + "version": "0.10.2", "description": "Use Lossless Scaling on the Steam Deck using the lsfg-vk vulkan layer", "type": "module", "scripts": { diff --git a/src/components/ProfileManagement.tsx b/src/components/ProfileManagement.tsx index 67f0645..46c507c 100644 --- a/src/components/ProfileManagement.tsx +++ b/src/components/ProfileManagement.tsx @@ -11,7 +11,9 @@ import { ButtonItem, ModalRoot, TextField, - Focusable + Focusable, + AppOverview, + Router } from "@decky/ui"; import { getProfiles, @@ -24,11 +26,6 @@ import { } from "../api/lsfgApi"; import { showSuccessToast, showErrorToast } from "../utils/toastUtils"; -interface ProfileManagementProps { - currentProfile?: string; - onProfileChange?: (profileName: string) => void; -} - interface TextInputModalProps { title: string; description: string; @@ -110,6 +107,7 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa const [profiles, setProfiles] = useState([]); const [selectedProfile, setSelectedProfile] = useState(currentProfile || "decky-lsfg-vk"); const [isLoading, setIsLoading] = useState(false); + const [mainRunningApp, setMainRunningApp] = useState(undefined); // Load profiles on component mount useEffect(() => { @@ -123,6 +121,22 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa } }, [currentProfile]); + // Poll for running app every 2 seconds + useEffect(() => { + const checkRunningApp = () => { + setMainRunningApp(Router.MainRunningApp); + }; + + // Check immediately + checkRunningApp(); + + // Set up polling interval + const interval = setInterval(checkRunningApp, 2000); + + // Cleanup interval on unmount + return () => clearInterval(interval); + }, []); + const loadProfiles = async () => { try { const result: ProfilesResult = await getProfiles(); @@ -301,6 +315,21 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa return ( + {/* Display currently running game info */} + {mainRunningApp && ( + +
+ {mainRunningApp.display_name} running. Close game to change profile. +
+
+ )} + @@ -320,7 +349,7 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa Rename @@ -330,7 +359,7 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa Delete -- cgit v1.2.3