|
| 1 | +function Store_installGame { |
| 2 | + param( |
| 3 | + [string]$system, [string]$name, [string]$url |
| 4 | + ) |
| 5 | + |
| 6 | + $name_cleaned = $name -replace '\(.*?\)', '' -replace '\[.*?\]', '' |
| 7 | + $name_cleaned = $name_cleaned -replace ' ', '_' -replace '-', '_' |
| 8 | + $name_cleaned = $name_cleaned -replace '_+', '_' |
| 9 | + $name_cleaned = $name_cleaned -replace '[+&!''.]', '' -replace '_decrypted', '' -replace 'decrypted', '' -replace '.ps3', '' |
| 10 | + $name_cleaned = $name_cleaned.ToLower() |
| 11 | + |
| 12 | + $zipPath = "$romsPath/$system/$name.zip" |
| 13 | + $screenshotPath = "$storagePath/retrolibrary/artwork/$system/media/screenshot/$name_cleaned.jpg" |
| 14 | + $boxartPath = "$storagePath/retrolibrary/artwork/$system/media/box2dfront/$name_cleaned.jpg" |
| 15 | + |
| 16 | + Invoke-WebRequest -Uri $url -OutFile $zipPath |
| 17 | + Invoke-WebRequest -Uri "https://f005.backblazeb2.com/file/emudeck-artwork/$system/media/screenshot/$name.png" -OutFile $screenshotPath |
| 18 | + Invoke-WebRequest -Uri "https://f005.backblazeb2.com/file/emudeck-artwork/$system/media/box2dfront/$name.png" -OutFile $boxartPath |
| 19 | + |
| 20 | + if (Test-Path $zipPath -and Test-Path $screenshotPath -and Test-Path $boxartPath) { |
| 21 | + Write-Output "true" |
| 22 | + } else { |
| 23 | + Write-Output "false" |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +function Store_uninstallGame { |
| 28 | + param( |
| 29 | + [string]$system, [string]$name, [string]$url |
| 30 | + ) |
| 31 | + |
| 32 | + $name_cleaned = $name -replace '\(.*?\)', '' -replace '\[.*?\]', '' |
| 33 | + $name_cleaned = $name_cleaned -replace ' ', '_' -replace '-', '_' |
| 34 | + $name_cleaned = $name_cleaned -replace '_+', '_' |
| 35 | + $name_cleaned = $name_cleaned -replace '[+&!''.]', '' -replace '_decrypted', '' -replace 'decrypted', '' -replace '.ps3', '' |
| 36 | + $name_cleaned = $name_cleaned.ToLower() |
| 37 | + |
| 38 | + $zipPath = "$romsPath/$system/$name.zip" |
| 39 | + $screenshotPath = "$storagePath/retrolibrary/artwork/$system/media/screenshot/$name_cleaned.jpg" |
| 40 | + $boxartPath = "$storagePath/retrolibrary/artwork/$system/media/box2dfront/$name_cleaned.jpg" |
| 41 | + |
| 42 | + Remove-Item -Path $zipPath -Force -ErrorAction SilentlyContinue |
| 43 | + Remove-Item -Path $screenshotPath -Force -ErrorAction SilentlyContinue |
| 44 | + Remove-Item -Path $boxartPath -Force -ErrorAction SilentlyContinue |
| 45 | + |
| 46 | + if (-Not (Test-Path $zipPath) -and -Not (Test-Path $screenshotPath) -and -Not (Test-Path $boxartPath)) { |
| 47 | + Write-Output "true" |
| 48 | + } else { |
| 49 | + Write-Output "false" |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +function Store_isGameInstalled { |
| 54 | + param( |
| 55 | + [string]$system, [string]$name, [string]$url |
| 56 | + ) |
| 57 | + |
| 58 | + $zipPath = "$romsPath/$system/$name.zip" |
| 59 | + |
| 60 | + if (Test-Path $zipPath) { |
| 61 | + Write-Output "true" |
| 62 | + } else { |
| 63 | + Write-Output "false" |
| 64 | + } |
| 65 | +} |
0 commit comments