Skip to content

Commit

Permalink
Handle multiple skilltree
Browse files Browse the repository at this point in the history
  • Loading branch information
C1rdec committed Dec 8, 2023
1 parent 26dd2c8 commit 46789a9
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 30 deletions.
46 changes: 44 additions & 2 deletions src/Lurker.UI/ViewModels/BuildConfigurationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class BuildConfigurationViewModel : Caliburn.Micro.PropertyChangedBase
private Build _build;
private SimpleBuild _buildConfiguration;
private string _ascendency;
private bool _isSkillTreeOpen;

#endregion

Expand All @@ -38,6 +39,7 @@ public class BuildConfigurationViewModel : Caliburn.Micro.PropertyChangedBase
/// <param name="build">The build.</param>
public BuildConfigurationViewModel(SimpleBuild build)
{
this.SkillTreeInformation = new ObservableCollection<SkillTreeInformation>();
this._buildConfiguration = build;
this.Items = new ObservableCollection<UniqueItemViewModel>();
if (PathOfBuildingService.IsInitialize)
Expand All @@ -58,6 +60,16 @@ public BuildConfigurationViewModel(SimpleBuild build)

#region Properties

/// <summary>
/// Gets or sets skill trees.
/// </summary>
public ObservableCollection<SkillTreeInformation> SkillTreeInformation { get; set; }

/// <summary>
/// Gets or sets skill trees.
/// </summary>
public SkillTreeInformation SelectedSkillTreeInformation { get; set; }

/// <summary>
/// Gets the simple build.
/// </summary>
Expand All @@ -80,6 +92,23 @@ private set
}
}

/// <summary>
/// Gets or sets a value indicating whether the popup is open.
/// </summary>
public bool IsSkillTreeOpen
{
get
{
return this._isSkillTreeOpen;
}

set
{
this._isSkillTreeOpen = value;
this.NotifyOfPropertyChange();
}
}

/// <summary>
/// Gets or sets the gem view model.
/// </summary>
Expand Down Expand Up @@ -203,9 +232,17 @@ public string Notes
/// </summary>
public void OpenTree()
{
if (this._build != null && !string.IsNullOrEmpty(this._build.SkillTrees.FirstOrDefault().Url))
this.IsSkillTreeOpen = true;
}

/// <summary>
/// Opens the tree.
/// </summary>
public void OpenSelectedTree()
{
if (this.SelectedSkillTreeInformation != null && !string.IsNullOrEmpty(this.SelectedSkillTreeInformation.Url))
{
Process.Start(this._build.SkillTrees.FirstOrDefault().Url);
Process.Start(this.SelectedSkillTreeInformation.Url);
}
}

Expand Down Expand Up @@ -263,6 +300,11 @@ private void DecodeBuild(SimpleBuild simpleBuild)
{
this.Items.Add(new UniqueItemViewModel(item, false));
}

foreach (var tree in this._build.SkillTrees.Reverse<SkillTreeInformation>())
{
this.SkillTreeInformation.Add(tree);
}
});
}

Expand Down
57 changes: 51 additions & 6 deletions src/Lurker.UI/ViewModels/BuildViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class BuildViewModel : PoeOverlayBase
private SettingsViewModel _settings;
private GithubService _githubService;
private MouseLurker _mouseLurker;
private bool _isSkillTreeOpen;

#endregion

Expand Down Expand Up @@ -71,6 +72,7 @@ public BuildViewModel(IWindowManager windowManager, DockingHelper dockingHelper,

this.Skills = new ObservableCollection<SkillViewModel>();
this.UniqueItems = new ObservableCollection<UniqueItemViewModel>();
this.SkillTreeInformation = new ObservableCollection<SkillTreeInformation>();

this._mouseLurker = mouseLurker;

Expand Down Expand Up @@ -104,11 +106,38 @@ public BuildViewModel(IWindowManager windowManager, DockingHelper dockingHelper,

#region Properties

/// <summary>
/// Gets or sets skill trees.
/// </summary>
public ObservableCollection<SkillTreeInformation> SkillTreeInformation { get; set; }

/// <summary>
/// Gets or sets skill trees.
/// </summary>
public SkillTreeInformation SelectedSkillTreeInformation { get; set; }

/// <summary>
/// Gets or sets the build selector.
/// </summary>
public BuildSelectorViewModel BuildSelector { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the popup is open.
/// </summary>
public bool IsSkillTreeOpen
{
get
{
return this._isSkillTreeOpen;
}

set
{
this._isSkillTreeOpen = value;
this.NotifyOfPropertyChange();
}
}

/// <summary>
/// Gets or sets a value indicating whether this instance is open.
/// </summary>
Expand Down Expand Up @@ -362,14 +391,11 @@ public async void Import()
}

/// <summary>
/// Trees this instance.
/// Opens the tree.
/// </summary>
public void Tree()
public void OpenTree()
{
if (this.Build != null)
{
Process.Start(this.Build.SkillTrees.FirstOrDefault().Url);
}
this.IsSkillTreeOpen = true;
}

/// <summary>
Expand Down Expand Up @@ -403,6 +429,14 @@ public async Task<bool> 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<SkillTreeInformation>())
{
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)))
Expand Down Expand Up @@ -448,6 +482,17 @@ public async Task<bool> Initialize(string buildValue, bool findMainSkill)
return true;
}

