diff --git a/HowLongToBeatControl.cs b/HowLongToBeatControl.cs new file mode 100644 index 0000000..fcf0ac4 --- /dev/null +++ b/HowLongToBeatControl.cs @@ -0,0 +1,75 @@ +using Playnite.SDK; +using Playnite.SDK.Controls; +using Playnite.SDK.Models; +using Playnite.SDK.Plugins; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; + +namespace Playlist +{ + public class HowLongToBeatControl : ContentControl + { + private static Plugin _plugin; + private static Plugin Plugin + { + get + { + if (_plugin == null) + { + _plugin = Playlist.StaticPlayniteApi.Addons.Plugins.FirstOrDefault(p => p.Id == Guid.Parse("e08cd51f-9c9a-4ee3-a094-fde03b55492f")); + } + return _plugin; + } + } + + public static bool HowLongToBeatIsInstalled => Plugin != null; + + public HowLongToBeatControl(string controlName) + { + if (Plugin == null) + { + return; + } + + control = Plugin.GetGameViewControl(new GetGameViewControlArgs + { + Name = controlName, + Mode = ApplicationMode.Desktop, + }) as PluginUserControl; + if (control == null) + { + return; + } + + control.GameContext = DataContext as Game; + DataContextChanged += (sender, e) => + { + control.GameContext = e.NewValue as Game; + }; + + Content = control; + } + + private PluginUserControl control; + } + + public class HowLongToBeatProgressBar : HowLongToBeatControl + { + public HowLongToBeatProgressBar() : base("PluginProgressBar") + { + + } + } + public class HowLongToBeatPluginButton : HowLongToBeatControl + { + public HowLongToBeatPluginButton() : base("PluginButton") + { + + } + } + +} diff --git a/Playlist.cs b/Playlist.cs index 2cddf41..20bbbcd 100644 --- a/Playlist.cs +++ b/Playlist.cs @@ -17,6 +17,8 @@ public class Playlist : GenericPlugin { private static readonly ILogger logger = LogManager.GetLogger(); + public static IPlayniteAPI StaticPlayniteApi { get; set; } + private PlaylistViewModel PlaylistViewModel { get; set; } private PlaylistView PlaylistView { get; set; } @@ -62,6 +64,8 @@ public Playlist(IPlayniteAPI api) : base(api) // Ensure the library loaded now, relative to the extension DLL. // If the XAML trys to load it later it will incorrectly load it relative to Playnite's executable Assembly.Load("GongSolutions.WPF.DragDrop"); + + StaticPlayniteApi = api; } private IEnumerable LoadPlaylistFile() diff --git a/Playlist.csproj b/Playlist.csproj index a35aacc..3107fd4 100644 --- a/Playlist.csproj +++ b/Playlist.csproj @@ -51,6 +51,7 @@ + diff --git a/PlaylistView.xaml b/PlaylistView.xaml index 035a47f..b9c2b62 100644 --- a/PlaylistView.xaml +++ b/PlaylistView.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:dd="urn:gong-wpf-dragdrop" + xmlns:local="clr-namespace:Playlist" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="600"> @@ -167,6 +168,14 @@ + + + + + + + + @@ -220,6 +229,7 @@ +