blob: 026d5460e2c7f1d3d9e312d3f897c4b815cdeeac (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#!/usr/bin/env bash
set -x # Enable debugging
exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors
error_exit() {
echo "$1"
if [[ -n $STEAM_ZENITY ]]; then
$STEAM_ZENITY --error --text "$1"
else
zenity --error --text "$1"
fi
exit 1
}
mod_path="/usr/share/fgmod"
if [ "$#" -lt 1 ]; then
echo "Usage: $0 program [program_arguments...]"
exit 1
fi
# One arg means the command is ran standalone
if [[ $# -eq 1 ]]; then
if [[ "$1" == *.exe ]]; then
exe_folder_path=$(dirname "$1")
else
exe_folder_path=$1
fi
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" == *"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}
exe_folder_path=$(dirname "$arg")
break
fi
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
# 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")
fi
if [[ -d $exe_folder_path ]]; then
if [[ ! -w $exe_folder_path ]]; then
error_exit "No write permission to the game folder!"
fi
original_dlls=("d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll")
# 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
cp -f "$mod_path/fgmod-uninstaller.sh" "$exe_folder_path" ||
error_exit "Couldn't copy the uninstaller!"
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!"
# 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
cp -f "$mod_path/_nvngx.dll" "$exe_folder_path" ||
error_exit "Couldn't copy _nvngx.dll!"
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!"
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!"
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
if [[ $# -gt 1 ]]; then
# Log to both file and system journal
logger -t fgmod "=================="
logger -t fgmod "Debug Info (Launch Mode):"
logger -t fgmod "Number of arguments: $#"
for i in $(seq 1 $#); do
logger -t fgmod "Arg $i: ${!i}"
done
logger -t fgmod "Final executable path: $exe_folder_path"
logger -t fgmod "=================="
# Execute the original command
export SteamDeck=0
export WINEDLLOVERRIDES="$WINEDLLOVERRIDES,dxgi=n,b"
"$@"
else
echo "Done!"
echo "----------------------------------------"
echo "Debug Info (Standalone Mode):"
echo "Number of arguments: $#"
for i in $(seq 1 $#); do
echo "Arg $i: ${!i}"
done
echo "Final executable path: $exe_folder_path"
echo "----------------------------------------"
# Also log standalone mode to journal
logger -t fgmod "=================="
logger -t fgmod "Debug Info (Standalone Mode):"
logger -t fgmod "Number of arguments: $#"
for i in $(seq 1 $#); do
logger -t fgmod "Arg $i: ${!i}"
done
logger -t fgmod "Final executable path: $exe_folder_path"
logger -t fgmod "=================="
fi
|