-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.sh
executable file
·461 lines (319 loc) · 12.5 KB
/
generator.sh
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#!/bin/bash
# Copyright Fabxx 2023 - Software Distributed under the General Public License V3 WITHOUT ANY GUARANTEE OR WARRANTY.
# Info message for auto sort option
msg="moves roms into folders to generate start.sh per game. 2MB of free space is required.\n
If a game requires multiple files with different extensions (like duckstation with .bin and .cue),
just rename the files with the same name and keep the extension as is.\n
These emulators don't need sorting and function can be skipped:\n
-Rpcs3 JB folder\n
-Xenia extracted files with default.xex\n
-Cxbx-r extracted files with default.xbe\n "
# Emulator Arguments
xemu_args="-full-screen -dvd_path"
xenia_args="--gpu vulkan"
pcsx2_args="-fullscreen"
mgba_args="-f"
dolphin_args="--config=Dolphin.Display.Fullscreen=True"
mupen_args="--fullscreen"
cemu_args="-f -g"
rpcs3_args="--no-gui"
# Wine DLL Overrides for PC games
# Current games that use the overrides: need for speed most wanted/carbon - splinter cell 1/Pandora tomorrow/Chaos Theory - Dirt/2/3/Showdown
NFSC_MW_OVERRIDE="*d3d9,*d3d10,*d3d10_1,*d3d10core,*d3d11,*dxgi=b"
SC_SCPT_OVERRIDE="*d3d8, *msacm32, *msvfw32=n,b"
SCCT_OVERRIDE="*d3d9, *msacm32, *msvfw32=n,b"
GTA3_OVERRIDE="d3d8=n,b"
# PC Games arguments
# Current Arguments: Colin McRae Rally 2005 - Kingdom Come Deliverance - Splinter Cell Chaos Theory
CMR2005="FORCEHT WIDESCREENDISPLAY NOVIDEO"
KINGDOMDEV="-devmode"
SCCT_SKIP_VIDEO="-nointro"
isXbmcScript=2
# Rom sorter.
SortRoms()
{
zenity --question --text="sort roms into folders? If you don't know how it works please check AutoSort info in the main menu."
if [[ $? == 1 ]]; then Parser
fi
# Check disk space, remove the final char "M" from the space number.
minDiskSpace=2
freeDiskSpaceRaw=$(df --output=avail -BM "$path_games" | tail -n 1)
freeDiskSpace=${freeDiskSpaceRaw::-1}
if [[ $freeDiskSpace -lt $minDiskSpace ]]; then
zenity --error --text="Not enough space on disk to create folders! The Parser cannot sort the files"
ZenityUI
fi
# Find all files that can match the extension in the folder. Create folders with those strings and move the files into the matching folder name
cd "$path_games"
files=()
readarray -t files < <(ls *.3ds *.app *.bin *.cia *.cue *.chd *.dsi *.dol *.ecm *.elf *.gb *.gba \
*.gbc *.gcz *.ids *.img *.iso *.jpeg *.jpg *.n64 *.nds *.nsp *.png \
*.rvz *.sav *.sbi *.sfc *.smc *.v64 *.wad *.wbfs *.wud *.wux *.xci *.z64 *.zar \
)
for i in "${files[@]%.*}"; do mkdir "$i"; done
subdirs=(*/)
# Move those files that have the same name as the created folder. If the matches are done for that folder, go to the next folder.
# Example: CTR is the folder, then CTR.bin CTR.cue CTR.jpg are the files.
# remove the extension one by one and if it matches CTR, move the file into the folder.
# After the last file, go to the next folder and find the matching names.
indexdirs=0 indexfiles=0
while [[ $indexfiles -lt ${#files[@]} ]]
do
if [[ "${files[$indexfiles]%.*}" == "${subdirs[$indexdirs]%/*}" ]]; then
mv "${files[$indexfiles]}" "${subdirs[$indexdirs]}";
((indexfiles++))
indexdirs=0
else
((indexdirs++))
fi
done
}
# Parser
Parser()
{
# If the user is generating runners to launch through XBMC Python scripts, the start.sh must kill
# XBMC to avoid input priority over the UI. then if the PID of the exe doesn't exist anymore
# the sh file re-runs XBMC executable again. Extra echos are at the end before the cd ..
if [[ $isXbmcScript -ne 0 && $isXbmcScript -ne 1 ]]; then
zenity --question --text="Will you use these scripts with XBMC? Will ask only once."
if [[ $? == 1 ]]; then
isXbmcScript=0
else
isXbmcScript=1
zenity --info --text="Select XBMC.exe file"
xmbcExecutable=$(zenity --title="select XBMC executable" --file-selection)
fi
fi
for folder in "$path_games"/*; do cd "$folder";
echo -e "#!/bin/bash" "\n" > start.sh
echo -e "cd \"$(pwd)\"\n" >> start.sh
case $parserList in
1)
case $parser_ID in
1) #duckstation
echo -e \""$path_executable"\" "" \""$(ls *.cue *.iso *.img *.ecm *.chd)"\" "\n" >> start.sh
;;
2) #pcsx2
echo -e \""$path_executable"\" "" \""$(ls *.iso *.chd)"\" "" "$pcsx2_args" "\n" >> start.sh
;;
3) #ppsspp
echo -e \""$path_executable"\" "" \""$(ls *.iso)"\" "\n" >> start.sh
;;
4) #rpcs3 JB format
echo -e \""$path_executable"\" "" "$rpcs3_args" \""$(find ~+ -name 'EBOOT.BIN')"\" "\n" >> start.sh
;;
esac
;;
2)
case $parser_ID in
1) #citra
echo -e \""$path_executable"\" "" \""$(ls *.3ds *.cia)"\" "\n" >> start.sh
;;
2) #melonDS
echo -e \""$path_executable"\" "" \""$(ls *.nds *.dsi *.ids *.app)"\" "\n" >> start.sh
;;
3) #Yuzu/Ryujinx
echo -e \""$path_executable"\" "" \""$(ls *.nsp *.xci)"\" "\n" >> start.sh
;;
4) #mGBA
echo -e \""$path_executable"\" "" "$mgba_args" "" \""$(ls *.gba *.gbc *.gb)"\" "\n" >> start.sh
;;
5) #mupen64
echo -e \""$path_executable"\" "" \""$(ls *.z64 *.v64 *.n64)"\" "$mupen_args" "\n" >> start.sh
;;
6) #snes9x
echo -e \""$path_executable"\" "" \""$(ls *.smc *.sfc)"\" "\n" >> start.sh
;;
7) #Cemu
echo -e \""$path_executable"\" "" "$cemu_args" \""$(ls *.wud *.wux)"\" "\n" >> start.sh
;;
8) #Dolphin
echo -e \""$path_executable"\" "" "--exec=\""$(ls *.wbfs *.wad *.iso *.gcz *.rvz *.dol *.elf)"\"" "$dolphin_args" "\n" >> start.sh
;;
esac
;;
3)
case $parser_ID in
1) #Xemu
echo -e \""$path_executable"\" "" "$xemu_args" "" \""$(ls *.iso)"\" "\n" >> start.sh
;;
2) #Xenia
echo -e wine \""$path_executable"\" "" \""$(ls *.xex *.iso *.zar)"\" "\n" >> start.sh
;;
3) #cxbx-r
echo -e wine \""$path_executable"\" "" \""$(ls *.xbe)"\" "\n" >> start.sh
;;
esac
;;
4)
case $parser_ID in
1) #Wine
# List of games that use the DLLOVERRIDES in the script.
#NOTE: If you renamed your game folder that is in this list, please rename the folder names here to match your folder names.
# gather executable to use in XBMC echos
exeFile="$(find ~+ -name '*.EXE')"
if [ "$(pwd)" == "$path_games/Tom Clancys Splinter Cell" ]; then
echo -n WINEDLLOVERRIDES=\""$SC_SCPT_OVERRIDE"\" wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Tom Clancys Splinter Cell Pandora Tomorrow" ]; then
echo -n WINEDLLOVERRIDES=\""$SC_SCPT_OVERRIDE"\" wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Tom Clancys Splinter Cell Chaos Theory" ]; then
echo -n WINEDLLOVERRIDES=\""$SCCT_OVERRIDE"\" wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Need For Speed Carbon" ]; then
echo -n WINEDLLOVERRIDES=\""$NFSC_MW_OVERRIDE"\" wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Need For Speed Most Wanted 2005" ]; then
echo -n WINEDLLOVERRIDES=\""$NFSC_MW_OVERRIDE"\" wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Grand Theft Auto III" ]; then
echo -n WINEDLLOVERRIDES=\""$GTA3_OVERRIDE"\" wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Blur" ]; then
blurPrefix="/home/$(whoami)/blurpfx"
WINEPREFIX="$blurPrefix" wineboot
WINEPREFIX="$blurPrefix" winetricks -q vcrun2019 dxvk1030
echo -n WINEPREFIX=\""$blurPrefix"\" wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Saints Row 2" ]; then
sr2Prefix="/home/$(whoami)/sr2pfx"
WINEPREFIX="$sr2Prefix" wineboot
WINEPREFIX="$sr2Prefix" winetricks -q vcrun2019 dxvk xact
echo -n WINEPREFIX=\""$sr2Prefix"\" wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Driver 2" ]; then
drv2Prefix="/home/$(whoami)/d2pfx"
WINEPREFIX="$drv2Prefix" WINEARCH=win32 wineboot
echo -n WINEPREFIX=\""$drv2Prefix"\" WINEARCH=win32 wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Test Drive Unlimited 2" ]; then
tdu2Prefix="/home/$(whoami)/tdu2pfx"
WINEPREFIX="$tdu2Prefix" WINEARCH=win32 wineboot
WINEPREFIX="$tdu2Prefix" WINEARCH=win32 winetricks ie7 dotnet40 dxvk1103 dinput8 directplay
echo -n WINEPREFIX=\""$tdu2Prefix"\" WINEARCH=win32 wine \""$exeFile"\" >> start.sh
elif [ "$(pwd)" == "$path_games/Assetto Corsa Competizione" ]; then
accPrefix="/home/$(whoami)/accpfx"
WINEPREFIX="$accPrefix" wineboot
WINEPREFIX="$accPrefix" winetricks -q vcrun2019 dxvk
echo -n WINEPREFIX=\""$accPrefix"\" wine \""$exeFile"\" >> start.sh
else echo wine \""$exeFile"\" >> start.sh
fi
;;
esac
;;
*)
esac
# Write the script that runs XBMC once executable or emulator is closed
if [[ $isXbmcScript -eq 1 ]]; then
echo -e "while true ; do\n" >> start.sh
if [[ $parserList -eq 4 ]]; then
echo -e "if [[ \"\$(pidof "$exeFile")\" == \"""\" ]]; then\n" >> start.sh
else
emulatorExecutable=$(basename -z "$path_executable")
echo -e "if [[ \"\$(pidof "$emulatorExecutable")\" == \"""\" ]]; then\n" >> start.sh
fi
echo -e "wine \""$xmbcExecutable"\"" "\n" >> start.sh
echo -e "break\n" >> start.sh
echo -e "fi\n" >> start.sh
echo -e "sleep 3\n" >> start.sh
echo -e "done" >> start.sh
fi
cd ..;
done
zenity --info --text="Script generation complete"
ZenityUI
}
ZenityUI()
{
# Categories
parserList=$(zenity --list --text="Select a category" --column="ID" --column="Name" --column="Description" --width=800 --height=600 \
1 "Sony" "Emulators" \
2 "Nintendo" "Emulators" \
3 "Microsoft" "Emulators" \
4 "PC Games" "Wine" \
5 "Information" "Show autoSort info")
if [ $? == 1 ]; then exit;
fi
case $parserList in
1)
parser_ID=$(zenity --list --text="Select a Parser" --column="ID" --column="Name" --column="Description" --width=800 --height=600 \
1 Duckstation "PS1 Emulator" \
2 Pcsx2 "PS2 Emulator" \
3 Ppsspp "PSP Emulator" \
4 Rpcs3 "PS3 Emulator" )
if [ $? == 1 ]; then ZenityUI;
fi
;;
2)
parser_ID=$(zenity --list --text="Select a Parser" --column="ID" --column="Name" --column="Description" --width=800 --height=600 \
1 Citra "Nintendo 3DS Emulator" \
2 melonDS "Nintendo DS Emulator" \
3 Yuzu/Ryujinx "Nintendo Switch Emulator" \
4 mGBA "Gameboy Advance Emulator" \
5 mupen64 "Nintendo 64 Emulator" \
6 snes9x "Super nintendo emulator" \
7 Cemu "Nintendo Wii U emulator" \
8 dolphin "Nintendo Wii/Gamecube emulator" )
if [ $? == 1 ]; then ZenityUI;
fi
;;
3)
parser_ID=$(zenity --list --text="Select a Parser" --column="ID" --column="Name" --column="Description" --width=800 --height=600 \
1 Xemu "Original Xbox Emulator" \
2 Xenia "Xbox 360 Emulator" \
3 Cxbx-r "Original Xbox Emulator" )
if [ $? == 1 ]; then ZenityUI;
fi
;;
4)
parser_ID=$(zenity --list --text="Select a Parser" --column="ID" --column="Name" --column="Description" --width=800 --height=600 \
1 Wine "Windows .exe games (default prefix)" \ )
if [ $? == 1 ]; then ZenityUI;
fi
;;
5)
zenity --info --ellipsize --text="$msg"
ZenityUI
;;
esac
if [ $? == 1 ]; then ZenityUI
fi
# Wine uses default prefix.
if [[ $parserList == 4 && $parser_ID == 1 ]]; then
if [[ $winePresent != 0 || $winetricksPresent != 0 ]]; then
zenity --error --text="You must install wine and winetricks to run this parser!"
ZenityUI
else
zenity --info --text="Using default prefix, executing wineboot and winetricks commands"
wineboot
winetricks -q dxvk vkd3d
fi
fi
# Xenia canary requires wine. (until linux build works)
if [[ $parserList == 3 && $parser_ID == 2 ]]; then
zenity --info --text="Using default prefix, executing wineboot and winetricks commands"
wineboot
winetricks -q dxvk vkd3d
fi
# Always ask for emulator executable if not using wine
if [[ $parserList != 4 ]]; then
zenity --info --text="Select the emulator executable"
path_executable=$(zenity --title="Select emulator executable" --file-selection)
if [ $? == 1 ]; then ZenityUI
fi
fi
#Always ask for ROM directory
zenity --info --text="Select the ROM's directory"
path_games=$(zenity --title="Select ROM's path" --directory --file-selection)
if [ $? == 1 ]; then ZenityUI
fi
SortRoms
Parser
}
# Detect available UI selection interfaces. type returns 0 if command is available, 1 if not.
type zenity >> /dev/null
zenityPresent=$?
type winetricks >> /dev/null
winetricksPresent=$?
type wine >> /dev/null
winePresent=$?
# Check if needed components are available
if [ $zenityPresent != 0 ]; then
echo "Zenity must be installed in your system to display UI."
exit
elif [[ $winePresent != 0 || $winetricksPresent != 0 ]]; then
zenity --info --text="Consider installing wine and winetricks to use PC parser"
fi
ZenityUI