JosefNemec / Playnite

Video game library manager with support for wide range of 3rd party libraries and game emulation support, providing one unified interface for your games.
https://playnite.link
MIT License
9.5k stars 504 forks source link

ScummVM import #3566

Closed mobeck15 closed 1 year ago

mobeck15 commented 1 year ago

Bug Description

Setting up a truly portable installation requires relative paths to be used to reference emulator executables and game files. For most emulators this works fine.

ScummVM requires some additional configuration to run portably. 1) the scummvm.ini file needs to be located in the same folder as the scummvm.exe file. Then when launching scummvm, you need to provide the launch argument -c scummvm.ini to force it to use this file instead of the default one in appdata.

2) The scummvm.ini file needs to have all of the path references changed from absolute paths, to relative paths. if scummvm.exe is in D:\Games\Emulators\ScummVM, path=D:\Games\Roms\scummvm\Other\Beneath a Steel Sky\ becomes path=....\Roms\scummvm\Other\Beneath a Steel Sky\

This impacts Playnite in a few ways. 1) Configuring the ScummVM emulator you need to override the launch command with custom arguments -c scummvm.ini -f {ImageName} This allows the portable version of the scummvm.ini to be used when launching games.

2) When importing scummvm games, the installDir used for scummvm games is just taking the path string directly from the scummvm.ini. It is expecting an absolute path, but if a relative path is present, it uses that which will only work if the playnite directory and the scummVM directory have the same relative path to the game files folders.

In my case, playnite is in D:\Games\PlaynitePortable so the relative path to the same game above would be ..\Roms\scummvm\Other\Beneath a Steel Sky\

Fortunately this does not affect the ability to launch a scummvm game. The installDir in playnite is invalid though and any reference to it will fail.

3) When importing new scummvm games, after some games have already been imported, playnite fails to recognize that any games have been imported and imports all configured games again. This is due to the relative path not matching the saved installdir.

This can be corrected with the following lines added right before the if...continue section in the importGames.ps1 file for scummVM

    $romPath = Join-Path $config[$key].path $key        
    if (-not [System.IO.Path]::IsPathRooted($romPath)) # Check if it's a relative path
    {
        $romPath = Join-Path $ImportArgs.ScanDirectory $romPath
    }

    $anyFunc = [Func[string,bool]]{ param($a) [System.IO.Path]::GetFullPath($a) -ieq [System.IO.Path]::GetFullPath($romPath) }

To Reproduce

1) Set up ScummVM portable by launching the application with the -c scummvm.ini file. 2) Detect and configure one or more games 3) Edit the scummvm.ini file to change absolute paths to relative paths. (Scummvm must be closed when you make this edit) 4) Configure playnite to use this scummVM instance by using custom arguments: -c scummvm.ini -f {ImageName} 5) Configure auto-scan for scummvm to point to the scummvm folder that contains scummvm.ini 6) Update Emulated Folders for ScummVM and notice the Installation Folder detected. The link will not work if the relative path is not exactly matching. 7) Update Emulated Folders for ScummVM a second time and notice that all configured games are imported a second time.

Diagnostics ID

ca07e05f-5a89-46f4-9e52-f1020c0becd6

Screenshots

No response

JosefNemec commented 1 year ago

Merged in master