-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.ps1
426 lines (326 loc) · 11.6 KB
/
generator.ps1
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
# 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"
# MAIN UI CODE
Function interface() {
Clear-Host
# force the while loop checks and XBMC check
$parserList = 14
$parserID = 14
Write-Host "Categories:" -ForegroundColor White
Write-Host "1 Sony Emulators" -ForegroundColor DarkCyan
Write-Host "2 Nintendo Emulators" -ForegroundColor DarkRed
Write-Host "3 Microsoft Emulators" -ForegroundColor Green
Write-Host "4 PC Games Windows .exe" -ForegroundColor DarkYellow
Write-Host "5 Information Show autoSort info" -ForegroundColor Gray
Write-Host "0 Exit" -ForegroundColor White
while (($parserList -lt 0) -or ($parserList -gt 5)) {
[int]$parserList = Read-Host "Select category of games (0-5)"
if ($parserList -eq 0) {
exit
}
}
switch ($parserList) {
1 {
Clear-Host
Write-Host "0) Menu" -ForegroundColor White
Write-Host "1) Duckstation" -ForegroundColor DarkYellow
Write-Host "2) Pcsx2" -ForegroundColor DarkBlue
Write-Host "3) Ppsspp" -ForegroundColor DarkCyan
Write-Host "4) Rpcs3" -ForegroundColor DarkMagenta
while (($parserID -lt 0) -or ($parserID -gt 4)) {
[int]$parserID = Read-Host "Select an option (0-4)"
if ($parserID -eq 0) {
interface
}
}
}
2 {
Clear-Host
Write-Host "0 Menu" -ForegroundColor White
Write-Host "1 Citra Nintendo 3DS Emulator" -ForegroundColor Yellow
Write-Host "2 melonDS Nintendo DS Emulator" -ForegroundColor Green
Write-Host "3 Yuzu/Ryujinx Nintendo Switch Emulator" -ForegroundColor DarkRed
Write-Host "4 mGBA Gameboy Advance Emulator" -ForegroundColor Magenta
Write-Host "5 mupen64 Nintendo 64 Emulator" -ForegroundColor DarkGray
Write-Host "6 snes9x Super Nintendo Emulator" -ForegroundColor DarkRed
Write-Host "7 Cemu Nintendo Wii U Emulator" -ForegroundColor DarkCyan
Write-Host "8 dolphin Nintendo Wii/Gamecube Emulator" -ForegroundColor DarkMagenta
while (($parserID -lt 0) -or ($parserID -gt 8)) {
[int]$parserID = Read-Host "Select an option (0-8)"
if ($parserID -eq 0) {
interface
}
}
}
3 {
Clear-Host
Write-Host "0 Menu" -ForegroundColor White
Write-Host "1 Xemu Original Xbox Emulator" -ForegroundColor DarkGreen
Write-Host "2 Xenia Xbox 360 Emulator" -ForegroundColor Green
Write-Host "3 Cxbx-r Original Xbox Emulator" -ForegroundColor DarkYellow
while (($parserID -lt 0) -or ($parserID -gt 3)) {
[int]$parserID = Read-Host "Select an option (0-3)"
}
if ($parserID -eq 0) {
interface
}
}
4 {
Clear-Host
Write-Host "0 Menu" -ForegroundColor White
Write-Host "1 Windows Executables" -ForegroundColor DarkCyan
while (($parserID -lt 0) -or ($parserID -gt 1)) {
[int]$parserID = Read-Host "Select an option (0-1)"
if ($parserID -eq 0) {
interface
}
}
}
}
$isXbmcscript = -1
while ( ($isXbmcscript -ne 1) -and ($isXbmcscript -ne 0) ) {
[int]$isXbmcscript = Read-Host "Will you use these scripts with XBMC? Type 1 for yes or 0 for no"
}
if ($isXbmcscript -eq 1) {
$xbmcExecutable = Read-Host "Write absolute path of XBMC, including XBMC.exe"
}
# Let user select game folder
$path = Read-Host "Insert the absolute path of the games folder."
# get all subdirs in folder.
$subdirs = Get-ChildItem -Path $path -Directory | Select-Object -ExpandProperty Name
# if user has not selected windows category, let him choose emulator executable
if ($parserList -ne 4) {
$emulator = Read-Host "Put absolute path of emulator executable, with also the .exe name and extension"
$emuPath = $(Get-Item $emulator).DirectoryName
}
parser
}
Function parser() {
foreach ($folder in $subdirs) {
Set-Location $path\$folder
switch ($parserList) {
1 {
switch ($parserID) {
# NOTE: Working directory argument is optional. TargetPath and Arguments are what matters the most.
1 {
# Duckstation
$game = $(Get-Item *.cue,*.iso,*.img,*.ecm,*.chd).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = "`"$game`" " # write argument with double quotes by escaping them.
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
2 {
# PCSX2
$game = $(Get-Item *.iso,*.chd).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" `"$pcsx2_args`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
3 {
# PPSSPP
$game = $(Get-Item *.iso).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
4 {
# RPCS3
$childItem = $(Get-ChildItem -Recurse -Name | Where-Object {$_ -clike "*EBOOT.BIN"} -ErrorAction 'SilentlyContinue' )
$game = $(Get-Item $ChildItem).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" `"$rpcs3_args`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
}
}
2 {
switch ($parserID) {
1 {
# Citra
$game = $(Get-Item *.cia,*.3ds).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
2 {
# MelonDS
$game = $(Get-Item *.nds).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
3 {
# Yuzu/Ryujinx
$game = $(Get-Item *.xci,*.nsp).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
4 {
# mGBA
$game = $(Get-Item *.gba,*.gbc,*.gb).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
5 {
# mupen64
$game = $(Get-Item *.z64,*.v64,*.n64).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" `"$mgba_args`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
6 {
# snes9x
$game = $(Get-Item *.smc,*.sfc).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
7 {
# Cemu
$game = $(Get-Item *.wud,*.wux).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" `"$cemu_args`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
8 {
# Dolphin
$game = $(Get-Item *.wbfs,*.wad,*.iso,*.gcz,*rvz,*.dol,*.elf).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" `"$dolphin_args`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
}
}
3 {
switch ($parserID) {
1 {
# Xemu
$game = $(Get-Item *.iso).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$xemu_args`"`"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
2 {
# Xenia
$game = $(Get-Item *.xex,*.zar,*.iso).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
3 {
# Cxbx-r
$game = $(Get-Item *.xbe).FullName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = $emulator
$Shortcut.Arguments = " `"$game`" "
$Shortcut.WorkingDirectory = $emuPath
$Shortcut.Save()
}
}
}
4 {
switch ($parserID) {
1 {
# Windows .exe
$tmpExe = Get-ChildItem -Path "$path\$folder" -File -Recurse | Where-Object { $_.Extension -ceq ".EXE" } | Select-Object -ExpandProperty FullName
$exeFolder = $tmpExe.DirectoryName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$path\$folder\$folder.lnk")
$Shortcut.TargetPath = "$tmpExe"
$Shortcut.WorkingDirectory = "$exeFolder"
$Shortcut.Save()
}
}
}
}
if ($isXbmcscript -eq 1) {
xbmcScriptGen
}
Write-Output $(Get-Location)
Set-Location ..
}
Write-Host "Scan Complete! Returning to main menu."
Start-Sleep 3
interface
}
Function xbmcScriptGen() {
# Create empty powershell file to write script.
"" | Out-File -FilePath $path\$folder\Xbmc.ps1
if (($parserList -eq 4) -and ($parserID -eq 1)) {
$xbmcScript = @"
while (`$true) {
if (!`$(Get-Process $exeName)) {
cd '$xbmcPath'; .\XBMC.exe
break
}
Start-Sleep -Seconds 3.0
}
"@
} else{
$emulatorProcName = $(get-Item $emulator).Basename
$xbmcScript = @"
while (`$true) {
if (!`$(Get-Process $emulatorProcName)) {
cd '$xbmcPath'; .\XBMC.exe
break
}
Start-Sleep -Seconds 3.0
}
"@
}
Add-Content $path\$folder\Xbmc.ps1 $xbmcScript
}
interface
parser