diff --git a/src/Avalonia/Core/ViewModels/MapsViewModel.cs b/src/Avalonia/Core/ViewModels/MapsViewModel.cs index b7291e23..2c754c5b 100644 --- a/src/Avalonia/Core/ViewModels/MapsViewModel.cs +++ b/src/Avalonia/Core/ViewModels/MapsViewModel.cs @@ -103,6 +103,8 @@ public override IAddon? SelectedAddon OnPropertyChanged(nameof(IsSelectedAddonUpvoted)); OnPropertyChanged(nameof(IsSelectedAddonDownvoted)); OnPropertyChanged(nameof(SelectedAddonPlaytime)); + OnPropertyChanged(nameof(SelectedAddonPreview)); + OnPropertyChanged(nameof(IsPreviewVisible)); StartMapCommand.NotifyCanExecuteChanged(); } diff --git a/src/Avalonia/Core/ViewModels/RightPanelViewModel.cs b/src/Avalonia/Core/ViewModels/RightPanelViewModel.cs index f80f544c..7b6ea121 100644 --- a/src/Avalonia/Core/ViewModels/RightPanelViewModel.cs +++ b/src/Avalonia/Core/ViewModels/RightPanelViewModel.cs @@ -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; @@ -42,12 +43,32 @@ ScoresProvider scoresProvider /// /// Preview image of the selected campaign /// - 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; + } + } /// /// Is preview image in the description visible /// - public bool IsPreviewVisible => SelectedAddon?.PreviewImage is not null; + public bool IsPreviewVisible => SelectedAddonPreview is not null; public int? SelectedAddonScore { diff --git a/src/Mods/Providers/InstalledAddonsProvider.cs b/src/Mods/Providers/InstalledAddonsProvider.cs index 6cf27d3c..0c3e8c1f 100644 --- a/src/Mods/Providers/InstalledAddonsProvider.cs +++ b/src/Mods/Providers/InstalledAddonsProvider.cs @@ -368,7 +368,7 @@ newAddon.Version is not null && 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);