summaryrefslogtreecommitdiff
path: root/defaults/assets/fgmod.sh
diff options
context:
space:
mode:
authorKurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>2025-07-17 00:28:42 -0400
committerGitHub <noreply@github.com>2025-07-17 00:28:42 -0400
commit74ac6e7b7a18c2ae969b08242a5919f903d294e2 (patch)
treee6d48b345c4933ea21a83ef6e2dc315ba9a990f3 /defaults/assets/fgmod.sh
parente905b94fe5b40b438f2ce63caad90760fea7fc9a (diff)
downloadDecky-Framegen-74ac6e7b7a18c2ae969b08242a5919f903d294e2.tar.gz
Decky-Framegen-74ac6e7b7a18c2ae969b08242a5919f903d294e2.zip
v0.10.0 initial implementation of proper optiscaler nightly statically linked (#113)
* initial implementation of proper optiscaler nightly statically linked * default ini to nukems on mod dir install * description tweaks
Diffstat (limited to 'defaults/assets/fgmod.sh')
-rwxr-xr-xdefaults/assets/fgmod.sh130
1 files changed, 67 insertions, 63 deletions
diff --git a/defaults/assets/fgmod.sh b/defaults/assets/fgmod.sh
index 026d546..134ded0 100755
--- a/defaults/assets/fgmod.sh
+++ b/defaults/assets/fgmod.sh
@@ -1,42 +1,41 @@
#!/usr/bin/env bash
-set -x # Enable debugging
-exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors
+set -x
+exec > >(tee -i /tmp/fgmod-install.log) 2>&1
error_exit() {
- echo "$1"
+ echo "❌ $1"
if [[ -n $STEAM_ZENITY ]]; then
$STEAM_ZENITY --error --text "$1"
else
- zenity --error --text "$1"
+ zenity --error --text "$1" || echo "Zenity failed to display error"
fi
+ logger -t fgmod "❌ ERROR: $1"
exit 1
}
-mod_path="/usr/share/fgmod"
+# === CONFIG ===
+fgmod_path="$HOME/fgmod"
+dll_name="${DLL:-dxgi.dll}"
+preserve_ini="${PRESERVE_INI:-true}"
-if [ "$#" -lt 1 ]; then
- echo "Usage: $0 program [program_arguments...]"
- exit 1
+# === Resolve Game Path ===
+if [[ "$#" -lt 1 ]]; then
+ error_exit "Usage: $0 program [program_arguments...]"
fi
-# One arg means the command is ran standalone
+exe_folder_path=""
if [[ $# -eq 1 ]]; then
- if [[ "$1" == *.exe ]]; then
- exe_folder_path=$(dirname "$1")
- else
- exe_folder_path=$1
- fi
+ [[ "$1" == *.exe ]] && exe_folder_path=$(dirname "$1") || exe_folder_path="$1"
else
for arg in "$@"; do
if [[ "$arg" == *.exe ]]; then
- # Special cases, only FG-supported games
[[ "$arg" == *"Cyberpunk 2077"* ]] && arg=${arg//REDprelauncher.exe/bin/x64/Cyberpunk2077.exe}
[[ "$arg" == *"Witcher 3"* ]] && arg=${arg//REDprelauncher.exe/bin/x64_dx12/witcher3.exe}
[[ "$arg" == *"HITMAN 3"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe}
[[ "$arg" == *"HITMAN World of Assassination"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe}
- [[ "$arg" == *"SYNCED"* ]] && arg=${arg//Launcher\/sop_launcher.exe/SYNCED.exe} # UE with a launcher
- [[ "$arg" == *"2KLauncher"* ]] && arg=${arg//2KLauncher\/LauncherPatcher.exe/DoesntMatter.exe} # 2K launcher games
+ [[ "$arg" == *"SYNCED"* ]] && arg=${arg//Launcher\/sop_launcher.exe/SYNCED.exe}
+ [[ "$arg" == *"2KLauncher"* ]] && arg=${arg//2KLauncher\/LauncherPatcher.exe/DoesntMatter.exe}
[[ "$arg" == *"Warhammer 40,000 DARKTIDE"* ]] && arg=${arg//launcher\/Launcher.exe/binaries/Darktide.exe}
[[ "$arg" == *"Warhammer Vermintide 2"* ]] && arg=${arg//launcher\/Launcher.exe/binaries_dx12/vermintide2_dx12.exe}
[[ "$arg" == *"Satisfactory"* ]] && arg=${arg//FactoryGameSteam.exe/Engine/Binaries/Win64/FactoryGameSteam-Win64-Shipping.exe}
@@ -46,65 +45,70 @@ else
done
fi
-# Fallback to STEAM_COMPAT_INSTALL_PATH when no path was found
-if [[ ! -d $exe_folder_path ]] && [[ -n ${STEAM_COMPAT_INSTALL_PATH} ]]; then
- echo "Trying the path from STEAM_COMPAT_INSTALL_PATH"
- exe_folder_path=${STEAM_COMPAT_INSTALL_PATH}
-fi
+[[ -z "$exe_folder_path" && -n "$STEAM_COMPAT_INSTALL_PATH" ]] && exe_folder_path="$STEAM_COMPAT_INSTALL_PATH"
-# Check for UE games
if [[ -d "$exe_folder_path/Engine" ]]; then
- ue_exe_path=$(find "$exe_folder_path" -maxdepth 4 -mindepth 4 -path "*Binaries/Win64/*.exe" -not -path "*/Engine/*" | head -1)
- exe_folder_path=$(dirname "$ue_exe_path")
+ ue_exe=$(find "$exe_folder_path" -maxdepth 4 -mindepth 4 -path "*Binaries/Win64/*.exe" -not -path "*/Engine/*" | head -1)
+ exe_folder_path=$(dirname "$ue_exe")
fi
-if [[ -d $exe_folder_path ]]; then
- if [[ ! -w $exe_folder_path ]]; then
- error_exit "No write permission to the game folder!"
- fi
+[[ ! -d "$exe_folder_path" ]] && error_exit "❌ Could not resolve game directory!"
+[[ ! -w "$exe_folder_path" ]] && error_exit "🛑 No write permission to the game folder!"
- original_dlls=("d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll")
+logger -t fgmod "🟢 Target directory: $exe_folder_path"
+logger -t fgmod "🧩 Using DLL name: $dll_name"
+logger -t fgmod "📄 Preserve INI: $preserve_ini"
- # Assume that the mod is not installed when dlss-enabler.dll is not present
- if [[ ! -f "$exe_folder_path/dlss-enabler.dll" ]]; then
- [[ -f "$exe_folder_path/dxgi.dll" ]] && error_exit 'dxgi.dll is already present in the game folder!\nThis script uses dxgi.dll to load required files.\nRemove the mod using dxgi.dll or install DLSS Enabler manually.'
- for dll in "${original_dlls[@]}"; do
- if [[ ! -f "$exe_folder_path/${dll}.b" ]]; then
- mv -f "$exe_folder_path/$dll" "$exe_folder_path/${dll}.b" 2>/dev/null
- fi
- done
- fi
+# === Cleanup Old Injectors ===
+rm -f "$exe_folder_path"/{dxgi.dll,winmm.dll,nvngx.dll,_nvngx.dll,nvngx-wrapper.dll,dlss-enabler.dll,OptiScaler.dll}
- cp -f "$mod_path/fgmod-uninstaller.sh" "$exe_folder_path" ||
- error_exit "Couldn't copy the uninstaller!"
+# === Optional: Backup Original DLLs ===
+original_dlls=("d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll" "nvapi64.dll" "amdxcffx64.dll")
+for dll in "${original_dlls[@]}"; do
+ [[ -f "$exe_folder_path/$dll" && ! -f "$exe_folder_path/$dll.b" ]] && mv -f "$exe_folder_path/$dll" "$exe_folder_path/$dll.b"
+done
- cp -f "$mod_path/dlss-enabler.dll" "$exe_folder_path" &&
- cp -f "$mod_path/dxgi.dll" "$exe_folder_path" &&
- cp -f "$mod_path/nvngx-wrapper.dll" "$exe_folder_path" ||
- error_exit "Couldn't copy DLSS Enabler files!"
+# === Core Install ===
+if [[ -f "$fgmod_path/renames/$dll_name" ]]; then
+ echo "✅ Using pre-renamed $dll_name"
+ cp "$fgmod_path/renames/$dll_name" "$exe_folder_path/$dll_name" || error_exit "❌ Failed to copy $dll_name"
+else
+ echo "⚠️ Pre-renamed $dll_name not found, falling back to OptiScaler.dll"
+ cp "$fgmod_path/OptiScaler.dll" "$exe_folder_path/$dll_name" || error_exit "❌ Failed to copy OptiScaler.dll as $dll_name"
+fi
- # File is not preset on Nvidia installs so will fail on some setups on purpose
- cp -f "$mod_path/nvapi64.dll" "$exe_folder_path" 2>/dev/null
+# === OptiScaler.ini Handling ===
+if [[ "$preserve_ini" == "true" && -f "$exe_folder_path/OptiScaler.ini" ]]; then
+ echo "📄 Preserving existing OptiScaler.ini (user settings retained)"
+ logger -t fgmod "📄 Existing OptiScaler.ini preserved in $exe_folder_path"
+else
+ echo "📄 Installing OptiScaler.ini from plugin defaults"
+ cp "$fgmod_path/OptiScaler.ini" "$exe_folder_path/OptiScaler.ini" || error_exit "❌ Failed to copy OptiScaler.ini"
+ logger -t fgmod "📄 OptiScaler.ini installed to $exe_folder_path"
+fi
- cp -f "$mod_path/_nvngx.dll" "$exe_folder_path" ||
- error_exit "Couldn't copy _nvngx.dll!"
+# === Supporting Libraries ===
+cp -f "$fgmod_path/libxess.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/amd_fidelityfx_dx12.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/amd_fidelityfx_vk.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/nvngx.dll" "$exe_folder_path/" || true
- cp -f "$mod_path/dlssg_to_fsr3_amd_is_better.dll" "$exe_folder_path" &&
- cp -f "$mod_path/dlssg_to_fsr3_amd_is_better-3.0.dll" "$exe_folder_path" ||
- error_exit "Couldn't copy dlssg-to-fsr3!"
+# === Nukem FG Mod Files (now in fgmod directory) ===
+cp -f "$fgmod_path/dlssg_to_fsr3_amd_is_better.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/dlssg_to_fsr3.ini" "$exe_folder_path/" || true
+cp -f "$fgmod_path/nvapi64.dll" "$exe_folder_path/" || true
+cp -f "$fgmod_path/fakenvapi.ini" "$exe_folder_path/" || true
+cp -f "$fgmod_path/amdxcffx64.dll" "$exe_folder_path/" || true
- cp -f "$mod_path/dlss-enabler-upscaler.dll" "$exe_folder_path" &&
- cp -f "$mod_path/amd_fidelityfx_dx12.dll" "$exe_folder_path" &&
- cp -f "$mod_path/amd_fidelityfx_vk.dll" "$exe_folder_path" &&
- cp -f "$mod_path/d3dcompiler_47.dll" "$exe_folder_path" ||
- error_exit "Couldn't copy Optiscaler files!"
+# === Additional Support Files ===
+cp -f "$fgmod_path/d3dcompiler_47.dll" "$exe_folder_path/" || true
- cp -n "$mod_path/nvngx.ini" "$exe_folder_path"
- cp -n "$mod_path/fakenvapi.ini" "$exe_folder_path"
-else
- error_exit "Path doesn't exist!"
-fi
+echo "✅ Installation completed successfully!"
+echo "📄 For Steam, add this to the launch options: \"$fgmod_path/fgmod\" %COMMAND%"
+echo "📄 For Heroic, add this as a new wrapper: \"$fgmod_path/fgmod\""
+logger -t fgmod "🟢 Installation completed successfully for $exe_folder_path"
+# === Execute original command ===
if [[ $# -gt 1 ]]; then
# Log to both file and system journal
logger -t fgmod "=================="
@@ -119,7 +123,7 @@ if [[ $# -gt 1 ]]; then
# Execute the original command
export SteamDeck=0
export WINEDLLOVERRIDES="$WINEDLLOVERRIDES,dxgi=n,b"
- "$@"
+ exec "$@"
else
echo "Done!"
echo "----------------------------------------"