-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathsetup_linux.sh
More file actions
executable file
·379 lines (333 loc) · 12 KB
/
setup_linux.sh
File metadata and controls
executable file
·379 lines (333 loc) · 12 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#!/usr/bin/env bash
show_help() {
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --filename=<string> Set target filename for OptiScaler.dll. Options are:"
echo " - dxgi.dll"
echo " - winmm.dll"
echo " - version.dll"
echo " - dbghelp.dll"
echo " - d3d12.dll"
echo " - wininet.dll"
echo " - winhttp.dll"
echo " - OptiScaler.asi"
echo ""
echo " --overwrite=<y|n> Overwrite existing file (y/n)"
echo " --using_nvidia=<y|n> Using Nvidia GPU (y/n)"
echo " --using_dlss=<y|n> Use DLSS inputs/spoofing (y/n)"
echo " -h, --help Show this help message"
echo ""
echo "Example:"
echo " $0 --filename=dxgi.dll --overwrite=y --using_nvidia=n --using_dlss=y"
echo ""
exit 0
}
for arg in "$@"; do
case "$arg" in
-h|--help) show_help ;;
--filename=*) selected_filename="${arg#*=}" ;;
--overwrite=*) overwrite_choice="${arg#*=}" ;;
--using_nvidia=*) using_nvidia="${arg#*=}" ;;
--using_dlss=*) using_dlss="${arg#*=}" ;;
esac
done
clear
echo " :::::::: ::::::::: ::::::::::: ::::::::::: :::::::: :::::::: ::: ::: :::::::::: ::::::::: "
echo ":+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: "
echo "#+: +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ "
echo "+#+ +:+ +#++:++#+ +#+ +#+ +#++:++#++ +#+ +#++:++#++: +#+ +#++:++# +#++:++#: "
echo "+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ "
echo "#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# "
echo " ######## ### ### ########### ######## ######## ### ### ########## ########## ### ### "
echo ""
echo "Coping is strong with this one..."
echo ""
# Get the script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OPTISCALER_FILE="$SCRIPT_DIR/OptiScaler.dll"
# Remove junk files
rm -f "$SCRIPT_DIR/!! EXTRACT ALL FILES TO GAME FOLDER !!" 2>/dev/null
rm -f "$SCRIPT_DIR/setup_windows.bat" 2>/dev/null
# Check if OptiScaler.dll exists
if [ ! -f "OptiScaler.dll" ]; then
echo "OptiScaler \"OptiScaler.dll\" file is not found!"
echo "Please make sure you extracted all OptiScaler files to the game folder."
echo ""
echo "For Unreal Engine games, look for the game executable in:"
echo "- <path-to-game>/Game-or-Project-name/Binaries/Win64/"
echo "- Ignore the Engine folder"
echo ""
read -p "Press Enter to exit..."
exit 1
fi
# Unreal Engine detection (skip for headless)
if [ -d "$SCRIPT_DIR/Engine" ] && [ -z "$selected_filename" ]; then
echo "Found Engine folder, if this is an Unreal Engine game then please extract OptiScaler to #CODENAME#/Binaries/Win64"
echo ""
while true; do
read -p "Continue installation to current folder? [y/n]: " continue_choice
continue_choice=$(echo "$continue_choice" | tr -d ' ')
if [ "$continue_choice" = "y" ] || [ "$continue_choice" = "Y" ]; then
break
elif [ "$continue_choice" = "n" ] || [ "$continue_choice" = "N" ]; then
echo "Installation cancelled."
read -p "Press Enter to exit..."
exit 0
fi
done
fi
select_filename() {
# Skip if filename already set and valid
if [ -n "$selected_filename" ]; then
case "$selected_filename" in
dxgi.dll|winmm.dll|version.dll|dbghelp.dll|d3d12.dll|wininet.dll|winhttp.dll|OptiScaler.asi)
return
;;
*)
echo "Invalid filename: $selected_filename"
exit 1
;;
esac
fi
while true; do
echo ""
echo "Choose a filename for OptiScaler (default is dxgi.dll):"
echo " [1] dxgi.dll"
echo " [2] winmm.dll"
echo " [3] version.dll"
echo " [4] dbghelp.dll"
echo " [5] d3d12.dll"
echo " [6] wininet.dll"
echo " [7] winhttp.dll"
echo " [8] OptiScaler.asi"
read -p "Enter 1-8 (or press Enter for default): " filename_choice
case "$filename_choice" in
""|"1")
selected_filename="dxgi.dll"
;;
"2")
selected_filename="winmm.dll"
;;
"3")
selected_filename="version.dll"
;;
"4")
selected_filename="dbghelp.dll"
;;
"5")
selected_filename="d3d12.dll"
;;
"6")
selected_filename="wininet.dll"
;;
"7")
selected_filename="winhttp.dll"
;;
"8")
selected_filename="OptiScaler.asi"
;;
*)
clear
echo "Invalid choice. Please select a valid option."
echo ""
continue
;;
esac
# Check if file already exists
if [ -f "$selected_filename" ]; then
echo ""
echo "WARNING: $selected_filename already exists in the current folder."
echo ""
if [ -n "$overwrite_choice" ]; then
if [[ "$overwrite_choice" =~ ^(yes|y)$ ]]; then
break
else
echo "File exists and overwrite_choice=$overwrite_choice, exiting."
exit 1
fi
fi
while true; do
read -p "Do you want to overwrite it? [y/n]: " overwrite_choice
overwrite_choice=${overwrite_choice,,}
if [[ "$overwrite_choice" =~ ^(yes|y)$ ]]; then
break 2 # Break out of both loops
elif [[ "$overwrite_choice" =~ ^(no|n)$ ]]; then
clear
break # Break out of the inner loop, continue filename selection
else
clear
echo "Invalid choice. Please enter 'y' or 'n'."
fi
done
else
break # File doesn't exist, proceed
fi
done
}
select_filename
# Try to detect Nvidia
NVIDIA_DETECTED=false
if command -v nvidia-smi >/dev/null 2>&1; then
if nvidia-smi >/dev/null 2>&1; then
NVIDIA_DETECTED=true
echo "Nvidia GPU detected."
fi
fi
while [ -z "$using_nvidia" ]; do
echo ""
if [ "$NVIDIA_DETECTED" = true ]; then
default_value="y"
read -r -p "Are you using an Nvidia GPU [Y/n]: " using_nvidia
else
default_value="n"
read -r -p "Are you using an Nvidia GPU [y/N]: " using_nvidia
fi
using_nvidia=${using_nvidia,,}
using_nvidia=${using_nvidia:-$default_value}
if [[ "$using_nvidia" =~ ^(no|n)$ ]]; then
while [ -z "$using_dlss" ]; do
echo ""
read -r -p "Will you try to use DLSS inputs? (enables spoofing, required for DLSS FG, Reflex->AL2) [Y/n]: " using_dlss
using_dlss=${using_dlss,,}
using_dlss=${using_dlss:-y}
if [[ "$using_dlss" =~ ^(no|n)$ ]]; then
# Disable spoofing
config_file="OptiScaler.ini"
if [ ! -f "$config_file" ]; then
echo "Config file not found: $config_file"
read -p "Press Enter to continue..."
else
# Use sed to replace Dxgi=auto with Dxgi=false
sed -i 's/Dxgi=auto/Dxgi=false/g' "$config_file"
echo "Spoofing disabled in configuration."
fi
break
elif [[ "$using_dlss" =~ ^(yes|y)$ ]]; then
break
else
echo "Invalid choice. Please enter 'y' or 'n'."
continue
fi
done
break
elif [[ "$using_nvidia" =~ ^(yes|y)$ ]]; then
break
else
echo "Invalid choice. Please enter 'y' or 'n'."
continue
fi
done
# Rename OptiScaler file
echo ""
if [ "$overwrite_choice" = "y" ] || [ "$overwrite_choice" = "Y" ]; then
echo "Removing previous $selected_filename..."
rm -f "$selected_filename"
fi
echo "Renaming OptiScaler file to $selected_filename..."
if ! mv "$OPTISCALER_FILE" "$selected_filename"; then
echo ""
echo "ERROR: Failed to rename OptiScaler file to $selected_filename."
echo "Please check file permissions and try again."
read -p "Press Enter to exit..."
exit 1
fi
# Create uninstaller
create_uninstaller() {
cat > "remove_optiscaler.sh" << 'EOF'
#!/usr/bin/env bash
show_help() {
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --remove=<y|n> Confirm removal (y/n)"
echo " -h, --help Show this help message"
echo ""
exit 0
}
for arg in "$@"; do
case "$arg" in
-h|--help) show_help ;;
--remove=*) remove_choice="${arg#*=}" ;;
esac
done
clear
echo " :::::::: ::::::::: ::::::::::: ::::::::::: :::::::: :::::::: ::: ::: :::::::::: ::::::::: "
echo ":+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: "
echo "#+: +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ "
echo "+#+ +:+ +#++:++#+ +#+ +#+ +#++:++#++ +#+ +#++:++#++: +#+ +#++:++# +#++:++#: "
echo "+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ "
echo "#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# "
echo " ######## ### ### ########### ######## ######## ### ### ########## ########## ### ### "
echo ""
echo "Coping is strong with this one..."
echo ""
if [ -z "$remove_choice" ]; then
read -p "Do you want to remove OptiScaler? [y/n]: " remove_choice
fi
if [ "$remove_choice" = "y" ] || [ "$remove_choice" = "Y" ]; then
echo ""
echo "Removing OptiScaler files..."
# Remove OptiScaler files
rm -f OptiScaler.log
rm -f OptiScaler.ini
rm -f SELECTED_FILENAME_PLACEHOLDER
rm -f fakenvapi.dll
rm -f fakenvapi.ini
rm -f fakenvapi.log
rm -f dlssg_to_fsr3_amd_is_better.dll
rm -f dlssg_to_fsr3.log
# Remove directories
rm -rf D3D12_Optiscaler
rm -rf DlssOverrides
rm -rf Licenses
echo ""
echo "OptiScaler removed!"
echo ""
# Remove this uninstaller
rm -f "$0"
else
echo ""
echo "Operation cancelled."
echo ""
fi
if [ $# -eq 0 ]; then
read -p "Press Enter to exit..."
fi
EOF
# Replace the placeholder with the actual selected filename
sed -i "s/SELECTED_FILENAME_PLACEHOLDER/$selected_filename/g" "remove_optiscaler.sh"
# Make the uninstaller executable
chmod +x "remove_optiscaler.sh"
echo ""
echo "Uninstaller created: remove_optiscaler.sh"
echo ""
}
# Create the uninstaller
create_uninstaller
# Success message
clear
echo " OptiScaler setup completed successfully..."
echo ""
echo " ___ "
echo " (_ ' "
echo " /__ /) / () (/ "
echo " _/ / "
echo ""
# Display Wine DLL override information
echo "IMPORTANT FOR LINUX/WINE USERS:"
echo "You might need to add the renamed DLL to Wine overrides"
echo "Example, if using Steam, add this to launch options:"
echo ""
echo "WINEDLLOVERRIDES=$selected_filename=n,b %COMMAND%"
echo ""
echo "Remember: Insert key opens OptiScaler overlay, Page Up/Down for performance stats"
echo ""
# Cleanup - remove setup script
if [ $# -eq 0 ]; then
read -p "Press Enter to exit..."
fi
rm -f "$0"
exit 0