Skip to content

Commit debf7fa

Browse files
committed
Merge remote-tracking branch 'origin/main' into docs-070
2 parents 0bf4cac + 86a6991 commit debf7fa

File tree

11 files changed

+308
-87
lines changed

11 files changed

+308
-87
lines changed

src/Games/NexusMods.Games.RedEngine/Cyberpunk2077/SortOrder/RedMod/RedModSortableItemProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private async Task PersistSortableEntries(List<RedModSortableItem> orderList)
378378

379379
private static bool RedModIsEnabled(RedModLoadoutGroup.ReadOnly grp)
380380
{
381-
return !grp.AsLoadoutItemGroup().AsLoadoutItem().GetThisAndParents().Any(f => f.Contains(LoadoutItem.Disabled));
381+
return grp.AsLoadoutItemGroup().AsLoadoutItem().IsEnabled();
382382
}
383383

384384
private static RelativePath RedModFolder(RedModLoadoutGroup.ReadOnly group)

src/NexusMods.App.UI/Pages/Sorting/LoadOrder/ILoadOrderItemModel.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reactive;
2-
using NexusMods.Abstractions.Games;
32
using NexusMods.App.UI.Controls;
43
using ReactiveUI;
54

src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderItemModel.cs

+31-5
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
using System.Reactive;
2+
using System.Reactive.Disposables;
23
using NexusMods.Abstractions.Games;
34
using NexusMods.App.UI.Controls;
45
using ReactiveUI;
6+
using ReactiveUI.Fody.Helpers;
57

68
namespace NexusMods.App.UI.Pages.Sorting;
79

810
public class LoadOrderItemModel : TreeDataGridItemModel<ILoadOrderItemModel, Guid>, ILoadOrderItemModel
911
{
12+
private CompositeDisposable _disposables = new();
1013
public ISortableItem InnerItem { get; }
1114

1215
public ReactiveCommand<Unit, Unit> MoveUp { get; }
1316
public ReactiveCommand<Unit, Unit> MoveDown { get; }
1417
public int SortIndex { get; }
1518
public string DisplayName { get; }
1619

17-
// TODO: Populate these properly
18-
public string ModName { get; } = string.Empty;
19-
public bool IsActive { get; } = true;
20+
[Reactive] public string ModName { get; private set; }
21+
[Reactive] public bool IsActive { get; private set; }
2022

2123
public LoadOrderItemModel(ISortableItem sortableItem)
2224
{
2325
InnerItem = sortableItem;
2426
SortIndex = sortableItem.SortIndex;
2527
DisplayName = sortableItem.DisplayName;
2628

29+
IsActive = sortableItem.IsActive;
30+
ModName = sortableItem.ModName;
31+
2732
MoveUp = ReactiveCommand.CreateFromTask(async () =>
2833
{
2934
await sortableItem.SortableItemProvider.SetRelativePosition(InnerItem, delta: 1);
@@ -37,9 +42,30 @@ public LoadOrderItemModel(ISortableItem sortableItem)
3742
return Unit.Default;
3843
}
3944
);
40-
45+
46+
this.WhenAnyValue(vm => vm.InnerItem.IsActive)
47+
.Subscribe(value => IsActive = value)
48+
.DisposeWith(_disposables);
49+
50+
this.WhenAnyValue(vm => vm.InnerItem.ModName)
51+
.Subscribe(value => ModName = value)
52+
.DisposeWith(_disposables);
4153
}
4254

4355

44-
56+
private bool _isDisposed;
57+
protected override void Dispose(bool disposing)
58+
{
59+
if (!_isDisposed)
60+
{
61+
if (disposing)
62+
{
63+
_disposables.Dispose();
64+
}
65+
66+
_isDisposed = true;
67+
}
68+
69+
base.Dispose(disposing);
70+
}
4571
}

src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml

+107-58
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,106 @@
77
xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons"
88
xmlns:sorting="clr-namespace:NexusMods.App.UI.Pages.Sorting"
99
xmlns:alerts="clr-namespace:NexusMods.App.UI.Controls.Alerts"
10-
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
10+
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
1111
x:Class="NexusMods.App.UI.Pages.Sorting.LoadOrderView">
1212
<Design.DataContext>
1313
<sorting:LoadOrderDesignViewModel />
1414
</Design.DataContext>
1515

