From a6955e828b1dee7b14f8021a8a470dd51d77e33e Mon Sep 17 00:00:00 2001
From: xXJSONDeruloXx <danielhimebauch@gmail.com>
Date: Fri, 3 Apr 2026 09:52:39 -0400
Subject: feat: proxy DLL name picker

Expose the proxy DLL rename as a user-selectable option across all
injection paths.  Previously hardcoded to dxgi.dll with no way to
change it short of manually prepending DLL=<name> to the Steam launch
option.

src/utils/constants.ts
- Add PROXY_DLL_OPTIONS (7 entries matching _create_renamed_copies)
  each with a label and one-line hint
- Add DEFAULT_PROXY_DLL constant (dxgi.dll) and ProxyDllValue type

src/api/index.ts
- runManualPatch now takes [directory, dll_name] so the chosen name
  reaches the backend

src/components/OptiScalerControls.tsx
- Own dllName state (default: dxgi.dll)
- Render a DropdownItem (visible when installed) showing the 7 options
  with the selected option's hint as the description
- Pass dllName down to both ClipboardCommands and ManualPatchControls

src/components/ClipboardCommands.tsx
- Accept dllName prop
- Patch command is plain ~/fgmod/fgmod %command% for the default;
  prefixed DLL=<name> ~/fgmod/fgmod %command% for any other choice

src/components/CustomPathOverride.tsx
- Accept dllName prop
- Pass it to runManualPatch
- Manual launch cmd clipboard button builds
  WINEDLLOVERRIDES="<stem>=n,b" dynamically; emits bare
  SteamDeck=0 %command% for OptiScaler.asi (ASI loader path needs no
  Wine DLL override)

main.py
- Add VALID_DLL_NAMES set (whitelist matching the renames dir)
- manual_patch_directory validates dll_name against the whitelist and
  returns an error for unknown values
- _manual_patch_directory_impl accepts dll_name param; removes the
  hardcoded "dxgi.dll" line

defaults/assets/fgmod.sh
- Fix longstanding bug: WINEDLLOVERRIDES was hardcoded to dxgi=n,b
  regardless of the DLL= env var selection.  Now derives the stem from
  $dll_name and skips the override entirely for .asi files.
---
 src/components/OptiScalerControls.tsx | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

(limited to 'src/components/OptiScalerControls.tsx')

diff --git a/src/components/OptiScalerControls.tsx b/src/components/OptiScalerControls.tsx
index 468683c..fb5d2f8 100644
--- a/src/components/OptiScalerControls.tsx
+++ b/src/components/OptiScalerControls.tsx
@@ -1,9 +1,9 @@
 import { useState, useEffect } from "react";
-import { PanelSection } from "@decky/ui";
+import { DropdownItem, PanelSection, PanelSectionRow } from "@decky/ui";
 import { runInstallFGMod, runUninstallFGMod } from "../api";
 import { OperationResult } from "./ResultDisplay";
 import { createAutoCleanupTimer } from "../utils";
-import { TIMEOUTS } from "../utils/constants";
+import { TIMEOUTS, PROXY_DLL_OPTIONS, DEFAULT_PROXY_DLL } from "../utils/constants";
 import { InstallationStatus } from "./InstallationStatus";
 import { OptiScalerHeader } from "./OptiScalerHeader";
 import { ClipboardCommands } from "./ClipboardCommands";
@@ -23,6 +23,7 @@ export function OptiScalerControls({ pathExists, setPathExists }: OptiScalerCont
   const [installResult, setInstallResult] = useState<OperationResult | null>(null);
   const [uninstallResult, setUninstallResult] = useState<OperationResult | null>(null);
   const [manualModeEnabled, setManualModeEnabled] = useState(false);
+  const [dllName, setDllName] = useState<string>(DEFAULT_PROXY_DLL);
   useEffect(() => {
     if (installResult) {
       return createAutoCleanupTimer(() => setInstallResult(null), TIMEOUTS.resultDisplay);
@@ -76,15 +77,29 @@ export function OptiScalerControls({ pathExists, setPathExists }: OptiScalerCont
       />
       
       <OptiScalerHeader pathExists={pathExists} />
-      
+
+      {pathExists === true && (
+        <PanelSectionRow>
+          <DropdownItem
+            label="Proxy DLL name"
+            description={PROXY_DLL_OPTIONS.find((o) => o.value === dllName)?.hint}
+            menuLabel="Proxy DLL name"
+            selectedOption={dllName}
+            rgOptions={PROXY_DLL_OPTIONS.map((o) => ({ data: o.value, label: o.label }))}
+            onChange={(option) => setDllName(String(option.data))}
+          />
+        </PanelSectionRow>
+      )}
+
       <ManualPatchControls
         isAvailable={pathExists === true}
         onManualModeChange={setManualModeEnabled}
+        dllName={dllName}
       />
 
       {!manualModeEnabled && (
         <>
-          <ClipboardCommands pathExists={pathExists} />
+          <ClipboardCommands pathExists={pathExists} dllName={dllName} />
           
           <InstructionCard pathExists={pathExists} />
         </>
-- 
cgit v1.2.3

