Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Massively overhauled the Engravings UI so that it's testing-ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirdoombox committed Mar 19, 2022
1 parent dfb122b commit 1385c45
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 136 deletions.
1 change: 1 addition & 0 deletions App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/themes/dark.lime.xaml" />
<ResourceDictionary Source="pack://application:,,,/Controls/Controls.xaml"/>
<ResourceDictionary>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibility" />
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibility" />
Expand Down
8 changes: 8 additions & 0 deletions Controls/Controls.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:LostArkTools.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Controls/HighlightableBorderedText.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource HighlightableBorderedText}" TargetType="{x:Type controls:HighlightableBorderedText}"/>
</ResourceDictionary>
47 changes: 47 additions & 0 deletions Controls/HighlightableBorderedText.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace LostArkTools.Controls;

[TemplatePart(Name = "PART_Border", Type = typeof(Border))]
[TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))]
public class HighlightableBorderedText : Control
{
public static readonly DependencyProperty IsHighlightedProperty = DependencyProperty.Register(
"IsHighlighted", typeof(bool), typeof(HighlightableBorderedText), new PropertyMetadata(default(bool)));
public bool IsHighlighted
{
get => (bool)GetValue(IsHighlightedProperty);
set => SetValue(IsHighlightedProperty, value);
}

public static readonly DependencyProperty HighlightBrushProperty = DependencyProperty.Register(
"HighlightBrush", typeof(Brush), typeof(HighlightableBorderedText), new PropertyMetadata(default(Brush)));
public Brush HighlightBrush
{
get => (Brush)GetValue(HighlightBrushProperty);
set => SetValue(HighlightBrushProperty, value);
}

public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
"Text", typeof(string), typeof(HighlightableBorderedText), new PropertyMetadata(default(string)));
public string Text
{
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}

public static readonly DependencyProperty TextAlignmentProperty = DependencyProperty.Register(
"TextAlignment", typeof(TextAlignment), typeof(HighlightableBorderedText), new PropertyMetadata(default(TextAlignment)));
public TextAlignment TextAlignment
{
get => (TextAlignment)GetValue(TextAlignmentProperty);
set => SetValue(TextAlignmentProperty, value);
}

static HighlightableBorderedText()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(HighlightableBorderedText), new FrameworkPropertyMetadata(typeof(HighlightableBorderedText)));
}
}
29 changes: 29 additions & 0 deletions Controls/HighlightableBorderedText.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:LostArkTools.Controls">
<Style x:Key="HighlightableBorderedText" TargetType="{x:Type controls:HighlightableBorderedText}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:HighlightableBorderedText}">
<Border x:Name="PART_Border"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<TextBlock x:Name="PART_TextBlock"
FontSize="{TemplateBinding FontSize}"
Text="{TemplateBinding Text}"
TextAlignment="{TemplateBinding TextAlignment}"
Foreground="{TemplateBinding Foreground}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="PART_TextBlock" Property="FontWeight" Value="Bold" />
<Setter TargetName="PART_Border" Property="Background"
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HighlightBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
23 changes: 0 additions & 23 deletions Controls/HighlightableTextBlock.xaml

This file was deleted.

38 changes: 0 additions & 38 deletions Controls/HighlightableTextBlock.xaml.cs

This file was deleted.

