Skip to content

Commit

Permalink
Merge pull request #2287 from Nexus-Mods/loadorder-v2
Browse files Browse the repository at this point in the history
Rename and reorganize Load Order views for UI work
  • Loading branch information
Al12rs authored Nov 21, 2024
2 parents e50f0e4 + 57e556a commit b4339c9
Show file tree
Hide file tree
Showing 21 changed files with 151 additions and 82 deletions.
20 changes: 15 additions & 5 deletions src/NexusMods.App.UI/NexusMods.App.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -688,17 +688,27 @@
<Compile Update="Controls\MiniGameWidget\MiniGameWidgetViewModel.cs">
<DependentUpon>IMiniGameWidgetViewModel.cs</DependentUpon>
</Compile>
<Compile Update="Pages\Sorting\LoadOrdersPageDesignViewModel.cs">
<DependentUpon>ILoadOrdersPageViewModel.cs</DependentUpon>
</Compile>
<Compile Update="Pages\Sorting\Prototype\LoadOrderViewModel.cs">
<DependentUpon>ILoadOrderViewModel.cs</DependentUpon>
</Compile>
<Compile Update="Pages\Sorting\Prototype\LoadOrderItemModel.cs">
<DependentUpon>ILoadOrderItemModel.cs</DependentUpon>
</Compile>
<Compile Update="Pages\Sorting\LoadOrdersPageViewModel.cs">
<DependentUpon>ILoadOrdersPageViewModel.cs</DependentUpon>
<Compile Update="Pages\Sorting\LoadOrdersWipPageViewModel.cs">
<DependentUpon>ILoadOrdersWIPPageViewModel.cs</DependentUpon>
</Compile>
<Compile Update="Pages\Sorting\SortingSelectionView\SortingSelectionView.axaml.cs">
<DependentUpon>SortingSelectionView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Pages\Sorting\LoadOrder\LoadOrderItemModel.cs">
<DependentUpon>ILoadOrderItemModel.cs</DependentUpon>
</Compile>
<Compile Update="Pages\Sorting\LoadOrder\LoadOrderViewModel.cs">
<DependentUpon>ILoadOrderViewModel.cs</DependentUpon>
</Compile>
<Compile Update="Pages\Sorting\SortingSelection\SortingSelectionViewModel.cs">
<DependentUpon>ISortingSelectionViewModel.cs</DependentUpon>
</Compile>
</ItemGroup>

Expand Down
3 changes: 3 additions & 0 deletions src/NexusMods.App.UI/NexusMods.App.UI.csproj.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pages_005Cdiagnostics_005Clist/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pages_005Cmodlibrary_005Cdownloadslibrary/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pages_005Cmodlibrary_005Cfileorigins/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pages_005Csorting_005Cloadorder/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pages_005Csorting_005Csortingselection/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pages_005Csorting_005Csortingselectionview/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=theme_005Ccontrolsgallery/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=workspaceattachments_005Cattachmentsfactories/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=workspacesystem_005Caddpanelbutton/@EntryIndexedValue">True</s:Boolean>
Expand Down
11 changes: 11 additions & 0 deletions src/NexusMods.App.UI/Pages/Sorting/ILoadOrdersWIPPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using NexusMods.App.UI.WorkspaceSystem;

namespace NexusMods.App.UI.Pages.Sorting;