16-
<Grid RowDefinitions="Auto, *">
17-
<!-- <Border Background="Red"> -->
18-
<!-- <TextBlock Text="{Binding SortOrderName}"/> -->
19-
<!-- </Border> -->
20-
21-
<StackPanel Spacing="24"
22-
Grid.Row="0">
23-
<alerts:Alert
24-
Severity="Info"
25-
Title="Load Order for REDmod files in Cyberpunk 2077 - First Loaded Wins"
26-
Body="Some Cyberpunk 2077 mods use REDmod files to alter core gameplay elements. If two REDmod files modify the same part of the game, the one loaded first will take priority and overwrite changes from those loaded later.\n\nFor example, the 1st position overwrites the 2nd, the 2nd overwrites the 3rd, and so on."
27-
IsVisible="True"
28-
ShowDismiss="False" />
29-
30-
<TextBlock Grid.Row="1" Text="Last Loaded REDmod File Wins"
31-
Theme="{StaticResource HeadingXSSemiTheme}" />
32-
</StackPanel>
33-
34-
35-
<Grid Grid.Row="1" ColumnDefinitions="50, *" Margin="0,24,0,0">
36-
37-
<Grid RowDefinitions="24, 8, *, 8, 24" Margin="0,60,0,0">
38-
<icons:UnifiedIcon Grid.Row="0" Value="{x:Static icons:IconValues.Trophy}" />
39-
<Border Grid.Row="2" Width="5">
40-
<Border.Background>
41-
<LinearGradientBrush StartPoint="0%,0%" EndPoint="0%,100%">
42-
<GradientStop Color="#FFFFFFFF" Offset="0" />
43-
<GradientStop Color="#32FFFFFF" Offset="1" />
44-
</LinearGradientBrush>
45-
</Border.Background>
46-
</Border>
47-
<icons:UnifiedIcon Grid.Row="4" Value="{x:Static icons:IconValues.ArrowDown}" Foreground="#32FFFFFF" />
48-
</Grid>
49-
50-
<TreeDataGrid Grid.Column="1" x:Name="SortOrderTreeDataGrid"
51-
AutoDragDropRows="False"
52-
CanUserResizeColumns="True"
53-
CanUserSortColumns="False"
54-
ShowColumnHeaders="True"
55-
RowDrop="OnRowDrop">
16+
<controls:EmptyState x:Name="EmptyState"
17+
Header="{Binding EmptyStateMessageTitle}">
18+
19+
<controls:EmptyState.Subtitle>
20+
<TextBlock Text="{Binding EmptyStateMessageContents}" />
21+
</controls:EmptyState.Subtitle>
22+
23+
<Grid RowDefinitions="Auto, Auto, *">
24+
<Border Grid.Row="0" Classes="Toolbar">
25+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
26+
<ComboBox SelectedIndex="0" Classes="Secondary">
27+
<ComboBox.ItemTemplate>
28+
<DataTemplate>
29+
<StackPanel Orientation="Horizontal">
30+
<icons:UnifiedIcon Value="{x:Static icons:IconValues.Sort}" Size="20" />
31+
<TextBlock Text="Ascending (1st top)" Theme="{StaticResource BodyMDNormalTheme}" />
32+
</StackPanel>
33+
</DataTemplate>
34+
</ComboBox.ItemTemplate>
35+
<ComboBoxItem>
36+
<StackPanel Orientation="Horizontal">
37+
<icons:UnifiedIcon Value="{x:Static icons:IconValues.SortAscending}" Size="20" />
38+
<TextBlock Text="Ascending (1st top)" Theme="{StaticResource BodyMDNormalTheme}" />
39+
</StackPanel>
40+
</ComboBoxItem>
41+
<ComboBoxItem>
42+
<StackPanel Orientation="Horizontal">
43+
<icons:UnifiedIcon Value="{x:Static icons:IconValues.SortDescending}" Size="20" />
44+
<TextBlock Text="Descending (1st bottom)" Theme="{StaticResource BodyMDNormalTheme}" />
45+
</StackPanel>
46+
</ComboBoxItem>
47+
</ComboBox>
48+
<CheckBox>
49+
<TextBlock Text="Hide Disabled Collections" Theme="{StaticResource BodyMDNormalTheme}" />
50+
</CheckBox>
51+
<Separator Width="1" Height="32" Background="{StaticResource StrokeTranslucentWeakBrush}" />
52+
<controls:StandardButton
53+
Size="Small"
54+
Text="Add to group" />
55+
<ComboBox SelectedIndex="0" Classes="Secondary">
56+
<ComboBox.ItemTemplate>
57+
<DataTemplate>
58+
<TextBlock Text="New group" Theme="{StaticResource BodyMDNormalTheme}" />
59+
</DataTemplate>
60+
</ComboBox.ItemTemplate>
61+
<ComboBoxItem Content="Item 1" />
62+
<ComboBoxItem Content="Item 2" />
63+
<ComboBoxItem Content="Item 3" />
64+
</ComboBox>
65+
</StackPanel>
66+
</Border>
67+
68+
<StackPanel Grid.Row="1" Spacing="24" Margin="24">
69+
<alerts:Alert
70+
Severity="Info"
71+
Title="Load Order for REDmod files in Cyberpunk 2077 - First Loaded Wins"
72+
Body="Some Cyberpunk 2077 mods use REDmod files to alter core gameplay elements. If two REDmod files modify the same part of the game, the one loaded first will take priority and overwrite changes from those loaded later.\n\nFor example, the 1st position overwrites the 2nd, the 2nd overwrites the 3rd, and so on."
73+
IsVisible="True"
74+
ShowDismiss="False" />
75+
76+
<TextBlock Text="Last Loaded REDmod File Wins"
77+
Theme="{StaticResource HeadingXSSemiTheme}" />
78+
</StackPanel>
5679

57-
<TreeDataGrid.Resources>
80+
<Grid Grid.Row="2" ColumnDefinitions="32, *" Margin="24,0,24,24">
5881

