diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-08-18 12:08:21 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-08-18 12:08:21 -0400 |
| commit | 234ac6e00c4e9e337e4c88829deee665d1a5303c (patch) | |
| tree | 3c87165f25c1f14db991f906e7b87221bba172fd | |
| parent | 3d75e193791c18b1a0bcde5c8e80bdc24492c031 (diff) | |
| download | decky-lsfg-vk-234ac6e00c4e9e337e4c88829deee665d1a5303c.tar.gz decky-lsfg-vk-234ac6e00c4e9e337e4c88829deee665d1a5303c.zip | |
lock profile selection if game is running
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | 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<string[]>([]); const [selectedProfile, setSelectedProfile] = useState<string>(currentProfile || "decky-lsfg-vk"); const [isLoading, setIsLoading] = useState(false); + const [mainRunningApp, setMainRunningApp] = useState<AppOverview | undefined>(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 ( <PanelSection title="Select Profile"> + {/* Display currently running game info */} + {mainRunningApp && ( + <PanelSectionRow> + <div style={{ + padding: "8px 12px", + backgroundColor: "rgba(0, 255, 0, 0.1)", + borderRadius: "4px", + border: "1px solid rgba(0, 255, 0, 0.3)", + fontSize: "13px" + }}> + <strong>{mainRunningApp.display_name}</strong> running. Close game to change profile. + </div> + </PanelSectionRow> + )} + <PanelSectionRow> <Field label="" @@ -311,7 +340,7 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa rgOptions={profileOptions} selectedOption={selectedProfile} onChange={handleDropdownChange} - disabled={isLoading} + disabled={isLoading || !!mainRunningApp} /> </Field> </PanelSectionRow> @@ -320,7 +349,7 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa <ButtonItem layout="below" onClick={handleRenameProfile} - disabled={isLoading || selectedProfile === "decky-lsfg-vk"} + disabled={isLoading || selectedProfile === "decky-lsfg-vk" || !!mainRunningApp} > Rename </ButtonItem> @@ -330,7 +359,7 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa <ButtonItem layout="below" onClick={handleDeleteProfile} - disabled={isLoading || selectedProfile === "decky-lsfg-vk"} + disabled={isLoading || selectedProfile === "decky-lsfg-vk" || !!mainRunningApp} > Delete </ButtonItem> |
