From 32ea07c1c79dc667bd436fc63bf2728a684760a7 Mon Sep 17 00:00:00 2001 From: Jos Demmers <8627157+josdemmers@users.noreply.github.com> Date: Sat, 10 Aug 2024 11:46:13 +0200 Subject: [PATCH] Added new affix, aspect, and sigil settings window. --- D4Companion/ViewModels/AffixViewModel.cs | 51 ++++---- .../Dialogs/AffixConfigViewModel.cs | 97 +++++++++++++++ .../Dialogs/AspectConfigViewModel.cs | 97 +++++++++++++++ .../Dialogs/SigilConfigViewModel.cs | 116 ++++++++++++++++++ .../Views/Dialogs/AffixConfigView.xaml | 54 ++++++++ .../Views/Dialogs/AffixConfigView.xaml.cs | 24 ++++ .../Views/Dialogs/AspectConfigView.xaml | 54 ++++++++ .../Views/Dialogs/AspectConfigView.xaml.cs | 24 ++++ .../Views/Dialogs/SigilConfigView.xaml | 55 +++++++++ .../Views/Dialogs/SigilConfigView.xaml.cs | 24 ++++ 10 files changed, 569 insertions(+), 27 deletions(-) create mode 100644 D4Companion/ViewModels/Dialogs/AffixConfigViewModel.cs create mode 100644 D4Companion/ViewModels/Dialogs/AspectConfigViewModel.cs create mode 100644 D4Companion/ViewModels/Dialogs/SigilConfigViewModel.cs create mode 100644 D4Companion/Views/Dialogs/AffixConfigView.xaml create mode 100644 D4Companion/Views/Dialogs/AffixConfigView.xaml.cs create mode 100644 D4Companion/Views/Dialogs/AspectConfigView.xaml create mode 100644 D4Companion/Views/Dialogs/AspectConfigView.xaml.cs create mode 100644 D4Companion/Views/Dialogs/SigilConfigView.xaml create mode 100644 D4Companion/Views/Dialogs/SigilConfigView.xaml.cs diff --git a/D4Companion/ViewModels/AffixViewModel.cs b/D4Companion/ViewModels/AffixViewModel.cs index 15f96858..13540687 100644 --- a/D4Companion/ViewModels/AffixViewModel.cs +++ b/D4Companion/ViewModels/AffixViewModel.cs @@ -823,41 +823,38 @@ private void AddAffixPresetNameExecute() private async void AffixConfigExecute() { - // TODO: New dialog - //var affixConfigDialog = new CustomDialog() { Title = "Affix config" }; - //var dataContext = new AffixConfigViewModel(async instance => - //{ - // await affixConfigDialog.WaitUntilUnloadedAsync(); - //}); - //affixConfigDialog.Content = new AffixConfigView() { DataContext = dataContext }; - //await _dialogCoordinator.ShowMetroDialogAsync(this, affixConfigDialog); - //await affixConfigDialog.WaitUntilUnloadedAsync(); + var affixConfigDialog = new CustomDialog() { Title = "Affix config" }; + var dataContext = new AffixConfigViewModel(async instance => + { + await affixConfigDialog.WaitUntilUnloadedAsync(); + }); + affixConfigDialog.Content = new AffixConfigView() { DataContext = dataContext }; + await _dialogCoordinator.ShowMetroDialogAsync(this, affixConfigDialog); + await affixConfigDialog.WaitUntilUnloadedAsync(); } private async void AspectConfigExecute() { - // TODO: New dialog - //var aspectConfigDialog = new CustomDialog() { Title = "Aspect config" }; - //var dataContext = new AspectConfigViewModel(async instance => - //{ - // await aspectConfigDialog.WaitUntilUnloadedAsync(); - //}); - //aspectConfigDialog.Content = new AspectConfigView() { DataContext = dataContext }; - //await _dialogCoordinator.ShowMetroDialogAsync(this, aspectConfigDialog); - //await aspectConfigDialog.WaitUntilUnloadedAsync(); + var aspectConfigDialog = new CustomDialog() { Title = "Aspect config" }; + var dataContext = new AspectConfigViewModel(async instance => + { + await aspectConfigDialog.WaitUntilUnloadedAsync(); + }); + aspectConfigDialog.Content = new AspectConfigView() { DataContext = dataContext }; + await _dialogCoordinator.ShowMetroDialogAsync(this, aspectConfigDialog); + await aspectConfigDialog.WaitUntilUnloadedAsync(); } private async void SigilConfigExecute() { - // TODO: New dialog - //var sigilConfigDialog = new CustomDialog() { Title = "Sigil config" }; - //var dataContext = new SigilConfigViewModel(async instance => - //{ - // await sigilConfigDialog.WaitUntilUnloadedAsync(); - //}); - //sigilConfigDialog.Content = new SigilConfigView() { DataContext = dataContext }; - //await _dialogCoordinator.ShowMetroDialogAsync(this, sigilConfigDialog); - //await sigilConfigDialog.WaitUntilUnloadedAsync(); + var sigilConfigDialog = new CustomDialog() { Title = "Sigil config" }; + var dataContext = new SigilConfigViewModel(async instance => + { + await sigilConfigDialog.WaitUntilUnloadedAsync(); + }); + sigilConfigDialog.Content = new SigilConfigView() { DataContext = dataContext }; + await _dialogCoordinator.ShowMetroDialogAsync(this, sigilConfigDialog); + await sigilConfigDialog.WaitUntilUnloadedAsync(); } private void CreateItemAffixesFilteredView() diff --git a/D4Companion/ViewModels/Dialogs/AffixConfigViewModel.cs b/D4Companion/ViewModels/Dialogs/AffixConfigViewModel.cs new file mode 100644 index 00000000..2b7c46e1 --- /dev/null +++ b/D4Companion/ViewModels/Dialogs/AffixConfigViewModel.cs @@ -0,0 +1,97 @@ +using D4Companion.Interfaces; +using D4Companion.Views.Dialogs; +using MahApps.Metro.Controls.Dialogs; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using System; + +namespace D4Companion.ViewModels.Dialogs +{ + public class AffixConfigViewModel : BindableBase + { + private readonly IEventAggregator _eventAggregator; + private readonly IDialogCoordinator _dialogCoordinator; + private readonly ISettingsManager _settingsManager; + + // Start of Constructors region + + #region Constructors + + public AffixConfigViewModel(Action closeHandler) + { + // Init IEventAggregator + _eventAggregator = (IEventAggregator)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(IEventAggregator)); + + // Init services + _dialogCoordinator = (IDialogCoordinator)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(IDialogCoordinator)); + _settingsManager = (ISettingsManager)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(ISettingsManager)); + + // Init View commands + AffixConfigDoneCommand = new DelegateCommand(AffixConfigDoneExecute); + CloseCommand = new DelegateCommand(closeHandler); + SetColorsCommand = new DelegateCommand(SetColorsExecute); + } + + #endregion + + // Start of Events region + + #region Events + + #endregion + + // Start of Properties region + + #region Properties + + public DelegateCommand CloseCommand { get; } + public DelegateCommand AffixConfigDoneCommand { get; } + public DelegateCommand SetColorsCommand { get; } + + public bool IsTemperedAffixDetectionEnabled + { + get => _settingsManager.Settings.IsTemperedAffixDetectionEnabled; + set + { + _settingsManager.Settings.IsTemperedAffixDetectionEnabled = value; + RaisePropertyChanged(nameof(IsTemperedAffixDetectionEnabled)); + + _settingsManager.SaveSettings(); + } + } + + #endregion + + // Start of Event handlers region + + #region Event handlers + + private void AffixConfigDoneExecute() + { + CloseCommand.Execute(this); + } + + private async void SetColorsExecute() + { + var colorsConfigDialog = new CustomDialog() { Title = "Default colors config" }; + var dataContext = new ColorsConfigViewModel(async instance => + { + await colorsConfigDialog.WaitUntilUnloadedAsync(); + }); + colorsConfigDialog.Content = new ColorsConfigView() { DataContext = dataContext }; + await _dialogCoordinator.ShowMetroDialogAsync(this, colorsConfigDialog); + await colorsConfigDialog.WaitUntilUnloadedAsync(); + + _settingsManager.SaveSettings(); + } + + #endregion + + // Start of Methods region + + #region Methods + + #endregion + } +} diff --git a/D4Companion/ViewModels/Dialogs/AspectConfigViewModel.cs b/D4Companion/ViewModels/Dialogs/AspectConfigViewModel.cs new file mode 100644 index 00000000..9f2574df --- /dev/null +++ b/D4Companion/ViewModels/Dialogs/AspectConfigViewModel.cs @@ -0,0 +1,97 @@ +using D4Companion.Interfaces; +using D4Companion.Views.Dialogs; +using MahApps.Metro.Controls.Dialogs; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using System; + +namespace D4Companion.ViewModels.Dialogs +{ + public class AspectConfigViewModel : BindableBase + { + private readonly IEventAggregator _eventAggregator; + private readonly IDialogCoordinator _dialogCoordinator; + private readonly ISettingsManager _settingsManager; + + // Start of Constructors region + + #region Constructors + + public AspectConfigViewModel(Action closeHandler) + { + // Init IEventAggregator + _eventAggregator = (IEventAggregator)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(IEventAggregator)); + + // Init services + _dialogCoordinator = (IDialogCoordinator)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(IDialogCoordinator)); + _settingsManager = (ISettingsManager)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(ISettingsManager)); + + // Init View commands + AspectConfigDoneCommand = new DelegateCommand(AspectConfigDoneExecute); + CloseCommand = new DelegateCommand(closeHandler); + SetColorsCommand = new DelegateCommand(SetColorsExecute); + } + + #endregion + + // Start of Events region + + #region Events + + #endregion + + // Start of Properties region + + #region Properties + + public DelegateCommand CloseCommand { get; } + public DelegateCommand AspectConfigDoneCommand { get; } + public DelegateCommand SetColorsCommand { get; } + + public bool IsAspectDetectionEnabled + { + get => _settingsManager.Settings.IsAspectDetectionEnabled; + set + { + _settingsManager.Settings.IsAspectDetectionEnabled = value; + RaisePropertyChanged(nameof(IsAspectDetectionEnabled)); + + _settingsManager.SaveSettings(); + } + } + + #endregion + + // Start of Event handlers region + + #region Event handlers + + private void AspectConfigDoneExecute() + { + CloseCommand.Execute(this); + } + + private async void SetColorsExecute() + { + var colorsConfigDialog = new CustomDialog() { Title = "Default colors config" }; + var dataContext = new ColorsConfigViewModel(async instance => + { + await colorsConfigDialog.WaitUntilUnloadedAsync(); + }); + colorsConfigDialog.Content = new ColorsConfigView() { DataContext = dataContext }; + await _dialogCoordinator.ShowMetroDialogAsync(this, colorsConfigDialog); + await colorsConfigDialog.WaitUntilUnloadedAsync(); + + _settingsManager.SaveSettings(); + } + + #endregion + + // Start of Methods region + + #region Methods + + #endregion + } +} diff --git a/D4Companion/ViewModels/Dialogs/SigilConfigViewModel.cs b/D4Companion/ViewModels/Dialogs/SigilConfigViewModel.cs new file mode 100644 index 00000000..a8ab4ef9 --- /dev/null +++ b/D4Companion/ViewModels/Dialogs/SigilConfigViewModel.cs @@ -0,0 +1,116 @@ +using D4Companion.Events; +using D4Companion.Interfaces; +using MahApps.Metro.Controls.Dialogs; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using System; +using System.Collections.ObjectModel; +using System.Windows; + +namespace D4Companion.ViewModels.Dialogs +{ + public class SigilConfigViewModel : BindableBase + { + private readonly IEventAggregator _eventAggregator; + private readonly IDialogCoordinator _dialogCoordinator; + private readonly ISettingsManager _settingsManager; + + private ObservableCollection _sigilDisplayModes = new ObservableCollection(); + + // Start of Constructors region + + #region Constructors + + public SigilConfigViewModel(Action closeHandler) + { + // Init IEventAggregator + _eventAggregator = (IEventAggregator)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(IEventAggregator)); + + // Init services + _dialogCoordinator = (IDialogCoordinator)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(IDialogCoordinator)); + _settingsManager = (ISettingsManager)Prism.Ioc.ContainerLocator.Container.Resolve(typeof(ISettingsManager)); + + // Init View commands + SigilConfigDoneCommand = new DelegateCommand(SigilConfigDoneExecute); + CloseCommand = new DelegateCommand(closeHandler); + + // Init modes + InitSigilDisplayModes(); + } + + #endregion + + // Start of Events region + + #region Events + + #endregion + + // Start of Properties region + + #region Properties + + public DelegateCommand CloseCommand { get; } + public DelegateCommand SigilConfigDoneCommand { get; } + + public ObservableCollection SigilDisplayModes { get => _sigilDisplayModes; set => _sigilDisplayModes = value; } + + public bool IsDungeonTiersEnabled + { + get => _settingsManager.Settings.DungeonTiers; + set + { + _settingsManager.Settings.DungeonTiers = value; + RaisePropertyChanged(nameof(IsDungeonTiersEnabled)); + _eventAggregator.GetEvent().Publish(); + + _settingsManager.SaveSettings(); + } + } + + public string SelectedSigilDisplayMode + { + get => _settingsManager.Settings.SelectedSigilDisplayMode; + set + { + if (!string.IsNullOrEmpty(value)) + { + _settingsManager.Settings.SelectedSigilDisplayMode = value; + RaisePropertyChanged(nameof(SelectedSigilDisplayMode)); + + _settingsManager.SaveSettings(); + } + } + } + + #endregion + + // Start of Event handlers region + + #region Event handlers + + private void SigilConfigDoneExecute() + { + CloseCommand.Execute(this); + } + + #endregion + + // Start of Methods region + + #region Methods + + private void InitSigilDisplayModes() + { + Application.Current?.Dispatcher?.Invoke(() => + { + // TODO: When localising this modify the AffixManager/OverlayHandler as well. + SigilDisplayModes.Add("Whitelisting"); + SigilDisplayModes.Add("Blacklisting"); + }); + } + + #endregion + } +} diff --git a/D4Companion/Views/Dialogs/AffixConfigView.xaml b/D4Companion/Views/Dialogs/AffixConfigView.xaml new file mode 100644 index 00000000..bfd02627 --- /dev/null +++ b/D4Companion/Views/Dialogs/AffixConfigView.xaml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + +