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.25k stars 501 forks source link

Scripting API suggestions #919

Open bburky opened 5 years ago

bburky commented 5 years ago
bburky commented 5 years ago

Another:

Make PlayniteApi.ExpandGameVariables(Game, GameAction) also expand an any associated emulator profile's Executable, WorkingDirectory and Arguments into the new GameAction, correctly handling OverrideDefaultArgs and AdditionalArguments.

Currently I have to manually lookup the emulator. Look up the Profile (using Linq in IronPython, which is weird but works). Manually expand each variable from the profile with PlayniteApi.ExpandGameVariables(Game, string). And append AdditionalArguments myself. I gave up for now. Never mind, EmulatorProfileExtensions has ExpandVariables(..) but extension methods are mostly unsupported in IronPython. The type currently isn't exposed to IronPython, but I managed to call it directly using some horrible reflection. It would still be nice if there was a method that evaluates everything like Playnite does right before starting a game.

JosefNemec commented 2 years ago

How many of these are still needed?

bburky commented 2 years ago
  1. Add an easy way to get a path to the extension directoryPath.GetDirectoryName(Assembly.GetExecutingAssembly().Location) and $PSScriptRoot cover this now.
  2. Maybe allow easier configuration of script extensions – There's still no way to provide configuration to script extensions. They can't provide a GetSettingsView() or save/load settings.
    • If you're okay with this being a feature restricted to C# extensions, this is acceptable.
  3. A REPL with access to the PlayniteApi would be really nice. – It might be nice to provide an interactive PowerShell console as a first class feature. For now though it's possible to debug a random PS extension and extract it's $PlayniteApi variable. This is hacky and not documented though:
    Enter-PSHostProcess -Name Playnite.DesktopApp
    $PlayniteApi = (Get-Runspace)[-2].SessionStateProxy.GetVariable("PlayniteApi")
  4. Expand game variables – I think extension methods are accessible in PowerShell which covers part of this.

You can close this if you would like to though, or if you think any of these are good use cases I can create followup issues.

JosefNemec commented 2 years ago

1) Extensions can use $CurrentExtensionInstallPath and your GetExecutingAssembly example for plugins is imho pretty standard, I don't think we need to add special variable for that.

2) #1741

3) #1967

4) https://playnite.link/docs/tutorials/extensions/expandingVariables.html