Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into docs-070
Browse files Browse the repository at this point in the history
  • Loading branch information
Pickysaurus committed Nov 27, 2024
2 parents 0bf4cac + 86a6991 commit debf7fa
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ private async Task PersistSortableEntries(List<RedModSortableItem> orderList)

private static bool RedModIsEnabled(RedModLoadoutGroup.ReadOnly grp)
{
return !grp.AsLoadoutItemGroup().AsLoadoutItem().GetThisAndParents().Any(f => f.Contains(LoadoutItem.Disabled));
return grp.AsLoadoutItemGroup().AsLoadoutItem().IsEnabled();
}

private static RelativePath RedModFolder(RedModLoadoutGroup.ReadOnly group)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reactive;
using NexusMods.Abstractions.Games;
using NexusMods.App.UI.Controls;
using ReactiveUI;

Expand Down
36 changes: 31 additions & 5 deletions src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderItemModel.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
using System.Reactive;
using System.Reactive.Disposables;
using NexusMods.Abstractions.Games;
using NexusMods.App.UI.Controls;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;

namespace NexusMods.App.UI.Pages.Sorting;

public class LoadOrderItemModel : TreeDataGridItemModel<ILoadOrderItemModel, Guid>, ILoadOrderItemModel
{
private CompositeDisposable _disposables = new();
public ISortableItem InnerItem { get; }

public ReactiveCommand<Unit, Unit> MoveUp { get; }
public ReactiveCommand<Unit, Unit> MoveDown { get; }
public int SortIndex { get; }
public string DisplayName { get; }

// TODO: Populate these properly
public string ModName { get; } = string.Empty;
public bool IsActive { get; } = true;
[Reactive] public string ModName { get; private set; }
[Reactive] public bool IsActive { get; private set; }

public LoadOrderItemModel(ISortableItem sortableItem)
{
InnerItem = sortableItem;
SortIndex = sortableItem.SortIndex;
DisplayName = sortableItem.DisplayName;

IsActive = sortableItem.IsActive;
ModName = sortableItem.ModName;

MoveUp = ReactiveCommand.CreateFromTask(async () =>
{
await sortableItem.SortableItemProvider.SetRelativePosition(InnerItem, delta: 1);
Expand All @@ -37,9 +42,30 @@ public LoadOrderItemModel(ISortableItem sortableItem)
return Unit.Default;
}
);


this.WhenAnyValue(vm => vm.InnerItem.IsActive)
.Subscribe(value => IsActive = value)
.DisposeWith(_disposables);

this.WhenAnyValue(vm => vm.InnerItem.ModName)
.Subscribe(value => ModName = value)
.DisposeWith(_disposables);
}



private bool _isDisposed;
protected override void Dispose(bool disposing)
{
if (!_isDisposed)
{
if (disposing)
{
_disposables.Dispose();
}

_isDisposed = true;
}

base.Dispose(disposing);
}
}
165 changes: 107 additions & 58 deletions src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,106 @@
xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons"
xmlns:sorting="clr-namespace:NexusMods.App.UI.Pages.Sorting"
xmlns:alerts="clr-namespace:NexusMods.App.UI.Controls.Alerts"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
x:Class="NexusMods.App.UI.Pages.Sorting.LoadOrderView">
<Design.DataContext>
<sorting:LoadOrderDesignViewModel />
</Design.DataContext>

<Grid RowDefinitions="Auto, *">
<!-- <Border Background="Red"> -->
<!-- <TextBlock Text="{Binding SortOrderName}"/> -->
<!-- </Border> -->

<StackPanel Spacing="24"
Grid.Row="0">
<alerts:Alert
Severity="Info"
Title="Load Order for REDmod files in Cyberpunk 2077 - First Loaded Wins"
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."
IsVisible="True"
ShowDismiss="False" />

<TextBlock Grid.Row="1" Text="Last Loaded REDmod File Wins"
Theme="{StaticResource HeadingXSSemiTheme}" />
</StackPanel>


<Grid Grid.Row="1" ColumnDefinitions="50, *" Margin="0,24,0,0">

<Grid RowDefinitions="24, 8, *, 8, 24" Margin="0,60,0,0">
<icons:UnifiedIcon Grid.Row="0" Value="{x:Static icons:IconValues.Trophy}" />
<Border Grid.Row="2" Width="5">
<Border.Background>
<LinearGradientBrush StartPoint="0%,0%" EndPoint="0%,100%">
<GradientStop Color="#FFFFFFFF" Offset="0" />
<GradientStop Color="#32FFFFFF" Offset="1" />
</LinearGradientBrush>
</Border.Background>
</Border>
<icons:UnifiedIcon Grid.Row="4" Value="{x:Static icons:IconValues.ArrowDown}" Foreground="#32FFFFFF" />
</Grid>

<TreeDataGrid Grid.Column="1" x:Name="SortOrderTreeDataGrid"
AutoDragDropRows="False"
CanUserResizeColumns="True"
CanUserSortColumns="False"
ShowColumnHeaders="True"
RowDrop="OnRowDrop">
<controls:EmptyState x:Name="EmptyState"
Header="{Binding EmptyStateMessageTitle}">

<controls:EmptyState.Subtitle>
<TextBlock Text="{Binding EmptyStateMessageContents}" />
</controls:EmptyState.Subtitle>

