Skip to content

Commit

Permalink
Merge pull request #2624 from Nexus-Mods/show-overrides-in-my-mods
Browse files Browse the repository at this point in the history
Add External Changes Left Menu entry
  • Loading branch information
Al12rs authored Feb 12, 2025
2 parents 6fa67bc + 5a72ee2 commit f8c518d
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public interface ILoadoutLeftMenuViewModel : ILeftMenuViewModel
public ILeftMenuItemViewModel LeftMenuItemLoadout { get; }

public ILeftMenuItemViewModel LeftMenuItemHealthCheck { get; }

public ILeftMenuItemViewModel? LeftMenuItemExternalChanges { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public class LoadoutLeftMenuDesignViewModel : AViewModel<ILoadoutLeftMenuViewMod
Text = new StringComponent(Language.LoadoutLeftMenuViewModel_LoadoutLeftMenuViewModel_Diagnostics),
Icon = IconValues.Cardiology,
};

public ILeftMenuItemViewModel LeftMenuItemExternalChanges { get; } = new LeftMenuItemDesignViewModel
{
Text = new StringComponent(Language.LoadoutLeftMenuViewModel_External_Changes),
Icon = IconValues.Cog,
};

public LoadoutLeftMenuDesignViewModel()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</StackPanel>

<items:LeftMenuItemView x:Name="HealthCheckItem" />
<items:LeftMenuItemView x:Name="ExternalChangesItem" />
</StackPanel>

<reactiveUi:ViewModelViewHost Grid.Row="1" x:Name="ApplyControlViewHost" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public LoadoutLeftMenuView()

this.OneWayBind(ViewModel, vm => vm.LeftMenuItemHealthCheck, view => view.HealthCheckItem.ViewModel)
.DisposeWith(disposables);

this.OneWayBind(ViewModel, vm => vm.LeftMenuItemExternalChanges, view => view.ExternalChangesItem.ViewModel)
.DisposeWith(disposables);

this.WhenAnyValue(view => view.ViewModel!.LeftMenuItemExternalChanges)
.Select(item => item != null)
.BindTo(this, view => view.ExternalChangesItem.IsVisible)
.DisposeWith(disposables);

this.WhenAnyValue(x => x.ViewModel!.LeftMenuCollectionItems)
.BindTo(this, x => x.MenuItemsControl.ItemsSource)
Expand Down
44 changes: 44 additions & 0 deletions src/NexusMods.App.UI/LeftMenu/Loadout/LoadoutLeftMenuViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using DynamicData;
using DynamicData.Kernel;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NexusMods.Abstractions.Collections;
using NexusMods.Abstractions.Diagnostics;
using NexusMods.Abstractions.Jobs;
Expand All @@ -15,6 +17,7 @@
using NexusMods.App.UI.LeftMenu.Items;
using NexusMods.App.UI.Overlays;
using NexusMods.App.UI.Pages.Diagnostics;
using NexusMods.App.UI.Pages.ItemContentsFileTree;
using NexusMods.App.UI.Pages.LibraryPage;
using NexusMods.App.UI.Pages.LoadoutPage;
using NexusMods.App.UI.Resources;
Expand All @@ -35,6 +38,7 @@ public class LoadoutLeftMenuViewModel : AViewModel<ILoadoutLeftMenuViewModel>, I
public ILeftMenuItemViewModel LeftMenuItemLibrary { get; }
public ILeftMenuItemViewModel LeftMenuItemLoadout { get; }
public ILeftMenuItemViewModel LeftMenuItemHealthCheck { get; }
[Reactive] public ILeftMenuItemViewModel? LeftMenuItemExternalChanges { get; private set; }

public IApplyControlViewModel ApplyControlViewModel { get; }

