From 80cee17a0bd1dc38e90b66a732bb48db30a19335 Mon Sep 17 00:00:00 2001 From: insomnious Date: Wed, 27 Nov 2024 10:08:15 +0000 Subject: [PATCH 1/6] add compact style to combobox --- .../Sorting/LoadOrder/LoadOrderView.axaml | 20 +++++++---- .../Controls/ComboBox/ComboBoxStyles.axaml | 34 +++++++++++++++++++ 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml index 3063e39386..f34b48eb4a 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml +++ b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml @@ -23,7 +23,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -81,15 +81,21 @@ - + - - - + diff --git a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/ComboBox/ComboBoxStyles.axaml b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/ComboBox/ComboBoxStyles.axaml index 48b3154970..48444c8a4f 100644 --- a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/ComboBox/ComboBoxStyles.axaml +++ b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/ComboBox/ComboBoxStyles.axaml @@ -100,6 +100,23 @@ Item 2 + + + + Item 1 + Item 2 + + + + Item 1 + Item 2 + + + + Item 1 + Item 2 + + @@ -200,6 +217,8 @@ + + + + + + + From 99f5a7f627a5c18c394ecbfe6aa4f2fa2ebd1ee9 Mon Sep 17 00:00:00 2001 From: insomnious Date: Wed, 27 Nov 2024 12:16:20 +0000 Subject: [PATCH 2/6] added checkbox styles --- .../Sorting/LoadOrder/LoadOrderView.axaml | 6 +- .../Controls/CheckBox/CheckBoxStyles.axaml | 123 ++++++++++++++++-- 2 files changed, 117 insertions(+), 12 deletions(-) diff --git a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml index f34b48eb4a..66ae554e2f 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml +++ b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml @@ -22,7 +22,7 @@ - + @@ -45,9 +45,7 @@ - - - + + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 133889baa86b767e0ab69d224ee5b9a0fffa880e Mon Sep 17 00:00:00 2001 From: insomnious Date: Wed, 27 Nov 2024 12:55:07 +0000 Subject: [PATCH 3/6] toolbar combo style --- .../Pages/Sorting/LoadOrder/LoadOrderView.axaml | 8 ++++---- .../Styles/Controls/ComboBox/ComboBoxStyles.axaml | 12 +++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml index 66ae554e2f..6460bfe829 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml +++ b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml @@ -22,8 +22,8 @@ - - + + @@ -45,8 +45,8 @@ - - + + diff --git a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/ComboBox/ComboBoxStyles.axaml b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/ComboBox/ComboBoxStyles.axaml index 48444c8a4f..93addf5feb 100644 --- a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/ComboBox/ComboBoxStyles.axaml +++ b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/ComboBox/ComboBoxStyles.axaml @@ -309,6 +309,7 @@ + + + + From 56560285275f223bb894f4135490c814bd66b73e Mon Sep 17 00:00:00 2001 From: insomnious Date: Wed, 27 Nov 2024 15:19:10 +0000 Subject: [PATCH 4/6] Fixes ComboBoxItem having wrong padding --- .../Styles/Controls/TabControl/TabControlStyles.axaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/TabControl/TabControlStyles.axaml b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/TabControl/TabControlStyles.axaml index dde946d19d..a4ace35060 100644 --- a/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/TabControl/TabControlStyles.axaml +++ b/src/Themes/NexusMods.Themes.NexusFluentDark/Styles/Controls/TabControl/TabControlStyles.axaml @@ -155,7 +155,7 @@ - From 18f92aae8352eecacd82368f149bec8d9609aba1 Mon Sep 17 00:00:00 2001 From: insomnious Date: Wed, 27 Nov 2024 16:02:24 +0000 Subject: [PATCH 5/6] Moved Alert visibility swapping into code-behind --- .../Controls/Alerts/Alert.axaml.cs | 6 +++++- .../Controls/Alerts/AlertSettingsWrapper.cs | 14 ++++++++++++-- .../ControlThemes/AlertControlTheme.axaml | 4 ---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/NexusMods.App.UI/Controls/Alerts/Alert.axaml.cs b/src/NexusMods.App.UI/Controls/Alerts/Alert.axaml.cs index 6304c24670..f8ed6485be 100644 --- a/src/NexusMods.App.UI/Controls/Alerts/Alert.axaml.cs +++ b/src/NexusMods.App.UI/Controls/Alerts/Alert.axaml.cs @@ -200,6 +200,11 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang } } + if (change.Property == IsDismissedProperty) + { + IsVisible = !IsDismissed; + } + base.OnPropertyChanged(change); } @@ -225,7 +230,6 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e) if (_icon == null || _dismissButton == null || _titleText == null || _bodyText == null || _bodyTextBorder == null || _actionsRowBorder == null) return; - // turn off elements based on properties _dismissButton.IsVisible = ShowDismiss; _bodyTextBorder.IsVisible = ShowBody && !string.IsNullOrWhiteSpace(Body); diff --git a/src/NexusMods.App.UI/Controls/Alerts/AlertSettingsWrapper.cs b/src/NexusMods.App.UI/Controls/Alerts/AlertSettingsWrapper.cs index 1ec799e0a0..e078ad57ca 100644 --- a/src/NexusMods.App.UI/Controls/Alerts/AlertSettingsWrapper.cs +++ b/src/NexusMods.App.UI/Controls/Alerts/AlertSettingsWrapper.cs @@ -22,7 +22,7 @@ public AlertSettingsWrapper() public AlertSettingsWrapper(ISettingsManager settingsManager, string key) { _settingsManager = settingsManager; - + Key = key; IsDismissed = settingsManager.Get().IsDismissed(key); } @@ -33,7 +33,17 @@ public void DismissAlert() _settingsManager?.Update(alertSettings => alertSettings with { - AlertStatus = alertSettings.AlertStatus.SetItem(Key, true), + AlertStatus = alertSettings.AlertStatus.SetItem(Key, IsDismissed), + }); + } + + public void ShowAlert() + { + IsDismissed = false; + + _settingsManager?.Update(alertSettings => alertSettings with + { + AlertStatus = alertSettings.AlertStatus.SetItem(Key, IsDismissed), }); } } diff --git a/src/Themes/NexusMods.Themes.NexusFluentDark/Resources/ControlThemes/AlertControlTheme.axaml b/src/Themes/NexusMods.Themes.NexusFluentDark/Resources/ControlThemes/AlertControlTheme.axaml index 5d3646ccbf..d01734b149 100644 --- a/src/Themes/NexusMods.Themes.NexusFluentDark/Resources/ControlThemes/AlertControlTheme.axaml +++ b/src/Themes/NexusMods.Themes.NexusFluentDark/Resources/ControlThemes/AlertControlTheme.axaml @@ -196,10 +196,6 @@ - - From 910ce076eef883e1c8d657e461db5bf541cbc70e Mon Sep 17 00:00:00 2001 From: insomnious Date: Wed, 27 Nov 2024 16:05:42 +0000 Subject: [PATCH 6/6] Functionality to hide and show Alert and write to Settings --- .../Sorting/LoadOrder/ILoadOrderViewModel.cs | 6 +++++ .../Sorting/LoadOrder/LoadOrderView.axaml | 24 ++++++++++++------- .../Sorting/LoadOrder/LoadOrderView.axaml.cs | 4 ++++ .../LoadOrder/LoadOrderViewDesignViewModel.cs | 12 +++++++--- .../Sorting/LoadOrder/LoadOrderViewModel.cs | 14 ++++++++++- .../SortingSelectionDesignViewModel.cs | 21 ++++++++++------ .../SortingSelectionViewModel.cs | 5 +++- 7 files changed, 65 insertions(+), 21 deletions(-) diff --git a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/ILoadOrderViewModel.cs b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/ILoadOrderViewModel.cs index 11340eb024..a36629f10f 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/ILoadOrderViewModel.cs +++ b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/ILoadOrderViewModel.cs @@ -2,6 +2,7 @@ using System.Reactive; using NexusMods.Abstractions.UI; using NexusMods.App.UI.Controls; +using NexusMods.App.UI.Controls.Alerts; using ReactiveUI; namespace NexusMods.App.UI.Pages.Sorting; @@ -71,4 +72,9 @@ public interface ILoadOrderViewModel : IViewModelInterface /// Contents text for the empty state, in case there are no sortable items to display /// string EmptyStateMessageContents { get; } + + /// + /// AlertSettings wrapper for the Alert so it can be shown\hidden based on the settings + /// + AlertSettingsWrapper AlertSettingsWrapper { get; } } diff --git a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml index 6460bfe829..cf589611f6 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml +++ b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml @@ -64,15 +64,21 @@ - - - + + + + + + diff --git a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml.cs b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml.cs index 32e1051180..247b572a1f 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml.cs +++ b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderView.axaml.cs @@ -52,6 +52,10 @@ public LoadOrderView() vm => vm.Adapter.IsSourceEmpty.Value, view => view.EmptyState.IsActive) .DisposeWith(disposables); + + // alert + this.OneWayBind(ViewModel, vm => vm.AlertSettingsWrapper, view => view.LoadOrderAlert.AlertSettings) + .DisposeWith(disposables); } ); } diff --git a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderViewDesignViewModel.cs b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderViewDesignViewModel.cs index 3bf804806d..b02a25209b 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderViewDesignViewModel.cs +++ b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderViewDesignViewModel.cs @@ -6,8 +6,11 @@ using Avalonia.Controls.Models.TreeDataGrid; using DynamicData; using DynamicData.Binding; +using NexusMods.Abstractions.Settings; using NexusMods.Abstractions.UI; using NexusMods.App.UI.Controls; +using NexusMods.App.UI.Controls.Alerts; +using NexusMods.App.UI.Settings; using ReactiveUI; namespace NexusMods.App.UI.Pages.Sorting; @@ -20,15 +23,16 @@ public class LoadOrderDesignViewModel : AViewModel, ILoadOr public string InfoAlertHeading { get; set;} = "Info Alert Heading"; public string InfoAlertMessage { get; set;} = "Info Alert Message"; public bool InfoAlertIsVisible { get; set; } = true; - public ReactiveCommand InfoAlertCommand { get; } = ReactiveCommand.Create(() => { Console.WriteLine("InfoAlertCommand"); }); + public ReactiveCommand InfoAlertCommand { get; } = ReactiveCommand.Create(() => { }); public string TrophyToolTip { get; set;} = "Trophy Tool Tip"; public ListSortDirection SortDirectionCurrent { get; set; } public bool IsWinnerTop { get; set;} public string EmptyStateMessageTitle { get; } = "Empty State Message Title"; public string EmptyStateMessageContents { get; } = "Empty State Message Contents"; + public AlertSettingsWrapper AlertSettingsWrapper { get; } - public LoadOrderDesignViewModel() - { + public LoadOrderDesignViewModel(ISettingsManager settingsManager) + { Adapter = new LoadOrderTreeDataGridDesignAdapter(); this.WhenActivated(d => @@ -38,6 +42,8 @@ public LoadOrderDesignViewModel() .DisposeWith(d); } ); + + AlertSettingsWrapper = new AlertSettingsWrapper(settingsManager, "cyberpunk2077 redmod load-order first-loaded-wins"); } } diff --git a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderViewModel.cs b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderViewModel.cs index c60a119f6a..673f1f33ec 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderViewModel.cs +++ b/src/NexusMods.App.UI/Pages/Sorting/LoadOrder/LoadOrderViewModel.cs @@ -7,8 +7,11 @@ using DynamicData.Binding; using NexusMods.Abstractions.Games; using NexusMods.Abstractions.Loadouts; +using NexusMods.Abstractions.Settings; using NexusMods.Abstractions.UI; using NexusMods.App.UI.Controls; +using NexusMods.App.UI.Controls.Alerts; +using NexusMods.App.UI.Settings; using ReactiveUI; using ReactiveUI.Fody.Helpers; @@ -27,10 +30,12 @@ public class LoadOrderViewModel : AViewModel, ILoadOrderVie [Reactive] public bool IsWinnerTop { get; private set; } public string EmptyStateMessageTitle { get; } public string EmptyStateMessageContents { get; } + + public AlertSettingsWrapper AlertSettingsWrapper { get; } public TreeDataGridAdapter Adapter { get; } - public LoadOrderViewModel(LoadoutId loadoutId, ISortableItemProviderFactory itemProviderFactory) + public LoadOrderViewModel(LoadoutId loadoutId, ISortableItemProviderFactory itemProviderFactory, ISettingsManager settingsManager) { var provider = itemProviderFactory.GetLoadoutSortableItemProvider(loadoutId); @@ -52,6 +57,13 @@ public LoadOrderViewModel(LoadoutId loadoutId, ISortableItemProviderFactory item var sortDirectionObservable = this.WhenAnyValue(vm => vm.SortDirectionCurrent); Adapter = new LoadOrderTreeDataGridAdapter(provider, sortDirectionObservable); Adapter.ViewHierarchical.Value = true; + + AlertSettingsWrapper = new AlertSettingsWrapper(settingsManager, "cyberpunk2077 redmod load-order first-loaded-wins"); + + InfoAlertCommand = ReactiveCommand.Create(() => + { + AlertSettingsWrapper.ShowAlert(); + }); this.WhenActivated(d => { diff --git a/src/NexusMods.App.UI/Pages/Sorting/SortingSelection/SortingSelectionDesignViewModel.cs b/src/NexusMods.App.UI/Pages/Sorting/SortingSelection/SortingSelectionDesignViewModel.cs index b70b6c78d3..5bc6ade038 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/SortingSelection/SortingSelectionDesignViewModel.cs +++ b/src/NexusMods.App.UI/Pages/Sorting/SortingSelection/SortingSelectionDesignViewModel.cs @@ -1,24 +1,31 @@ using System.Collections.ObjectModel; using NexusMods.Abstractions.UI; +using Microsoft.Extensions.DependencyInjection; +using NexusMods.Abstractions.Settings; namespace NexusMods.App.UI.Pages.Sorting; public class SortingSelectionDesignViewModel : AViewModel, ISortingSelectionViewModel { + private readonly ISettingsManager _settingsManager; public ReadOnlyObservableCollection LoadOrderViewModels { get; } - - public SortingSelectionDesignViewModel() + public SortingSelectionDesignViewModel(IServiceProvider serviceProvider) { + _settingsManager = serviceProvider.GetRequiredService(); + var loadOrderViewModels = new ObservableCollection { - new LoadOrderDesignViewModel { SortOrderName = "Load order (RedMOD)", + new LoadOrderDesignViewModel(_settingsManager) + { + SortOrderName = "Load order (RedMOD)", InfoAlertHeading = "Load Order for REDmod files in Cyberpunk 2077 - First Loaded Wins", - InfoAlertMessage = "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." + InfoAlertMessage = + "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." }, - new LoadOrderDesignViewModel { SortOrderName = "Load Order (Archive XL)" }, - new LoadOrderDesignViewModel { SortOrderName = "File Overwrites" } + new LoadOrderDesignViewModel(_settingsManager) { SortOrderName = "Load Order (Archive XL)" }, + new LoadOrderDesignViewModel(_settingsManager) { SortOrderName = "File Overwrites" } }; - + LoadOrderViewModels = new ReadOnlyObservableCollection(loadOrderViewModels); } } diff --git a/src/NexusMods.App.UI/Pages/Sorting/SortingSelection/SortingSelectionViewModel.cs b/src/NexusMods.App.UI/Pages/Sorting/SortingSelection/SortingSelectionViewModel.cs index 098e935aaf..423e51ca4d 100644 --- a/src/NexusMods.App.UI/Pages/Sorting/SortingSelection/SortingSelectionViewModel.cs +++ b/src/NexusMods.App.UI/Pages/Sorting/SortingSelection/SortingSelectionViewModel.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using NexusMods.Abstractions.Games; using NexusMods.Abstractions.Loadouts; +using NexusMods.Abstractions.Settings; using NexusMods.Abstractions.UI; using NexusMods.MnemonicDB.Abstractions; @@ -11,12 +12,14 @@ public class SortingSelectionViewModel : AViewModel, { private readonly LoadoutId _loadoutId; private readonly IConnection _connection; + private readonly ISettingsManager _settingsManager; public ReadOnlyObservableCollection LoadOrderViewModels { get; } public SortingSelectionViewModel(IServiceProvider serviceProvider, LoadoutId loadutId) { _loadoutId = loadutId; _connection = serviceProvider.GetRequiredService(); + _settingsManager = serviceProvider.GetRequiredService(); var loadout = Loadout.Load(_connection.Db, _loadoutId); var sortableItemProviders = loadout @@ -26,7 +29,7 @@ public SortingSelectionViewModel(IServiceProvider serviceProvider, LoadoutId loa LoadOrderViewModels = new ReadOnlyObservableCollection( new ObservableCollection( - sortableItemProviders.Select(provider => new LoadOrderViewModel(_loadoutId, provider)) + sortableItemProviders.Select(provider => new LoadOrderViewModel(_loadoutId, provider, _settingsManager)) ) ); }