Skip to content

Commit

Permalink
Added new affix, aspect, and sigil settings window.
Browse files Browse the repository at this point in the history
  • Loading branch information
josdemmers committed Aug 10, 2024
1 parent b8d422d commit 32ea07c
Show file tree
Hide file tree
Showing 10 changed files with 569 additions and 27 deletions.
51 changes: 24 additions & 27 deletions D4Companion/ViewModels/AffixViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
97 changes: 97 additions & 0 deletions D4Companion/ViewModels/Dialogs/AffixConfigViewModel.cs
Original file line number Diff line number Diff line change
@@ -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<AffixConfigViewModel> 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<AffixConfigViewModel>(closeHandler);
SetColorsCommand = new DelegateCommand(SetColorsExecute);
}

#endregion

// Start of Events region

#region Events

#endregion

// Start of Properties region

#region Properties

public DelegateCommand<AffixConfigViewModel> 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
}
}
97 changes: 97 additions & 0 deletions D4Companion/ViewModels/Dialogs/AspectConfigViewModel.cs
Original file line number Diff line number Diff line change
@@ -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<AspectConfigViewModel> 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<AspectConfigViewModel>(closeHandler);
SetColorsCommand = new DelegateCommand(SetColorsExecute);
}

#endregion

// Start of Events region

#region Events

#endregion

// Start of Properties region

#region Properties

public DelegateCommand<AspectConfigViewModel> 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
}
}
116 changes: 116 additions & 0 deletions D4Companion/ViewModels/Dialogs/SigilConfigViewModel.cs
Original file line number Diff line number Diff line change
@@ -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<string> _sigilDisplayModes = new ObservableCollection<string>();

// Start of Constructors region

#region Constructors

public SigilConfigViewModel(Action<SigilConfigViewModel> 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<SigilConfigViewModel>(closeHandler);

// Init modes
InitSigilDisplayModes();
}

#endregion

// Start of Events region

#region Events

#endregion

// Start of Properties region

#region Properties

public DelegateCommand<SigilConfigViewModel> CloseCommand { get; }
public DelegateCommand SigilConfigDoneCommand { get; }

public ObservableCollection<string> SigilDisplayModes { get => _sigilDisplayModes; set => _sigilDisplayModes = value; }

public bool IsDungeonTiersEnabled
{
get => _settingsManager.Settings.DungeonTiers;
set
{
_settingsManager.Settings.DungeonTiers = value;
RaisePropertyChanged(nameof(IsDungeonTiersEnabled));
_eventAggregator.GetEvent<SelectedSigilDungeonTierChangedEvent>().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
}
}
Loading

0 comments on commit 32ea07c

Please sign in to comment.