-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new affix, aspect, and sigil settings window.
- Loading branch information
1 parent
b8d422d
commit 32ea07c
Showing
10 changed files
with
569 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.