<# .SYNOPSIS Configure RomM plugin mapping for PC hacks. Emulator must be added in Playnite UI (see below). Playnite must be fully closed before running (only touches RomM plugin config.json). #> $ErrorActionPreference = 'Stop' $RommConfig = Join-Path $env:LOCALAPPDATA 'Playnite\ExtensionsData\9700aa21-447d-41b4-a989-acd38f407d9f\config.json' $DestPath = 'C:\Users\MattC\roms\windows' $PlatformSpec = 'pc_windows' if (-not (Test-Path $RommConfig)) { throw "RomM config not found: $RommConfig" } $emu = Get-Content -Raw $RommConfig | ConvertFrom-Json | ForEach-Object { $_.Mappings } | Where-Object { $_.PlatformId -eq $PlatformSpec } | Select-Object -First 1 if (-not $emu -or -not $emu.EmulatorId) { Write-Host @' Add the Playnite emulator first (Library -> Configure Emulators -> Add): Name: Pokemon PC Hack Launcher Install: C:\Users\MattC\Documents\pokemon\scripts Profile: Default Platforms: PC (Windows) Extensions: zip Executable: C:\Program Files\PowerShell\7\pwsh.exe Arguments: -ExecutionPolicy Bypass -File "C:\Users\MattC\Documents\pokemon\scripts\launch-pc-hack.ps1" "{ImagePath}" Working dir: {InstallDir} Then in RomM plugin settings, map pc_windows -> that emulator, destination '@ + $DestPath + @', Auto-extract ON. Or re-run this script after the emulator exists (it reads EmulatorId from an existing pc_windows mapping). '@ exit 1 } $cfg = Get-Content -Raw $RommConfig | ConvertFrom-Json $m = $cfg.Mappings | Where-Object { $_.PlatformId -eq $PlatformSpec } | Select-Object -First 1 if (-not $m) { Write-Host 'No pc_windows mapping yet — add it in RomM plugin settings after creating the emulator.' exit 1 } $m.DestinationPath = $DestPath $m.AutoExtract = $true $m.Enabled = $true $m.SyncSaves = $false New-Item -ItemType Directory -Force -Path $DestPath | Out-Null $cfg | ConvertTo-Json -Depth 8 -Compress | Set-Content -Encoding UTF8 $RommConfig Write-Host "RomM pc_windows mapping updated (destination $DestPath, AutoExtract on)."