summaryrefslogtreecommitdiff
path: root/src/components/GameConfigurationControls.tsx
blob: 6bea2e01032eaf9eef7c2b062a1564bb7c224297 (plain)
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
import { ConfigurationData } from "../config/configSchema";
import type { GameTarget } from "../hooks/useGameConfiguration";
import { ConfigurationSection } from "./ConfigurationSection";
import { FpsMultiplierControl } from "./FpsMultiplierControl";
import { WorkaroundsSection } from "./WorkaroundsSection";

interface Props {
  config: ConfigurationData;
  onConfigChange: (fieldName: keyof ConfigurationData, value: boolean | number | string | string[]) => Promise<void>;
  autoFocusFpsMultiplier?: boolean;
  onFpsMultiplierFocused?: () => void;
  showWorkarounds?: boolean;
  workaroundTarget?: Pick<GameTarget, "appid" | "nonSteam" | "transport">;
  onRepairWorkaround?: () => Promise<boolean>;
}

export function GameConfigurationControls({
  config,
  onConfigChange,
  autoFocusFpsMultiplier,
  onFpsMultiplierFocused,
  showWorkarounds = false,
  workaroundTarget,
  onRepairWorkaround,
}: Props) {
  return (
    <>
      <FpsMultiplierControl
        config={config}
        onConfigChange={onConfigChange}
        autoFocus={autoFocusFpsMultiplier}
        onAutoFocus={onFpsMultiplierFocused}
      />
      <ConfigurationSection config={config} onConfigChange={onConfigChange} />
      {showWorkarounds && workaroundTarget && (
        <WorkaroundsSection
          appId={workaroundTarget.appid}
          nonSteam={workaroundTarget.nonSteam}
          transport={workaroundTarget.transport}
          onRepair={onRepairWorkaround}
        />
      )}
    </>
  );
}