fix(plugin): add manual game name input, autostart MangoHud logging
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import {
|
||||
ButtonItem,
|
||||
PanelSection,
|
||||
PanelSectionRow,
|
||||
TextField,
|
||||
staticClasses,
|
||||
} from "@decky/ui"
|
||||
import {
|
||||
FaPlay,
|
||||
FaStop,
|
||||
FaClock,
|
||||
FaGamepad,
|
||||
} from "react-icons/fa"
|
||||
import type { RecordingState, SessionData, RecentSession, PluginSettings } from "../lib/store"
|
||||
import SessionForm from "./session-form"
|
||||
@@ -25,6 +26,7 @@ interface MainPanelProps {
|
||||
onAddToRecent: (sess: SessionData) => void
|
||||
onReset: () => void
|
||||
setError: (msg: string) => void
|
||||
setGameName: (name: string, appId?: number) => void
|
||||
}
|
||||
|
||||
export default function MainPanel({
|
||||
@@ -39,6 +41,7 @@ export default function MainPanel({
|
||||
onAddToRecent,
|
||||
onReset,
|
||||
setError,
|
||||
setGameName,
|
||||
}: MainPanelProps) {
|
||||
const [elapsed, setElapsed] = useState(0)
|
||||
|
||||
@@ -123,12 +126,22 @@ export default function MainPanel({
|
||||
)}
|
||||
|
||||
{recordingState === "idle" && (
|
||||
<>
|
||||
<PanelSectionRow>
|
||||
<TextField
|
||||
label="Game Name"
|
||||
value={session.gameName}
|
||||
onChange={(e) => setGameName(e.target.value)}
|
||||
placeholder="e.g. Cyberpunk 2077"
|
||||
/>
|
||||
</PanelSectionRow>
|
||||
<PanelSectionRow>
|
||||
<div className={staticClasses.Text} style={{ padding: "8px 0", fontSize: "12px", opacity: 0.7 }}>
|
||||
Enable MangoHud for your game, then press Start Recording before launching.
|
||||
Configure MangoHud in the Settings tab.
|
||||
</div>
|
||||
</PanelSectionRow>
|
||||
</>
|
||||
)}
|
||||
|
||||
{recentSessions.length > 0 && recordingState === "idle" && (
|
||||
|
||||
@@ -36,6 +36,7 @@ function Content() {
|
||||
reset,
|
||||
onGameStart,
|
||||
onGameStop,
|
||||
setGameName,
|
||||
} = useSession()
|
||||
const gameStartedUnregRef = useRef<{ unregister: () => void } | null>(null)
|
||||
const gameStoppedUnregRef = useRef<{ unregister: () => void } | null>(null)
|
||||
@@ -159,6 +160,7 @@ function Content() {
|
||||
onAddToRecent={addToRecent}
|
||||
onReset={reset}
|
||||
setError={setError}
|
||||
setGameName={setGameName}
|
||||
/>
|
||||
<SettingsPanel
|
||||
settings={settings}
|
||||
|
||||
@@ -171,6 +171,13 @@ export function useSession() {
|
||||
currentAppNameRef.current = ""
|
||||
}, [])
|
||||
|
||||
// Manual game name override (fallback when SteamClient events don't fire)
|
||||
const setGameName = useCallback((name: string, appId?: number) => {
|
||||
currentAppNameRef.current = name
|
||||
if (appId !== undefined) currentAppIdRef.current = appId
|
||||
setSession((prev) => ({ ...prev, gameName: name, appId: appId ?? prev.appId }))
|
||||
}, [])
|
||||
|
||||
return {
|
||||
recordingState,
|
||||
session,
|
||||
@@ -184,6 +191,7 @@ export function useSession() {
|
||||
reset,
|
||||
onGameStart,
|
||||
onGameStop,
|
||||
setGameName,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user