Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout change for Collection Loadout Page #2680

Merged
merged 10 commits into from
Feb 19, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public LoadoutLeftMenuViewModel(
var logger = serviceProvider.GetRequiredService<ILogger<LoadoutLeftMenuViewModel>>();

var collectionItemComparer = new LeftMenuCollectionItemComparer();
var collectionDownloader = new CollectionDownloader(serviceProvider);
var collectionDownloader = serviceProvider.GetRequiredService<CollectionDownloader>();

// Library
LeftMenuItemLibrary = new LeftMenuItemWithCountBadgeViewModel(
Expand Down
2 changes: 1 addition & 1 deletion src/NexusMods.App.UI/Pages/CollectionDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CollectionDataProvider(IServiceProvider serviceProvider)
{
_connection = serviceProvider.GetRequiredService<IConnection>();
_jobMonitor = serviceProvider.GetRequiredService<IJobMonitor>();
_collectionDownloader = new CollectionDownloader(serviceProvider);
_collectionDownloader = serviceProvider.GetRequiredService<CollectionDownloader>();
_thumbnailLoader = ImagePipelines.GetModPageThumbnailPipeline(serviceProvider);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public CollectionDownloadViewModel(
var mappingCache = serviceProvider.GetRequiredService<IGameDomainToGameIdMappingCache>();
var osInterop = serviceProvider.GetRequiredService<IOSInterop>();
var nexusModsLibrary = serviceProvider.GetRequiredService<NexusModsLibrary>();
var collectionDownloader = new CollectionDownloader(serviceProvider);
var collectionDownloader = serviceProvider.GetRequiredService<CollectionDownloader>();
var loginManager = serviceProvider.GetRequiredService<ILoginManager>();
var overlayController = serviceProvider.GetRequiredService<IOverlayController>();
var jobMonitor = serviceProvider.GetRequiredService<IJobMonitor>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public CollectionLoadoutDesignViewModel() : base(new DesignWindowManager()) { }

public LoadoutTreeDataGridAdapter Adapter { get; } = null!;
public bool IsCollectionEnabled => true;
public int InstalledModsCount { get; } = 10;
public string Name => "Vanilla+ [Quality of Life]";
public RevisionNumber RevisionNumber { get; } = RevisionNumber.From(6);
public string AuthorName => "Lowtonotolerance";
Expand Down
285 changes: 133 additions & 152 deletions src/NexusMods.App.UI/Pages/LoadoutPage/CollectionLoadoutView.axaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public CollectionLoadoutView()
.AddTo(disposables);
this.OneWayBind(ViewModel, vm => vm.Name, view => view.CollectionName.Text)
.AddTo(disposables);
this.OneWayBind(ViewModel, vm => vm.InstalledModsCount, view => view.TotalModsTextBlock.Text, count => $"{count} MODS")
.AddTo(disposables);
this.OneWayBind(ViewModel, vm => vm.TileImage, view => view.CollectionImage.Source)
.AddTo(disposables);

Expand All @@ -48,25 +50,14 @@ public CollectionLoadoutView()

this.OneWayBind(ViewModel, vm => vm.IsLocalCollection, view => view.NexusModsLogo.IsVisible, static b => !b)
.AddTo(disposables);
this.OneWayBind(ViewModel, vm => vm.IsReadOnly, view => view.ReadOnlyPillStack.IsVisible)
.AddTo(disposables);

this.WhenAnyValue(view => view.ViewModel!.IsCollectionEnabled)
.WhereNotNull()
.SubscribeWithErrorLogging(value =>
{
CollectionToggle.IsChecked = value;
ToolbarReadOnly.IsVisible = value;
ToolbarDisabled.IsVisible = !value;

if (value)
{
ToolbarBorder.Classes.Add("Info");
ToolbarBorder.Classes.Remove("Warning");
}
else
{
ToolbarBorder.Classes.Remove("Info");
ToolbarBorder.Classes.Add("Warning");
}
}
)
.DisposeWith(disposables);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using System.Reactive.Linq;
using DynamicData;
using NexusMods.Abstractions.Collections;
using NexusMods.App.UI.Controls.Navigation;
using NexusMods.App.UI.Pages.CollectionDownload;
using NexusMods.MnemonicDB.Abstractions.Query;
using NexusMods.MnemonicDB.Abstractions.TxFunctions;
using R3;
using ReactiveUI;
Expand Down Expand Up @@ -145,7 +147,13 @@ public CollectionLoadoutViewModel(
this.WhenActivated(disposables =>
{
Adapter.Activate().AddTo(disposables);


connection.ObserveDatoms(LoadoutItem.ParentId, pageContext.GroupId)
.QueryWhenChanged(datoms => datoms.Count)
.OnUI()
.Subscribe(count => InstalledModsCount = count)
.AddTo(disposables);

LoadoutItem
.Observe(connection, pageContext.GroupId)
.Select(static item => !item.IsDisabled)
Expand Down Expand Up @@ -192,6 +200,9 @@ public CollectionLoadoutViewModel(
[Reactive] public Bitmap? TileImage { get; private set; }

[Reactive] public bool IsCollectionEnabled { get; private set; }

[Reactive] public int InstalledModsCount { get; private set; }

public ReactiveCommand<Unit> CommandToggle { get; }
public ReactiveCommand<Unit> CommandDeleteCollection { get; }
public ReactiveUI.ReactiveCommand<NavigationInformation, System.Reactive.Unit> CommandViewCollectionDownloadPage { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public interface ICollectionLoadoutViewModel : IPageViewModelInterface
/// Gets whether the collection is enabled.
/// </summary>
bool IsCollectionEnabled { get; }

/// <summary>
/// Gets the number of mods installed in the collection, both required and optional.
/// </summary>
int InstalledModsCount { get; }

string Name { get; }

Expand Down
2 changes: 1 addition & 1 deletion src/NexusMods.Collections/InstallCollectionDownloadJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static async ValueTask<InstallCollectionDownloadJob> Create(
if (!optionalCollectionGroup.HasValue) throw new InvalidOperationException("Collection must exist!");
var collectionGroup = optionalCollectionGroup.Value.AsCollectionGroup();

var sourceCollection = new CollectionDownloader(serviceProvider).GetLibraryFile(download.CollectionRevision);
var sourceCollection = serviceProvider.GetRequiredService<CollectionDownloader>().GetLibraryFile(download.CollectionRevision);
var nexusModsLibrary = serviceProvider.GetRequiredService<NexusModsLibrary>();

var root = await nexusModsLibrary.ParseCollectionJsonFile(sourceCollection, cancellationToken);
Expand Down
3 changes: 2 additions & 1 deletion src/NexusMods.Collections/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static IServiceCollection AddNexusModsCollections(this IServiceCollection
.AddNexusCollectionBundledLoadoutGroupModel()
.AddNexusCollectionItemLoadoutGroupModel()
.AddNexusCollectionReplicatedLoadoutGroupModel()
.AddCollectionVerbs();
.AddCollectionVerbs()
.AddSingleton<CollectionDownloader>();
}
}
2 changes: 1 addition & 1 deletion src/NexusMods.Collections/Verbs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private static async Task<int> InstallCollection([Injected] IRenderer renderer,
[Injected] NexusModsLibrary nexusModsLibrary,
[Injected] IServiceProvider serviceProvider,
[Injected] IConnection connection,
[Injected] CollectionDownloader collectionDownloader,
[Injected] CancellationToken token)
{
await using var destination = temporaryFileManager.CreateFile();
Expand All @@ -46,7 +47,6 @@ private static async Task<int> InstallCollection([Injected] IRenderer renderer,

var revisionMetadata = await nexusModsLibrary.GetOrAddCollectionRevision(collectionFile, CollectionSlug.From(slug), RevisionNumber.From((ulong)revision), token);

var collectionDownloader = new CollectionDownloader(serviceProvider);
await collectionDownloader.DownloadItems(revisionMetadata, itemType: CollectionDownloader.ItemType.Required, db: connection.Db, cancellationToken: token);

var items = CollectionDownloader.GetItems(revisionMetadata, CollectionDownloader.ItemType.Required);
Expand Down
3 changes: 3 additions & 0 deletions src/NexusMods.Icons/IconValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ public static class IconValues

// https://pictogrammers.com/library/mdi/icon/folder-outline/
public static readonly IconValue Folder = new ProjektankerIcon("mdi-folder-outline");

// https://pictogrammers.com/library/mdi/icon/folder-eye-outline/
public static readonly IconValue FolderEyeOutline = new ProjektankerIcon("mdi-folder-eye-outline");

// https://pictogrammers.com/library/mdi/icon/check-underline/
public static readonly IconValue FolderOpen = new ProjektankerIcon("mdi-folder-open-outline");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<icons:UnifiedIcon Classes="DotsGrid" />
<icons:UnifiedIcon Classes="FormatAlignJustify" />
<icons:UnifiedIcon Classes="MoreVertical" />
<icons:UnifiedIcon Classes="FolderEyeOutline" />
</WrapPanel>
<WrapPanel>
<icons:UnifiedIcon Classes="Nexus" />
Expand Down Expand Up @@ -663,4 +664,7 @@
<Style Selector="icons|UnifiedIcon.MoreVertical">
<Setter Property="Value" Value="{x:Static icons:IconValues.MoreVertical}" />
</Style>
<Style Selector="icons|UnifiedIcon.FolderEyeOutline">
<Setter Property="Value" Value="{x:Static icons:IconValues.FolderEyeOutline}" />
</Style>
</Styles>
Loading