Open bburky opened 3 years ago
It also appears to be causing the drag and drop behavior to slow down significantly. Perhaps I may need to disable property updates during dragging
I don't know what PlayniteApi
object that is, but IPlayniteApi
doesn't have Plugins
member. This is definitely not supported and expect issues.
Sorry, typo while shortening the sample code.
It's IPlayniteApi.Addons.Plugins
. It has a List of all the currently loaded Plugins. https://playnite.link/docs/devel/api/Playnite.SDK.IAddons.html#Playnite_SDK_IAddons_Plugins
Would you consider an API in the future to allow plugin views or Windows to do this in a supported way? Something like <ContentControl x:Name="HowLongToBeat_PluginProgressBar"/>
but more generic?
open issue
To be honest I don't remember why that plugin list is exposed there, that should definitely not be done the way it is (exposing the "raw" plugin classes). I'm going to remove it in P9.
@bburky Basically, giving a GameContext
to a PluginUserControl
is how it works.
Closes #2
This is a kind of hacky implementation, but does work. The normal
<ContentControl x:Name="HowLongToBeat_PluginProgressBar"/>
way doesn't work because Playnite only provides custom control integration in library views.Instead, it's possible to manually access a different extension and call it's
GetGameViewControl()
methods to instantiate the custom controls it provides. This control can be loaded into a ContentControl and it's GameContext manually bound.The code is roughly this plus some additional error checking:
It mostly works well. This change introduced a short lag when first loading my Playlist sidebar view. Also when each HowLongToBeat progress bar shows up it takes a second to "pop in", it shows up unstyled and then resizes and loads. I'm not sure if that's avoidable?
@Lacro59 Are you okay with me using your plugin like this? Will anything break if I load lots of controls like this (it seems to work fine though). The button even works too. It gets loaded basically the same way as the library views use it. Is there any thing I should be doing to reduce the loading time for each control?
@JosefNemec I looked at
ControlTemplateTools.InitializePluginControls()
and it doesn't look like it could be easily extended to support sidebar views like I'm trying to do. Is loading another extension's control like I'm doing here a good idea, or should I expect this to break horribly?