From 46789a96a515c1ebaf10d9958c7755b673b8c93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Lampron?= Date: Fri, 8 Dec 2023 11:30:55 -0500 Subject: [PATCH] Handle multiple skilltree --- .../ViewModels/BuildConfigurationViewModel.cs | 46 ++++++++++++- src/Lurker.UI/ViewModels/BuildViewModel.cs | 57 ++++++++++++++-- .../Views/BuildConfigurationView.xaml | 67 +++++++++++++------ src/Lurker.UI/Views/BuildView.xaml | 24 ++++++- src/Lurker.UI/Views/SettingsView.xaml | 2 +- src/Lurker/Models/SkillTreeInformation.cs | 6 ++ 6 files changed, 172 insertions(+), 30 deletions(-) diff --git a/src/Lurker.UI/ViewModels/BuildConfigurationViewModel.cs b/src/Lurker.UI/ViewModels/BuildConfigurationViewModel.cs index fe4ea6b6..0883d133 100644 --- a/src/Lurker.UI/ViewModels/BuildConfigurationViewModel.cs +++ b/src/Lurker.UI/ViewModels/BuildConfigurationViewModel.cs @@ -27,6 +27,7 @@ public class BuildConfigurationViewModel : Caliburn.Micro.PropertyChangedBase private Build _build; private SimpleBuild _buildConfiguration; private string _ascendency; + private bool _isSkillTreeOpen; #endregion @@ -38,6 +39,7 @@ public class BuildConfigurationViewModel : Caliburn.Micro.PropertyChangedBase /// The build. public BuildConfigurationViewModel(SimpleBuild build) { + this.SkillTreeInformation = new ObservableCollection(); this._buildConfiguration = build; this.Items = new ObservableCollection(); if (PathOfBuildingService.IsInitialize) @@ -58,6 +60,16 @@ public BuildConfigurationViewModel(SimpleBuild build) #region Properties + /// + /// Gets or sets skill trees. + /// + public ObservableCollection SkillTreeInformation { get; set; } + + /// + /// Gets or sets skill trees. + /// + public SkillTreeInformation SelectedSkillTreeInformation { get; set; } + /// /// Gets the simple build. /// @@ -80,6 +92,23 @@ private set } } + /// + /// Gets or sets a value indicating whether the popup is open. + /// + public bool IsSkillTreeOpen + { + get + { + return this._isSkillTreeOpen; + } + + set + { + this._isSkillTreeOpen = value; + this.NotifyOfPropertyChange(); + } + } + /// /// Gets or sets the gem view model. /// @@ -203,9 +232,17 @@ public string Notes /// public void OpenTree() { - if (this._build != null && !string.IsNullOrEmpty(this._build.SkillTrees.FirstOrDefault().Url)) + this.IsSkillTreeOpen = true; + } + + /// + /// Opens the tree. + /// + public void OpenSelectedTree() + { + if (this.SelectedSkillTreeInformation != null && !string.IsNullOrEmpty(this.SelectedSkillTreeInformation.Url)) { - Process.Start(this._build.SkillTrees.FirstOrDefault().Url); + Process.Start(this.SelectedSkillTreeInformation.Url); } } @@ -263,6 +300,11 @@ private void DecodeBuild(SimpleBuild simpleBuild) { this.Items.Add(new UniqueItemViewModel(item, false)); } + + foreach (var tree in this._build.SkillTrees.Reverse()) + { + this.SkillTreeInformation.Add(tree); + } }); } diff --git a/src/Lurker.UI/ViewModels/BuildViewModel.cs b/src/Lurker.UI/ViewModels/BuildViewModel.cs index 2f6b6fe8..ed5685f4 100644 --- a/src/Lurker.UI/ViewModels/BuildViewModel.cs +++ b/src/Lurker.UI/ViewModels/BuildViewModel.cs @@ -41,6 +41,7 @@ public class BuildViewModel : PoeOverlayBase private SettingsViewModel _settings; private GithubService _githubService; private MouseLurker _mouseLurker; + private bool _isSkillTreeOpen; #endregion @@ -71,6 +72,7 @@ public BuildViewModel(IWindowManager windowManager, DockingHelper dockingHelper, this.Skills = new ObservableCollection(); this.UniqueItems = new ObservableCollection(); + this.SkillTreeInformation = new ObservableCollection(); this._mouseLurker = mouseLurker; @@ -104,11 +106,38 @@ public BuildViewModel(IWindowManager windowManager, DockingHelper dockingHelper, #region Properties + /// + /// Gets or sets skill trees. + /// + public ObservableCollection SkillTreeInformation { get; set; } + + /// + /// Gets or sets skill trees. + /// + public SkillTreeInformation SelectedSkillTreeInformation { get; set; } + /// /// Gets or sets the build selector. /// public BuildSelectorViewModel BuildSelector { get; set; } + /// + /// Gets or sets a value indicating whether the popup is open. + /// + public bool IsSkillTreeOpen + { + get + { + return this._isSkillTreeOpen; + } + + set + { + this._isSkillTreeOpen = value; + this.NotifyOfPropertyChange(); + } + } + /// /// Gets or sets a value indicating whether this instance is open. /// @@ -362,14 +391,11 @@ public async void Import() } /// - /// Trees this instance. + /// Opens the tree. /// - public void Tree() + public void OpenTree() { - if (this.Build != null) - { - Process.Start(this.Build.SkillTrees.FirstOrDefault().Url); - } + this.IsSkillTreeOpen = true; } /// @@ -403,6 +429,14 @@ public async Task Initialize(string buildValue, bool findMainSkill) { await service.InitializeAsync(this._githubService); this.Build = service.Decode(buildValue); + + this.SkillTreeInformation.Clear(); + + foreach (var tree in this.Build.SkillTrees.Reverse()) + { + this.SkillTreeInformation.Add(tree); + } + this.Ascendancy = this.Build.Ascendancy; this.Skills.Clear(); foreach (var skill in this.Build.Skills.Select(s => new SkillViewModel(s, this.SettingsService.TimelineEnabled))) @@ -448,6 +482,17 @@ public async Task Initialize(string buildValue, bool findMainSkill) return true; } + /// + /// Opens the tree. + /// + public void OpenSelectedTree() + { + if (this.SelectedSkillTreeInformation != null && !string.IsNullOrEmpty(this.SelectedSkillTreeInformation.Url)) + { + Process.Start(this.SelectedSkillTreeInformation.Url); + } + } + /// /// Clears the build. /// diff --git a/src/Lurker.UI/Views/BuildConfigurationView.xaml b/src/Lurker.UI/Views/BuildConfigurationView.xaml index 2940c10f..23e4ca4f 100644 --- a/src/Lurker.UI/Views/BuildConfigurationView.xaml +++ b/src/Lurker.UI/Views/BuildConfigurationView.xaml @@ -3,8 +3,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" + xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" mc:Ignorable="d" + xmlns:cal="http://www.caliburnproject.org" xmlns:local="clr-namespace:Lurker.UI" d:DesignHeight="450" d:DesignWidth="800"> @@ -79,24 +80,50 @@ - - + + + + + + + + + + + + + + + + + + diff --git a/src/Lurker.UI/Views/BuildView.xaml b/src/Lurker.UI/Views/BuildView.xaml index 9194bc71..a56b7795 100644 --- a/src/Lurker.UI/Views/BuildView.xaml +++ b/src/Lurker.UI/Views/BuildView.xaml @@ -159,7 +159,7 @@ + + + + + + + + + + + + + diff --git a/src/Lurker.UI/Views/SettingsView.xaml b/src/Lurker.UI/Views/SettingsView.xaml index 6fccb85e..7204a31f 100644 --- a/src/Lurker.UI/Views/SettingsView.xaml +++ b/src/Lurker.UI/Views/SettingsView.xaml @@ -50,7 +50,7 @@ - diff --git a/src/Lurker/Models/SkillTreeInformation.cs b/src/Lurker/Models/SkillTreeInformation.cs index 063f63d0..f507ec2f 100644 --- a/src/Lurker/Models/SkillTreeInformation.cs +++ b/src/Lurker/Models/SkillTreeInformation.cs @@ -23,5 +23,11 @@ public class SkillTreeInformation /// Gets or Sets the title. /// public string Title { get; set; } + + /// + /// Gets the display name. + /// + /// The display name. + public string DisplayName => string.IsNullOrEmpty(this.Title) ? this.Version : this.Title; } } \ No newline at end of file