<Grid RowDefinitions="Auto, Auto, *">
<Border Grid.Row="0" Classes="Toolbar">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
<ComboBox SelectedIndex="0" Classes="Secondary">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<icons:UnifiedIcon Value="{x:Static icons:IconValues.Sort}" Size="20" />
<TextBlock Text="Ascending (1st top)" Theme="{StaticResource BodyMDNormalTheme}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<icons:UnifiedIcon Value="{x:Static icons:IconValues.SortAscending}" Size="20" />
<TextBlock Text="Ascending (1st top)" Theme="{StaticResource BodyMDNormalTheme}" />
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<icons:UnifiedIcon Value="{x:Static icons:IconValues.SortDescending}" Size="20" />
<TextBlock Text="Descending (1st bottom)" Theme="{StaticResource BodyMDNormalTheme}" />
</StackPanel>
</ComboBoxItem>
</ComboBox>
<CheckBox>
<TextBlock Text="Hide Disabled Collections" Theme="{StaticResource BodyMDNormalTheme}" />
</CheckBox>
<Separator Width="1" Height="32" Background="{StaticResource StrokeTranslucentWeakBrush}" />
<controls:StandardButton
Size="Small"
Text="Add to group" />
<ComboBox SelectedIndex="0" Classes="Secondary">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="New group" Theme="{StaticResource BodyMDNormalTheme}" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBoxItem Content="Item 1" />
<ComboBoxItem Content="Item 2" />
<ComboBoxItem Content="Item 3" />
</ComboBox>
</StackPanel>
</Border>

<StackPanel Grid.Row="1" Spacing="24" Margin="24">
<alerts:Alert
Severity="Info"
Title="Load Order for REDmod files in Cyberpunk 2077 - First Loaded Wins"
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."
IsVisible="True"
ShowDismiss="False" />

<TextBlock Text="Last Loaded REDmod File Wins"
Theme="{StaticResource HeadingXSSemiTheme}" />
</StackPanel>

<TreeDataGrid.Resources>
<Grid Grid.Row="2" ColumnDefinitions="32, *" Margin="24,0,24,24">

<DataTemplate x:Key="LoadOrderItemIndexColumnTemplate"
DataType="sorting:ILoadOrderItemModel">
<!-- left column (trophy bar) -->
<DockPanel x:Name="TrophyBarPanel" HorizontalAlignment="Left">
<icons:UnifiedIcon x:Name="TrophyIcon" Margin="0,8,0,8" DockPanel.Dock="Top"
Value="{x:Static icons:IconValues.Trophy}" Size="20" />

<Grid RowDefinitions="Auto, *, Auto" HorizontalAlignment="Center">
<icons:UnifiedIcon x:Name="ArrowUpIcon" Grid.Row="0"
Value="{x:Static icons:IconValues.ArrowUpThick}"
Size="20" />
<Border Grid.Row="1" x:Name="TrophyGradientBorder" Width="3" Margin="0,4" />
<icons:UnifiedIcon x:Name="ArrowDownIcon" Grid.Row="2"
Value="{x:Static icons:IconValues.ArrowDownThick}"
Size="20" />
</Grid>
</DockPanel>

<!-- right column (tree data grid) -->
<TreeDataGrid Grid.Column="1" x:Name="SortOrderTreeDataGrid"
AutoDragDropRows="False"
CanUserResizeColumns="True"
CanUserSortColumns="False"
ShowColumnHeaders="True"
RowDrop="OnRowDrop">

<TreeDataGrid.Resources>

<DataTemplate x:Key="LoadOrderItemIndexColumnTemplate"
DataType="sorting:ILoadOrderItemModel">

<StackPanel Orientation="Horizontal" Spacing="12">
<controls:StandardButton x:Name="UpButton"
Expand Down Expand Up @@ -89,24 +138,24 @@
Fill="None" />
<Border
Background="{StaticResource SurfaceTranslucentMidBrush}"
Width="1"
Height="42"/>
Width="1"
Height="42" />
</StackPanel>
</DataTemplate>
</DataTemplate>

<DataTemplate x:Key="LoadOrderItemNameColumnTemplate"
DataType="sorting:ILoadOrderItemModel">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="ItemName"
Text="{CompiledBinding DisplayName}" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="LoadOrderItemNameColumnTemplate"
DataType="sorting:ILoadOrderItemModel">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="ItemName"
Text="{CompiledBinding DisplayName}" />
</StackPanel>
</DataTemplate>

</TreeDataGrid.Resources>
</TreeDataGrid.Resources>

</TreeDataGrid>
</TreeDataGrid>
</Grid>
</Grid>

</Grid>
</controls:EmptyState>

</reactiveUi:ReactiveUserControl>
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.ComponentModel;
using System.Reactive.Disposables;
using Avalonia.Controls;
using Avalonia.ReactiveUI;
using NexusMods.App.UI.Controls;
using NexusMods.App.UI.Helpers;
using ReactiveUI;

namespace NexusMods.App.UI.Pages.Sorting;
Expand All @@ -25,6 +27,31 @@ public LoadOrderView()
view => view.SortOrderTreeDataGrid.Source
)
.DisposeWith(disposables);
this.WhenAnyValue(view => view.ViewModel!.SortDirectionCurrent)
.Subscribe(sortCurrentDirection =>
{
var isAscending = sortCurrentDirection == ListSortDirection.Ascending;
ArrowUpIcon.IsVisible = !isAscending;
ArrowDownIcon.IsVisible = isAscending;
}
)
.DisposeWith(disposables);
this.WhenAnyValue(view => view.ViewModel!.IsWinnerTop)
.Subscribe(isWinnerTop =>
{
DockPanel.SetDock(TrophyIcon, isWinnerTop ? Dock.Top : Dock.Bottom);
TrophyBarPanel.Classes.Add(isWinnerTop ? "IsWinnerTop" : "IsWinnerBottom");
}
)
.DisposeWith(disposables);
// empty state
this.OneWayBind(ViewModel,
vm => vm.Adapter.IsSourceEmpty.Value,
view => view.EmptyState.IsActive)
.DisposeWith(disposables);
}
);
}
Expand Down
Loading

0 comments on commit debf7fa

Please sign in to comment.