Expand All @@ -56,6 +60,7 @@ public LoadoutLeftMenuViewModel(
var monitor = serviceProvider.GetRequiredService<IJobMonitor>();
var overlayController = serviceProvider.GetRequiredService<IOverlayController>();
var gameRunningTracker = serviceProvider.GetRequiredService<GameRunningTracker>();
var logger = serviceProvider.GetRequiredService<ILogger<LoadoutLeftMenuViewModel>>();

var collectionItemComparer = new LeftMenuCollectionItemComparer();
var collectionDownloader = new CollectionDownloader(serviceProvider);
Expand Down Expand Up @@ -195,6 +200,45 @@ public LoadoutLeftMenuViewModel(

this.WhenActivated(disposable =>
{
// External Changes
conn.ObserveDatoms(LoadoutOverridesGroup.OverridesFor, loadoutContext.LoadoutId)
.AsEntityIds()
.Transform(datom => LoadoutOverridesGroup.Load(conn.Db, datom.E))
.QueryWhenChanged(overrides =>
{
if (overrides.Count == 0)
{
return null;
}

Debug.Assert(overrides.Count == 1, "There should only be one LoadoutOverridesGroup for a LoadoutId");

var group = overrides.Items.First().AsLoadoutItemGroup();

return new LeftMenuItemViewModel(
workspaceController,
WorkspaceId,
new PageData
{
FactoryId = ItemContentsFileTreePageFactory.StaticId,
Context = new ItemContentsFileTreePageContext
{
GroupId = group.LoadoutItemGroupId,
},
}
)
{
Text = new StringComponent(Language.LoadoutLeftMenuViewModel_External_Changes),
Icon = IconValues.FolderEditOutline,
ToolTip = new StringComponent(Language.LoadoutLeftMenuViewModel_External_Changes_ToolTip),
};

})
.OnUI()
.SubscribeWithErrorLogging(item => LeftMenuItemExternalChanges = item)
.DisposeWith(disposable);


collectionItemsObservable
.OnUI()
.SortAndBind(out _leftMenuCollectionItems, collectionItemComparer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using NexusMods.App.UI.Windows;
using NexusMods.App.UI.WorkspaceSystem;
using NexusMods.Extensions.BCL;
using NexusMods.Icons;
using NexusMods.MnemonicDB.Abstractions;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
Expand All @@ -32,6 +33,9 @@ public ItemContentsFileTreeViewModel(
IWindowManager windowManager,
IConnection connection) : base(windowManager)
{
TabIcon = IconValues.FolderOpen;
TabTitle = "File Tree";

OpenEditorCommand = ReactiveCommand.Create<NavigationInformation>(info =>
{
var gamePath = SelectedItem!.Key;
Expand Down Expand Up @@ -63,14 +67,19 @@ public ItemContentsFileTreeViewModel(
var behavior = workspaceController.GetOpenPageBehavior(pageData, info);
var workspaceId = workspaceController.ActiveWorkspaceId;
workspaceController.OpenPage(workspaceId, pageData, behavior);
}, this.WhenAnyValue(vm => vm.SelectedItem).WhereNotNull().Select(x => x.IsFile));
},
this.WhenAnyValue(vm => vm.SelectedItem)
.WhereNotNull()
.Select(item => item is { IsFile: true, IsDeletion: false })
);

this.WhenActivated(disposables =>
{
this.WhenAnyValue(vm => vm.Context)
.WhereNotNull()
.Select(context => LoadoutItemGroup.Load(connection.Db, context.GroupId))
.Where(group => group.IsValid())
.Do(group => TabTitle = group.AsLoadoutItem().Name)
.Select(group => new LoadoutItemGroupFileTreeViewModel(group))
.BindToVM(this, vm => vm.FileTreeViewModel)
.DisposeWith(disposables);
Expand Down
24 changes: 21 additions & 3 deletions src/NexusMods.App.UI/Resources/Language.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/NexusMods.App.UI/Resources/Language.resx
Original file line number Diff line number Diff line change
Expand Up @@ -777,4 +777,10 @@ To apply changes or launch the game again, please close the game first.</value>
<data name="LoadoutView_Title_Installed_Mods_Default" xml:space="preserve">
<value>All</value>
</data>
<data name="LoadoutLeftMenuViewModel_External_Changes" xml:space="preserve">
<value>External Changes</value>
</data>
<data name="LoadoutLeftMenuViewModel_External_Changes_ToolTip" xml:space="preserve">
<value>Review, remove, or restore changes made outside the app.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/NexusMods.Icons/IconValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ public static class IconValues

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

// https://pictogrammers.com/library/mdi/icon/folder-edit-outline/
public static readonly IconValue FolderEditOutline = new SimpleVectorIcon(new SimpleVectorIconImage(
"M160-240v-480 480Zm0 80q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v132q-19-8-39.5-10.5t-40.5.5v-122H447l-80-80H160v480h324l-4 4v76H160Zm400 80v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T903-300L683-80H560Zm300-263-37-37 37 37ZM620-140h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z",
new Rect(0, -960, 960, 960)
));

// https://pictogrammers.com/library/mdi/icon/file-edit/
public static readonly IconValue FileEdit = new ProjektankerIcon("mdi-file-edit");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<icons:UnifiedIcon Classes="ChevronRight" />
<icons:UnifiedIcon Classes="FolderOutline" />
<icons:UnifiedIcon Classes="FolderOpenOutline" />
<icons:UnifiedIcon Classes="FolderEditOutline" />
<icons:UnifiedIcon Classes="File" />
<icons:UnifiedIcon Classes="Check" />
<icons:UnifiedIcon Classes="CheckCircle" />
Expand Down Expand Up @@ -351,6 +352,10 @@
<Style Selector="icons|UnifiedIcon.FolderOpenOutline">
<Setter Property="Value" Value="{x:Static icons:IconValues.FolderOpen}" />
</Style>

<Style Selector="icons|UnifiedIcon.FolderEditOutline">
<Setter Property="Value" Value="{x:Static icons:IconValues.FolderEditOutline}" />
</Style>

<Style Selector="icons|UnifiedIcon.File">
<Setter Property="Value" Value="{x:Static icons:IconValues.File}" />
Expand Down

0 comments on commit f8c518d

Please sign in to comment.