Skip to content

Commit

Permalink
restored preview images
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed Jun 15, 2024
1 parent 56a5a80 commit f051ed5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Avalonia/Core/ViewModels/MapsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public ImmutableList<IAddon> MapsList
OnPropertyChanged(nameof(IsSelectedAddonUpvoted));
OnPropertyChanged(nameof(IsSelectedAddonDownvoted));
OnPropertyChanged(nameof(SelectedAddonPlaytime));
OnPropertyChanged(nameof(SelectedAddonPreview));
OnPropertyChanged(nameof(IsPreviewVisible));

StartMapCommand.NotifyCanExecuteChanged();
}
Expand Down
25 changes: 23 additions & 2 deletions src/Avalonia/Core/ViewModels/RightPanelViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ClientCommon.API;
using ClientCommon.Config;
using ClientCommon.Providers;
using Common.Enums;
using Common.Helpers;
using Common.Interfaces;
using CommunityToolkit.Mvvm.ComponentModel;
Expand Down Expand Up @@ -42,12 +43,32 @@ ScoresProvider scoresProvider
/// <summary>
/// Preview image of the selected campaign
/// </summary>
public Stream? SelectedAddonPreview => SelectedAddon?.PreviewImage;
public Stream? SelectedAddonPreview
{
get
{
if (SelectedAddon is null)
{
return null;
}

if (SelectedAddon.Type is AddonTypeEnum.TC)
{
return SelectedAddon?.PreviewImage;
}
else if (SelectedAddon.Type is AddonTypeEnum.Map)
{
return SelectedAddon?.PreviewImage ?? SelectedAddon?.GridImage;
}

return null;
}
}

/// <summary>
/// Is preview image in the description visible
/// </summary>
public bool IsPreviewVisible => SelectedAddon?.PreviewImage is not null;
public bool IsPreviewVisible => SelectedAddonPreview is not null;

public int? SelectedAddonScore
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mods/Providers/InstalledAddonsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public void DisableAddon(AddonVersion addonId)
mainDef = manifest.MainDef;
addDefs = manifest.AdditionalDefs?.ToHashSet();

preview = ImageHelper.GetImageFromArchive(archive, "eduke32_preview.png");
preview = ImageHelper.GetImageFromArchive(archive, "preview.png");
image = ImageHelper.GetCoverFromArchive(archive) ?? preview;

dependencies = manifest.Dependencies?.Addons?.ToDictionary(static x => x.Id, static x => x.Version, StringComparer.OrdinalIgnoreCase);
Expand Down

0 comments on commit f051ed5

Please sign in to comment.