Skip to content

Commit

Permalink
playnite 8
Browse files Browse the repository at this point in the history
  • Loading branch information
spektor56 committed Oct 15, 2020
1 parent 6f2cf51 commit c73f0b8
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 76 deletions.
28 changes: 7 additions & 21 deletions LBGDBMetadata/LBGDBMetadata.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Playnite, Version=6.5.0.23433, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>Lib\Playnite.dll</HintPath>
</Reference>
<Reference Include="Playnite.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Lib\Playnite.Common.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
Expand Down Expand Up @@ -108,12 +100,6 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Lib\Playnite.Common.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Lib\Playnite.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\launchbox.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand All @@ -131,24 +117,24 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="EFCore.BulkExtensions">
<Version>3.1.5</Version>
<Version>3.2.4</Version>
</PackageReference>
<PackageReference Include="Microsoft.Data.Sqlite.Core">
<Version>3.1.8</Version>
<Version>3.1.9</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore">
<Version>3.1.8</Version>
<Version>3.1.9</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite">
<Version>3.1.8</Version>
<Version>3.1.9</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<Version>3.1.8</Version>
<Version>3.1.9</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="PlayniteSDK">
<Version>5.2.0</Version>
<Version>5.4.0</Version>
</PackageReference>
<PackageReference Include="SixLabors.ImageSharp">
<Version>1.0.1</Version>
Expand All @@ -160,7 +146,7 @@
<Version>2.0.4</Version>
</PackageReference>
<PackageReference Include="System.Net.Http">
<Version>4.3.0</Version>
<Version>4.3.4</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions LBGDBMetadata/LbgdbMetadataPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Xml.Serialization;
Expand All @@ -14,10 +12,8 @@
using LBGDBMetadata.LaunchBox.Api;
using LBGDBMetadata.LaunchBox.Metadata;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Protocols;
using Playnite.SDK;
using Playnite.SDK.Plugins;
using Playnite.ViewModels;
using Game = Playnite.SDK.Models.Game;

namespace LBGDBMetadata
Expand Down Expand Up @@ -253,7 +249,7 @@ public bool HasData()
}


public async Task<string> UpdateMetadata(ProgressViewViewModel progress)
public async Task<string> UpdateMetadata(GlobalProgressActionArgs progress)
{
var newMetadataHash = await _lbgdbApi.GetMetadataHash();
var zipFile = await _lbgdbApi.DownloadMetadata();
Expand All @@ -267,30 +263,34 @@ await Task.Run(async () =>
if (metaData != null)
{
progress.ProgressText = "Updating database...";
//progress.Text = "Updating database...";
using (var context = new MetaDataContext(GetPluginUserDataPath()))
{
await context.Database.EnsureDeletedAsync();
await context.Database.MigrateAsync();
}
progress.CurrentProgressValue++;
progress.ProgressText = "Importing games...";
//progress.Text = "Importing games...";
using (var metaDataStream = metaData.Open())
{
await ImportXml<LaunchBox.Metadata.Game>(metaDataStream);
}
progress.CurrentProgressValue++;
progress.ProgressText = "Importing alternate game names...";
//progress.Text = "Importing alternate game names...";
using (var metaDataStream = metaData.Open())
{
await ImportXml<GameAlternateName>(metaDataStream);
}
progress.CurrentProgressValue++;
progress.ProgressText = "Importing media...";
//progress.Text = "Importing media...";
using (var metaDataStream = metaData.Open())
{
await ImportXml<GameImage>(metaDataStream);
}
progress.CurrentProgressValue++;
}
}
});
Expand Down
50 changes: 26 additions & 24 deletions LBGDBMetadata/LbgdbMetadataSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@ namespace LBGDBMetadata
{
public class LbgdbMetadataSettings : ObservableObject, ISettings
{
private LbgdbMetadataSettings editingClone;
private readonly LbgdbMetadataPlugin plugin;
private LbgdbMetadataSettings _editingClone;
private readonly LbgdbMetadataPlugin _plugin;

private string oldMetadataHash = "";
private string _oldMetadataHash = "";
public string OldMetadataHash
{
get => oldMetadataHash;
get => _oldMetadataHash;
set
{
oldMetadataHash = value;
_oldMetadataHash = value;
OnPropertyChanged();
}
}

private string metaDataURL = @"https://gamesdb.launchbox-app.com/Metadata.zip";
private string _metaDataUrl = @"https://gamesdb.launchbox-app.com/Metadata.zip";
public string MetaDataURL
{
get => metaDataURL;
get => _metaDataUrl;
set
{
metaDataURL = value;
_metaDataUrl = value;
OnPropertyChanged();
}
}

private string metaDataFileName = @"Metadata.xml";
private string _metaDataFileName = @"Metadata.xml";
public string MetaDataFileName
{
get => metaDataFileName;
get => _metaDataFileName;
set
{
metaDataFileName = value;
_metaDataFileName = value;
OnPropertyChanged();
}
}
Expand All @@ -48,29 +48,29 @@ public LbgdbMetadataSettings()

public LbgdbMetadataSettings(LbgdbMetadataPlugin plugin)
{
this.plugin = plugin;

var settings = plugin.LoadPluginSettings<LbgdbMetadataSettings>();
if (settings != null)
this._plugin = plugin;
var savedSettings = plugin.LoadPluginSettings<LbgdbMetadataSettings>();
if (savedSettings != null)
{
LoadValues(settings);
RestoreSettings(savedSettings);
}

}

public void BeginEdit()
{
editingClone = this.GetClone();
_editingClone = new LbgdbMetadataSettings(_plugin);
}

public void EndEdit()

public void CancelEdit()
{
plugin.SavePluginSettings(this);
RestoreSettings(_editingClone);
}

public void CancelEdit()

public void EndEdit()
{
LoadValues(editingClone);
_plugin.SavePluginSettings(this);
}

public bool VerifySettings(out List<string> errors)
Expand All @@ -79,9 +79,11 @@ public bool VerifySettings(out List<string> errors)
return true;
}

private void LoadValues(LbgdbMetadataSettings source)
private void RestoreSettings(LbgdbMetadataSettings source)
{
source.CopyProperties(this, false, null, true);
MetaDataFileName = source.MetaDataFileName;
MetaDataURL = source.MetaDataURL;
OldMetadataHash = source.OldMetadataHash;
}
}
}
33 changes: 14 additions & 19 deletions LBGDBMetadata/LbgdbMetadataSettingsView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Windows;
using System.Windows.Controls;
using Playnite.ViewModels;
using Playnite.Windows;