59-
<DataTemplate x:Key="LoadOrderItemIndexColumnTemplate"
60-
DataType="sorting:ILoadOrderItemModel">
82+
<!-- left column (trophy bar) -->
83+
<DockPanel x:Name="TrophyBarPanel" HorizontalAlignment="Left">
84+
<icons:UnifiedIcon x:Name="TrophyIcon" Margin="0,8,0,8" DockPanel.Dock="Top"
85+
Value="{x:Static icons:IconValues.Trophy}" Size="20" />
86+
87+
<Grid RowDefinitions="Auto, *, Auto" HorizontalAlignment="Center">
88+
<icons:UnifiedIcon x:Name="ArrowUpIcon" Grid.Row="0"
89+
Value="{x:Static icons:IconValues.ArrowUpThick}"
90+
Size="20" />
91+
<Border Grid.Row="1" x:Name="TrophyGradientBorder" Width="3" Margin="0,4" />
92+
<icons:UnifiedIcon x:Name="ArrowDownIcon" Grid.Row="2"
93+
Value="{x:Static icons:IconValues.ArrowDownThick}"
94+
Size="20" />
95+
</Grid>
96+
</DockPanel>
97+
98+
<!-- right column (tree data grid) -->
99+
<TreeDataGrid Grid.Column="1" x:Name="SortOrderTreeDataGrid"
100+
AutoDragDropRows="False"
101+
CanUserResizeColumns="True"
102+
CanUserSortColumns="False"
103+
ShowColumnHeaders="True"
104+
RowDrop="OnRowDrop">
105+
106+
<TreeDataGrid.Resources>
107+
108+
<DataTemplate x:Key="LoadOrderItemIndexColumnTemplate"
109+
DataType="sorting:ILoadOrderItemModel">
61110

62111
<StackPanel Orientation="Horizontal" Spacing="12">
63112
<controls:StandardButton x:Name="UpButton"
@@ -89,24 +138,24 @@
89138
Fill="None" />
90139
<Border
91140
Background="{StaticResource SurfaceTranslucentMidBrush}"
92-
Width="1"
93-
Height="42"/>
141+
Width="1"
142+
Height="42" />
94143
</StackPanel>
95-
</DataTemplate>
144+
</DataTemplate>
96145

97-
<DataTemplate x:Key="LoadOrderItemNameColumnTemplate"
98-
DataType="sorting:ILoadOrderItemModel">
99-
<StackPanel Orientation="Horizontal">
100-
<TextBlock x:Name="ItemName"
101-
Text="{CompiledBinding DisplayName}" />
102-
</StackPanel>
103-
</DataTemplate>
146+
<DataTemplate x:Key="LoadOrderItemNameColumnTemplate"
147+
DataType="sorting:ILoadOrderItemModel">
148+
<StackPanel Orientation="Horizontal">
149+
<TextBlock x:Name="ItemName"
150+
Text="{CompiledBinding DisplayName}" />
151+
</StackPanel>
152+
</DataTemplate>
104153

105-
</TreeDataGrid.Resources>
154+
</TreeDataGrid.Resources>
106155

107-
</TreeDataGrid>
156+
</TreeDataGrid>
157+
</Grid>
108158
</Grid>
109-
110-
</Grid>
159+
</controls:EmptyState>
111160

112161
</reactiveUi:ReactiveUserControl>

src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml.cs

+27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
using System.ComponentModel;
12
using System.Reactive.Disposables;
23
using Avalonia.Controls;
34
using Avalonia.ReactiveUI;
45
using NexusMods.App.UI.Controls;
6+
using NexusMods.App.UI.Helpers;
57
using ReactiveUI;
68

79
namespace NexusMods.App.UI.Pages.Sorting;
@@ -25,6 +27,31 @@ public LoadOrderView()
2527
view => view.SortOrderTreeDataGrid.Source
2628
)
2729
.DisposeWith(disposables);
30+
31+
this.WhenAnyValue(view => view.ViewModel!.SortDirectionCurrent)
32+
.Subscribe(sortCurrentDirection =>
33+
{
34+
var isAscending = sortCurrentDirection == ListSortDirection.Ascending;
35+
ArrowUpIcon.IsVisible = !isAscending;
36+
ArrowDownIcon.IsVisible = isAscending;
37+
}
38+
)
39+
.DisposeWith(disposables);
40+
41+
this.WhenAnyValue(view => view.ViewModel!.IsWinnerTop)
42+
.Subscribe(isWinnerTop =>
43+
{
44+
DockPanel.SetDock(TrophyIcon, isWinnerTop ? Dock.Top : Dock.Bottom);
45+
TrophyBarPanel.Classes.Add(isWinnerTop ? "IsWinnerTop" : "IsWinnerBottom");
46+
}
47+
)
48+
.DisposeWith(disposables);
49+
50+
// empty state
51+
this.OneWayBind(ViewModel,
52+
vm => vm.Adapter.IsSourceEmpty.Value,
53+
view => view.EmptyState.IsActive)
54+
.DisposeWith(disposables);
2855
}
2956
);
3057
}

0 commit comments

Comments
 (0)