/// <summary>
/// Opens the tree.
/// </summary>
public void OpenSelectedTree()
{
if (this.SelectedSkillTreeInformation != null && !string.IsNullOrEmpty(this.SelectedSkillTreeInformation.Url))
{
Process.Start(this.SelectedSkillTreeInformation.Url);
}
}

/// <summary>
/// Clears the build.
/// </summary>
Expand Down
67 changes: 47 additions & 20 deletions src/Lurker.UI/Views/BuildConfigurationView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Grid Margin="10,0,10,0">
Expand Down Expand Up @@ -79,24 +80,50 @@
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
<Button Width="50"
Grid.Row="2"
x:Name="OpenTree"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Cursor="Hand"
ToolTip="Passive Tree"
Height="50" Style="{DynamicResource MahApps.Styles.Button.Circle}">
<Button.Content>
<local:IconPack HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Foreground="#af8404"
Grid.Row="2"
Height="20"
Width="20"
Data="{x:Static local:IconPackData.ThreeDot}"/>
</Button.Content>
</Button>
<ContentControl x:Name="GemViewModel" HorizontalAlignment="Right" Margin="0,-60,10,0" VerticalAlignment="Top"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,-60,10,0" VerticalAlignment="Top">
<ContentControl x:Name="GemViewModel" Margin="0,0,10,0"/>
<Button Width="50"
Grid.Row="2"
x:Name="OpenTree"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Cursor="Hand"
ToolTip="Passive Tree"
Height="50" Style="{DynamicResource MahApps.Styles.Button.Circle}">
<Button.Content>
<local:IconPack HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Foreground="#af8404"
Grid.Row="2"
Height="20"
Width="20"
Data="{x:Static local:IconPackData.ThreeDot}"/>
</Button.Content>
</Button>
</StackPanel>

<Popup IsOpen="{Binding IsSkillTreeOpen}"
Placement="Mouse"
StaysOpen="False">
<Border>
<ListView
Cursor="Hand"
ItemsSource="{Binding SkillTreeInformation}"
cal:Message.Attach="[Event MouseUp] = [Action OpenSelectedTree()]"
SelectedItem="{Binding SelectedSkillTreeInformation}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid x:Name="Main" Background="Transparent">
<TextBlock Margin="15,5,30,5"
VerticalAlignment="Center"
Background="Transparent"
FontSize="28"
Text="{Binding DisplayName}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Popup>
</Grid>
</UserControl>
24 changes: 23 additions & 1 deletion src/Lurker.UI/Views/BuildView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
</Controls:DropDownButton.Content>
</Controls:DropDownButton>
<Button Width="30"
x:Name="Tree"
x:Name="OpenTree"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Cursor="Hand"
Expand Down Expand Up @@ -245,6 +245,28 @@
<Button Style="{DynamicResource Tag}" x:Name="NewBuild" Margin="0,10,0,10" Cursor="Hand" VerticalAlignment="Bottom">New Build</Button>
</Grid>
</Controls:Flyout>
<Popup IsOpen="{Binding IsSkillTreeOpen}"
Placement="Mouse"
StaysOpen="False">
<Border>
<ListView Cursor="Hand"
ItemsSource="{Binding SkillTreeInformation}"
cal:Message.Attach="[Event MouseUp] = [Action OpenSelectedTree()]"
SelectedItem="{Binding SelectedSkillTreeInformation}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid x:Name="Main" Background="Transparent">
<TextBlock Margin="15,5,30,5"
VerticalAlignment="Center"
Background="Transparent"
FontSize="28"
Text="{Binding DisplayName}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Popup>
</Grid>
</Controls:Flyout>
</Window>
2 changes: 1 addition & 1 deletion src/Lurker.UI/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</Grid.RowDefinitions>

<StackPanel Margin="30,0,0,0" Grid.Row="2" HorizontalAlignment="Center" Orientation="Horizontal" VerticalAlignment="Center">
<Controls:ToggleSwitch Header="Build Helper"
<Controls:ToggleSwitch Header="Build Overlay"
Margin="20,0,0,0"
IsOn="{Binding BuildHelper}"/>
<Grid Margin="10,0,0,0" Visibility="{Binding BuildHelper, Converter={StaticResource BooleanToVisibilityConverter}}">
Expand Down
6 changes: 6 additions & 0 deletions src/Lurker/Models/SkillTreeInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ public class SkillTreeInformation
/// Gets or Sets the title.
/// </summary>
public string Title { get; set; }

/// <summary>
/// Gets the display name.
/// </summary>
/// <returns>The display name.</returns>
public string DisplayName => string.IsNullOrEmpty(this.Title) ? this.Version : this.Title;
}
}

0 comments on commit 46789a9

Please sign in to comment.