1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import { ButtonItem, Field, PanelSectionRow } from "@decky/ui";
import { GameTarget } from "../hooks/useGameConfiguration";
interface Props {
targets: GameTarget[];
runningGame: GameTarget | null;
onSelect: (appid: string) => void;
onResetAll: () => Promise<void>;
}
const profileDescription = (target: GameTarget, running: boolean, active: boolean) => [
running ? "Now playing" : "",
target.nonSteam ? "Non-Steam" : "Steam",
target.configured
? active ? "Profile active" : "Profile saved · applies next launch"
: "Not configured · changes apply next launch",
].filter(Boolean).join(" · ");
export function GameConfigurationSelector({ targets, runningGame, onSelect, onResetAll }: Props) {
const games = [...targets].sort((a, b) => {
if (a.appid === runningGame?.appid) return -1;
if (b.appid === runningGame?.appid) return 1;
return a.name.localeCompare(b.name);
});
return (
<>
{games.length === 0 && (
<PanelSectionRow>
<Field label="No installed games" description="Steam has not reported any eligible games" />
</PanelSectionRow>
)}
{games.map((game) => (
<PanelSectionRow key={game.appid}>
<Field
label={game.name}
description={profileDescription(
game,
game.appid === runningGame?.appid,
game.appid === runningGame?.appid ? runningGame.configured : game.configured,
)}
onActivate={() => onSelect(game.appid)}
highlightOnFocus
/>
</PanelSectionRow>
))}
<PanelSectionRow>
<ButtonItem
layout="below"
onClick={() => void onResetAll()}
disabled={!targets.some((target) => target.configured)}
>
Remove all profiles
</ButtonItem>
</PanelSectionRow>
</>
);
}
|