/// <summary>
/// Temporary page for hosting the WIP Load Order views
/// </summary>
public interface ILoadOrdersWIPPageViewModel : IPageViewModelInterface
{
public ISortingSelectionViewModel SortingSelectionViewModel { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using NexusMods.App.UI.Controls;
using ReactiveUI;

namespace NexusMods.App.UI.Pages.Sorting.Prototype;
namespace NexusMods.App.UI.Pages.Sorting;

public interface ILoadOrderItemModel : ITreeDataGridItemModel<ILoadOrderItemModel, Guid>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NexusMods.Abstractions.UI;

namespace NexusMods.App.UI.Pages.Sorting.Prototype;
namespace NexusMods.App.UI.Pages.Sorting;

public interface ILoadOrderViewModel : IViewModelInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using NexusMods.App.UI.Controls;
using ReactiveUI;

namespace NexusMods.App.UI.Pages.Sorting.Prototype;
namespace NexusMods.App.UI.Pages.Sorting;

public class LoadOrderItemModel : TreeDataGridItemModel<ILoadOrderItemModel, Guid>, ILoadOrderItemModel
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<reactiveUi:ReactiveUserControl x:TypeArguments="prototype:ILoadOrderViewModel" xmlns="https://github.com/avaloniaui"
<reactiveUi:ReactiveUserControl x:TypeArguments="sorting:ILoadOrderViewModel" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveUi="http://reactiveui.net"
xmlns:controls="clr-namespace:NexusMods.App.UI.Controls"
xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons"
xmlns:games="clr-namespace:NexusMods.Abstractions.Games;assembly=NexusMods.Abstractions.Games"
xmlns:prototype="clr-namespace:NexusMods.App.UI.Pages.Sorting.Prototype"
xmlns:sorting="clr-namespace:NexusMods.App.UI.Pages.Sorting"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="NexusMods.App.UI.Pages.Sorting.Prototype.LoadOrderView">
x:Class="NexusMods.App.UI.Pages.Sorting.LoadOrderView">
<StackPanel Orientation="Vertical">
<TreeDataGrid x:Name="SortOrderTreeDataGrid"
AutoDragDropRows="False"
Expand All @@ -21,7 +20,7 @@
<TreeDataGrid.Resources>

<DataTemplate x:Key="LoadOrderItemIndexColumnTemplate"
DataType="prototype:ILoadOrderItemModel">
DataType="sorting:ILoadOrderItemModel">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="ItemIndex"
Text="{CompiledBinding SortIndex}" />
Expand All @@ -39,7 +38,7 @@
</DataTemplate>

<DataTemplate x:Key="LoadOrderItemNameColumnTemplate"
DataType="prototype:ILoadOrderItemModel">
DataType="sorting:ILoadOrderItemModel">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="ItemName"
Text="{CompiledBinding DisplayName}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using NexusMods.App.UI.Controls;
using ReactiveUI;

namespace NexusMods.App.UI.Pages.Sorting.Prototype;
namespace NexusMods.App.UI.Pages.Sorting;

public partial class LoadOrderView : ReactiveUserControl<ILoadOrderViewModel>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using NexusMods.App.UI.Controls;
using ReactiveUI;

namespace NexusMods.App.UI.Pages.Sorting.Prototype;
namespace NexusMods.App.UI.Pages.Sorting;

public class LoadOrderViewModel : AViewModel<ILoadOrderViewModel>, ILoadOrderViewModel
{
Expand Down

This file was deleted.

21 changes: 0 additions & 21 deletions src/NexusMods.App.UI/Pages/Sorting/LoadOrdersPageView.axaml.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

namespace NexusMods.App.UI.Pages.Sorting;

[JsonName("NexusMods.App.UI.Pages.Sorting.LoadOrdersPageContext")]
public record LoadOrdersPageContext : IPageFactoryContext
[JsonName("NexusMods.App.UI.Pages.Sorting.LoadOrdersWIPPageContext")]
public record LoadOrdersWIPPageContext : IPageFactoryContext
{
public required LoadoutId LoadoutId { get; init; }
}

[UsedImplicitly]
public class LoadOrdersPageFactory : APageFactory<ILoadOrdersPageViewModel, LoadOrdersPageContext>
public class LoadOrdersWIPPageFactory : APageFactory<ILoadOrdersWIPPageViewModel, LoadOrdersWIPPageContext>
{
public LoadOrdersPageFactory(IServiceProvider serviceProvider) : base(serviceProvider)
public LoadOrdersWIPPageFactory(IServiceProvider serviceProvider) : base(serviceProvider)
{
}

public static readonly PageFactoryId StaticId = PageFactoryId.From(Guid.Parse("5192B4BE-4DEF-4C99-BDB9-32AEAF70D9A8"));
public override PageFactoryId Id => StaticId;

public override ILoadOrdersPageViewModel CreateViewModel(LoadOrdersPageContext context)
public override ILoadOrdersWIPPageViewModel CreateViewModel(LoadOrdersWIPPageContext context)
{
var vm = new LoadOrdersPageViewModel(ServiceProvider.GetRequiredService<IWindowManager>(), ServiceProvider, context.LoadoutId);
var vm = new LoadOrdersWipPageViewModel(ServiceProvider.GetRequiredService<IWindowManager>(), ServiceProvider, context.LoadoutId);
return vm;
}

Expand All @@ -42,7 +42,7 @@ public override ILoadOrdersPageViewModel CreateViewModel(LoadOrdersPageContext c
PageData = new PageData
{
FactoryId = Id,
Context = new LoadOrdersPageContext
Context = new LoadOrdersWIPPageContext
{
LoadoutId = loadoutContext.LoadoutId,
}
Expand Down
11 changes: 11 additions & 0 deletions src/NexusMods.App.UI/Pages/Sorting/LoadOrdersWIPPageView.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<reactiveUi:ReactiveUserControl x:TypeArguments="loadOrder:ILoadOrdersWIPPageViewModel" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveUi="http://reactiveui.net"
xmlns:loadOrder="clr-namespace:NexusMods.App.UI.Pages.Sorting"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="NexusMods.App.UI.Pages.Sorting.LoadOrdersWIPPageView">

<loadOrder:SortingSelectionView x:Name="SortingSelectionView"/>
</reactiveUi:ReactiveUserControl>
23 changes: 23 additions & 0 deletions src/NexusMods.App.UI/Pages/Sorting/LoadOrdersWIPPageView.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Reactive.Disposables;
using Avalonia.ReactiveUI;
using ReactiveUI;

namespace NexusMods.App.UI.Pages.Sorting;

public partial class LoadOrdersWIPPageView : ReactiveUserControl<ILoadOrdersWIPPageViewModel>
{
public LoadOrdersWIPPageView()
{
InitializeComponent();

this.WhenActivated(d =>
{
this.OneWayBind(ViewModel,
vm => vm.SortingSelectionViewModel,
v => v.SortingSelectionView.ViewModel
)
.DisposeWith(d);
}
);
}
}
23 changes: 23 additions & 0 deletions src/NexusMods.App.UI/Pages/Sorting/LoadOrdersWipPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using NexusMods.Abstractions.Loadouts;
using NexusMods.App.UI.Windows;
using NexusMods.App.UI.WorkspaceSystem;

namespace NexusMods.App.UI.Pages.Sorting;

public class LoadOrdersWipPageViewModel : APageViewModel<ILoadOrdersWIPPageViewModel>, ILoadOrdersWIPPageViewModel
{
private readonly LoadoutId _loadoutId;

public ISortingSelectionViewModel SortingSelectionViewModel { get; }


public LoadOrdersWipPageViewModel(IWindowManager windowManager, IServiceProvider serviceProvider, LoadoutId loadutId) : base(windowManager)
{
_loadoutId = loadutId;

SortingSelectionViewModel = new SortingSelectionViewModel(serviceProvider, _loadoutId);

TabTitle = "Load Orders (WIP)";
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Collections.ObjectModel;
using NexusMods.App.UI.Pages.Sorting.Prototype;
using NexusMods.App.UI.WorkspaceSystem;
using NexusMods.Abstractions.UI;

namespace NexusMods.App.UI.Pages.Sorting;

public interface ILoadOrdersPageViewModel : IPageViewModelInterface
public interface ISortingSelectionViewModel : IViewModelInterface
{
public ReadOnlyObservableCollection<ILoadOrderViewModel> LoadOrderViewModels { get; }
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<reactiveUi:ReactiveUserControl x:TypeArguments="loadOrder:ILoadOrdersPageViewModel" xmlns="https://github.com/avaloniaui"
<reactiveUi:ReactiveUserControl x:TypeArguments="sorting:ISortingSelectionViewModel" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveUi="http://reactiveui.net"
xmlns:loadOrder="clr-namespace:NexusMods.App.UI.Pages.Sorting"
xmlns:prototype="clr-namespace:NexusMods.App.UI.Pages.Sorting.Prototype"
xmlns:sorting="clr-namespace:NexusMods.App.UI.Pages.Sorting"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="NexusMods.App.UI.Pages.Sorting.LoadOrdersPageView">

x:Class="NexusMods.App.UI.Pages.Sorting.SortingSelectionView">
<TabControl x:Name="SortOrdersTabControl">
<TabControl.ItemTemplate>
<DataTemplate DataType="prototype:ILoadOrderViewModel">
<DataTemplate DataType="sorting:ILoadOrderViewModel">
<TextBlock Text="{CompiledBinding SortOrderName}" />
</DataTemplate>
</TabControl.ItemTemplate>

<TabControl.ContentTemplate>
<DataTemplate DataType="prototype:ILoadOrderViewModel">
<prototype:LoadOrderView ViewModel="{CompiledBinding}" />
<DataTemplate DataType="sorting:ILoadOrderViewModel">
<sorting:LoadOrderView ViewModel="{CompiledBinding}" />
</DataTemplate>
</TabControl.ContentTemplate>

</TabControl>
</reactiveUi:ReactiveUserControl>

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Reactive.Disposables;
using Avalonia.ReactiveUI;
using ReactiveUI;

namespace NexusMods.App.UI.Pages.Sorting;

public partial class SortingSelectionView : ReactiveUserControl<ISortingSelectionViewModel>
{
public SortingSelectionView()
{
InitializeComponent();

this.WhenActivated(disposables =>
{
this.OneWayBind(ViewModel,
vm => vm.LoadOrderViewModels,
v => v.SortOrdersTabControl.ItemsSource
)
.DisposeWith(disposables);
}
);


}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
using Microsoft.Extensions.DependencyInjection;
using NexusMods.Abstractions.Games;
using NexusMods.Abstractions.Loadouts;
using NexusMods.App.UI.Pages.Sorting.Prototype;
using NexusMods.App.UI.Windows;
using NexusMods.App.UI.WorkspaceSystem;
using NexusMods.Abstractions.UI;
using NexusMods.MnemonicDB.Abstractions;

namespace NexusMods.App.UI.Pages.Sorting;

public class LoadOrdersPageViewModel : APageViewModel<ILoadOrdersPageViewModel>, ILoadOrdersPageViewModel
public class SortingSelectionViewModel : AViewModel<ISortingSelectionViewModel>, ISortingSelectionViewModel
{
private readonly LoadoutId _loadoutId;
private readonly IConnection _connection;

public ReadOnlyObservableCollection<ILoadOrderViewModel> LoadOrderViewModels { get; }

public LoadOrdersPageViewModel(IWindowManager windowManager, IServiceProvider serviceProvider, LoadoutId loadutId) : base(windowManager)
public SortingSelectionViewModel(IServiceProvider serviceProvider, LoadoutId loadutId)
{
_loadoutId = loadutId;
_connection = serviceProvider.GetRequiredService<IConnection>();

var loadout = Loadout.Load(_connection.Db, _loadoutId);
var sortableItemProviders = loadout.InstallationInstance.GetGame().SortableItemProviderFactories;

var sortableItemProviders = loadout
.InstallationInstance
.GetGame()
.SortableItemProviderFactories;

LoadOrderViewModels = new ReadOnlyObservableCollection<ILoadOrderViewModel>(
new ObservableCollection<ILoadOrderViewModel>(
sortableItemProviders.Select(provider => new LoadOrderViewModel(_loadoutId, provider))
Expand Down
Loading

0 comments on commit b4339c9

Please sign in to comment.