79 changes: 33 additions & 46 deletions Features/Engravings/BuildView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,51 @@
BorderThickness="2"
Margin="10">
<Grid>
<Grid.Resources>
<Style TargetType="controls:HighlightableBorderedText" BasedOn="{StaticResource HighlightableBorderedText}">
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.Gray9}"/>
<Setter Property="HighlightBrush" Value="{DynamicResource MahApps.Brushes.Accent}"/>
<Setter Property="TextAlignment" Value="Center"/>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding BuildName}"
TextWrapping="Wrap"
FontSize="16"
FontWeight="Bold"
TextAlignment="Center"
Margin="10 0 10 0"
VerticalAlignment="Center" />
<Border Grid.Row="0"
Background="{DynamicResource MahApps.Brushes.Gray.SemiTransparent}">
<TextBlock Text="{Binding BuildName}"
TextWrapping="Wrap"
FontSize="16"
FontWeight="Bold"
TextAlignment="Center"
Margin="10 0 10 0"
VerticalAlignment="Center" />
</Border>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<controls:HighlightableTextBlock Grid.Column="0"
Text="{Binding Primary.Value}"
IsHighlighted="{Binding Primary.IsHighlight}"
HighlightBrush="{DynamicResource MahApps.Brushes.Accent}"
TextAlignment="Center"
FontWeight="Bold"/>
<controls:HighlightableTextBlock Grid.Column="1"
Text="{Binding Secondary.Value}"
IsHighlighted="{Binding Secondary.IsHighlight}"
HighlightBrush="{DynamicResource MahApps.Brushes.Accent}"
TextAlignment="Center"/>
<controls:HighlightableBorderedText Grid.Column="0"
BorderThickness="0 2 1 2"
Text="{Binding Primary.Value}"
FontSize="13"
IsHighlighted="{Binding Primary.IsHighlight}" />
<controls:HighlightableBorderedText Grid.Column="1"
BorderThickness="1 2 0 2"
Text="{Binding Secondary.Value}"
FontSize="13"
IsHighlighted="{Binding Secondary.IsHighlight}" />
</Grid>
<Separator Grid.Row="2"
Background="{DynamicResource MahApps.Brushes.Gray2}" />
<ItemsControl Grid.Row="3"
<ItemsControl Grid.Row="2"
ItemsSource="{Binding Engravings}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}"
x:Name="EngravingText"/>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsHighlight}"
Value="True">
<Setter TargetName="EngravingText"
Property="Foreground"
Value="{DynamicResource MahApps.Brushes.Accent}"/>
<Setter TargetName="EngravingText"
Property="FontWeight"
Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsHighlight}"
Value="False">
<Setter TargetName="EngravingText"
Property="Foreground"
Value="{DynamicResource MahApps.Brushes.Text}"/>
<Setter TargetName="EngravingText"
Property="FontWeight"
Value="Normal"/>
</DataTrigger>
</DataTemplate.Triggers>
<controls:HighlightableBorderedText BorderThickness="0 0 0 1"
Text="{Binding Value}"
IsHighlighted="{Binding IsHighlight}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
Expand Down
66 changes: 45 additions & 21 deletions Features/Engravings/EngravingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,77 @@
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:EngravingsViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
<Grid.Resources>
<Thickness x:Key="ControlMargin">0 10 0 0</Thickness>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<ComboBox mah:TextBoxHelper.UseFloatingWatermark="True"
mah:TextBoxHelper.Watermark="First Engraving"
IsEditable="True"
<StackPanel Grid.Column="0"
Margin="10"
VerticalAlignment="Center">
<StackPanel.Resources>
<Style TargetType="ComboBox" BasedOn="{StaticResource MahApps.Styles.ComboBox.Virtualized}">
<Setter Property="mah:TextBoxHelper.UseFloatingWatermark" Value="True" />
<Setter Property="Margin" Value="{StaticResource ControlMargin}" />
<Setter Property="MaxDropDownHeight" Value="200" />
<Setter Property="IsEditable" Value="True" />
</Style>
</StackPanel.Resources>
<TextBlock TextWrapping="Wrap"
TextAlignment="Center"
Foreground="{DynamicResource MahApps.Brushes.SemiTransparent}"
FontWeight="Bold">
Builds are sourced from MaxRoll.gg and are currently hardcoded. <LineBreak/>
Any changes to builds based on feedback or updates to MaxRoll guides will require an update.<LineBreak/>
<LineBreak/>
Engravings are listed in order of importance.
</TextBlock>
<Separator Margin="25 25 25 0"/>
<mah:ToggleSwitch IsOn="{Binding FilteringEnabled}"
OnContent="Filtering Enabled"
OffContent="Showing All Builds"
Margin="{StaticResource ControlMargin}" />
<ComboBox mah:TextBoxHelper.Watermark="First Engraving"
ItemsSource="{Binding Engravings}"
MaxDropDownHeight="125"
Style="{DynamicResource MahApps.Styles.ComboBox.Virtualized}"
SelectedItem="{Binding SelectedEngravingOne}"/>
<ComboBox mah:TextBoxHelper.UseFloatingWatermark="True"
mah:TextBoxHelper.Watermark="Second Engraving"
IsEditable="True"
SelectedItem="{Binding SelectedEngravingOne}" />
<ComboBox mah:TextBoxHelper.Watermark="Second Engraving"
ItemsSource="{Binding Engravings}"
MaxDropDownHeight="125"
Style="{DynamicResource MahApps.Styles.ComboBox.Virtualized}"
SelectedItem="{Binding SelectedEngravingTwo}"/>
SelectedItem="{Binding SelectedEngravingTwo}" />
<mah:ToggleSwitch IsOn="{Binding IncludeStat}"
OnContent="Stat Included"
OffContent="Stat Excluded"/>
<ComboBox mah:TextBoxHelper.UseFloatingWatermark="True"
mah:TextBoxHelper.Watermark="Stat"
OffContent="Stat Excluded"
Margin="{StaticResource ControlMargin}" />
<ComboBox mah:TextBoxHelper.Watermark="Stat"
IsEditable="False"
IsEnabled="{Binding IncludeStat}"
ItemsSource="{Binding Stats}"
SelectedItem="{Binding SelectedStat}"/>
SelectedItem="{Binding SelectedStat}" />
</StackPanel>
<ItemsControl Grid.Column="1"
<Separator Grid.Column="1"
Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"
Background="{DynamicResource MahApps.Brushes.Gray7}" />
<ItemsControl Grid.Column="2"
Margin="10"
ItemsSource="{Binding Builds}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl s:View.Model="{Binding}"/>
<ContentControl s:View.Model="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<controls:AlignableWrapPanel HorizontalContentAlignment="Center"/>
<controls:AlignableWrapPanel HorizontalContentAlignment="Center" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}">
<ScrollViewer CanContentScroll="False"
<ScrollViewer CanContentScroll="False"
Padding="{TemplateBinding Padding}"
Focusable="False">
<ItemsPresenter />
Expand Down
11 changes: 10 additions & 1 deletion Features/Engravings/EngravingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public class EngravingsViewModel : FeatureScreenBase
public BindableCollection<string> Stats { get; } = new();
public BindableCollection<BuildViewModel> Builds { get; } = new();

private bool _filteringEnabled;
public bool FilteringEnabled
{
get => _filteringEnabled;
set => SetAndNotify(ref _filteringEnabled, value);
}

private string _selectedEngravingOne;
public string SelectedEngravingOne
{
Expand Down Expand Up @@ -41,7 +48,7 @@ public string SelectedStat
get => _selectedStat;
set => SetAndNotify(ref _selectedStat, value);
}

private readonly ICollectionView _buildsView;

public EngravingsViewModel(ResourceService resources) : base("Engravings", PackIconBoxIconsKind.SolidSearch, 4)
Expand Down Expand Up @@ -74,6 +81,8 @@ private bool FilterBuilds(object obj)
foreach (var value in build.Engravings)
value.IsHighlight = false;
build.Primary.IsHighlight = build.Secondary.IsHighlight = false;

if (!FilteringEnabled) return true;

if (IncludeStat && !ProcessStat(build)) return false;

Expand Down
Loading

0 comments on commit 1385c45

Please sign in to comment.