Skip to content

Commit

Permalink
alpha test
Browse files Browse the repository at this point in the history
  • Loading branch information
spektor56 committed Jan 20, 2020
1 parent 248d341 commit 1c3d32c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions LBGDBMetadata/LbgdbLazyMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ public LbgdbLazyMetadataProvider(ulong gameId, LbgdbMetadataPlugin plugin)
this.plugin = plugin;
}

private GameImage GetBestImage(List<GameImage> images)
private GameImage GetBestImage(List<GameImage> images, HashSet<string> imageTypes)
{
if (images.Count < 1)
{
return null;
}
IOrderedEnumerable<GameImage> filteredImages;
foreach (var coverType in LaunchBox.Image.ImageType.Cover)
foreach (var coverType in imageTypes)
{
if (!images.Any(image => image.Type == coverType))
if (images.All(image => image.Type != coverType))
{
continue;
}
Expand Down Expand Up @@ -226,10 +226,10 @@ public override MetadataFile GetCoverImage()
{
using (var context = new MetaDataContext())
{
var coverImages = GetBestImage(context.GameImages.Where(image => image.DatabaseID == game.DatabaseID && LaunchBox.Image.ImageType.Cover.Contains(image.Type)).ToList());
if (coverImages != null)
var coverImage = GetBestImage(context.GameImages.Where(image => image.DatabaseID == game.DatabaseID && LaunchBox.Image.ImageType.Cover.Contains(image.Type)).ToList(), LaunchBox.Image.ImageType.Cover);
if (coverImage != null)
{
return new MetadataFile("https://images.launchbox-app.com/" + coverImages.FileName);
return new MetadataFile("https://images.launchbox-app.com/" + coverImage.FileName);
}
}
}
Expand All @@ -245,10 +245,10 @@ public override MetadataFile GetBackgroundImage()
{
using (var context = new MetaDataContext())
{
var backgroundImages = GetBestImage(context.GameImages.Where(image => image.DatabaseID == game.DatabaseID && LaunchBox.Image.ImageType.Background.Contains(image.Type)).ToList());
if (backgroundImages != null)
var backgroundImage = GetBestImage(context.GameImages.Where(image => image.DatabaseID == game.DatabaseID && LaunchBox.Image.ImageType.Background.Contains(image.Type)).ToList(), LaunchBox.Image.ImageType.Background);
if (backgroundImage != null)
{
return new MetadataFile("https://images.launchbox-app.com/" + backgroundImages.FileName);
return new MetadataFile("https://images.launchbox-app.com/" + backgroundImage.FileName);
}
}
}
Expand Down

0 comments on commit 1c3d32c

Please sign in to comment.