using Playnite.SDK;

namespace LBGDBMetadata
{
Expand All @@ -13,7 +11,6 @@ namespace LBGDBMetadata
public partial class LbgdbMetadataSettingsView : UserControl
{
private readonly LbgdbMetadataPlugin _plugin;
private ProgressViewViewModel _downloadProgress;

public LbgdbMetadataSettingsView()
{
Expand All @@ -29,22 +26,20 @@ public LbgdbMetadataSettingsView(LbgdbMetadataPlugin plugin)
private void Button_Click(object sender, RoutedEventArgs e)
{
btnRefresh.IsEnabled = false;


_downloadProgress = new ProgressViewViewModel(new ProgressWindowFactory(),
() =>
var progressOptions =
new GlobalProgressOptions("Downloading LaunchBox Metadata...", false) {IsIndeterminate = false};
_plugin.PlayniteApi.Dialogs.ActivateGlobalProgress((progressAction) =>
{
try
{
try
{
var result = _plugin.UpdateMetadata(_downloadProgress).Result;
}
catch (Exception)
{
btnRefresh.IsEnabled = true;
}
},"Downloading LaunchBox Metadata..." );
_downloadProgress.ActivateProgress();

progressAction.ProgressMaxValue = 4;
var result = _plugin.UpdateMetadata(progressAction).Result;
}
catch (Exception)
{
btnRefresh.IsEnabled = true;
}
}, progressOptions);
}

private async void UserControl_Loaded(object sender, RoutedEventArgs e)
Expand Down
Binary file removed LBGDBMetadata/Lib/Playnite.Common.dll
Binary file not shown.
Binary file removed LBGDBMetadata/Lib/Playnite.dll
Binary file not shown.
7 changes: 4 additions & 3 deletions LBGDBMetadata/extension.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Name: LBGDB metadata provider
Author: Spektor
Version: 1.8
Id: Spektor56_Playnite_Metadata_LBGDB
Name: LBGDB metadata provider
Author: Spektor56
Version: 2.0.0
Module: LBGDBMetadata.dll
Type: MetadataProvider
Icon: Resources\launchbox.ico
Expand Down

0 comments on commit c73f0b8

Please sign in to comment.