Skip to content

Commit

Permalink
Add "Search Passive Skills" window
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercamp committed Feb 2, 2025
1 parent 93473fb commit 07d348d
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 1 deletion.
16 changes: 16 additions & 0 deletions PalCalc.UI/Localization/LocalizationCodes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions PalCalc.UI/Localization/LocalizationCodes.resx
Original file line number Diff line number Diff line change
Expand Up @@ -748,4 +748,16 @@
<data name="LC_TRAIT_LABEL_UNRECOGNIZED" xml:space="preserve">
<value>InternalName</value>
</data>
<data name="LC_TRAITS_SEARCH_DESCRIPTION" xml:space="preserve">
<value />
</data>
<data name="LC_TRAITS_SEARCH_NAME" xml:space="preserve">
<value />
</data>
<data name="LC_TRAITS_SEARCH_SEARCH" xml:space="preserve">
<value />
</data>
<data name="LC_TRAITS_SEARCH_TITLE" xml:space="preserve">
<value />
</data>
</root>
12 changes: 12 additions & 0 deletions PalCalc.UI/Localization/Localizations/en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,18 @@ Higher values linearly affect time required, depending on how many types of pals
<data name="LC_TRAITS_PRESETS_RENAME_TITLE" xml:space="preserve">
<value>Rename Preset '{PresetName}'</value>
</data>
<data name="LC_TRAITS_SEARCH_DESCRIPTION" xml:space="preserve">
<value>Description</value>
</data>
<data name="LC_TRAITS_SEARCH_NAME" xml:space="preserve">
<value>Name</value>
</data>
<data name="LC_TRAITS_SEARCH_SEARCH" xml:space="preserve">
<value>Search</value>
</data>
<data name="LC_TRAITS_SEARCH_TITLE" xml:space="preserve">
<value>Search Passive Skills</value>
</data>
<data name="LC_TRAIT_LABEL_UNRECOGNIZED" xml:space="preserve">
<value>{InternalName} (Unrecognized)</value>
</data>
Expand Down
11 changes: 10 additions & 1 deletion PalCalc.UI/View/Main/PalTargetView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:dnkc="clr-namespace:DotNetKit.Windows.Controls;assembly=DotNetKit.Wpf.AutoCompleteComboBox"
xmlns:itl="clr-namespace:PalCalc.UI.Localization"
xmlns:vu="clr-namespace:PalCalc.UI.View.Utils"
xmlns:materialIcons="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
d:Background="White"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:PalTargetViewModel, IsDesignTimeCreatable=True}"
Expand All @@ -34,7 +35,15 @@
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<GroupBox Header="{itl:LocalizedText LC_COMMON_TRAITS}">
<GroupBox>
<GroupBox.Header>
<StackPanel Orientation="Horizontal" Margin="0,0,0,3">
<TextBlock Text="{itl:LocalizedText LC_COMMON_TRAITS}" />
<Button Margin="10,0,0,0" Padding="0" Height="16" Command="{Binding OpenPassivesSearchCommand}">
<materialIcons:MaterialIcon Kind="Search" />
</Button>
</StackPanel>
</GroupBox.Header>
<Grid>
<TabControl>
<TabItem Header="{itl:LocalizedText LC_PAL_TARGET_REQUIRED_TRAITS}">
Expand Down
69 changes: 69 additions & 0 deletions PalCalc.UI/View/PassivesSearchWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<Window x:Class="PalCalc.UI.View.PassivesSearchWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PalCalc.UI.View"
xmlns:util="clr-namespace:Wpf.Util"
xmlns:mvm="clr-namespace:PalCalc.UI.ViewModel.Mapped"
xmlns:itl="clr-namespace:PalCalc.UI.Localization"
mc:Ignorable="d"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="{itl:LocalizedText Code=LC_TRAITS_SEARCH_TITLE}"
Height="450" Width="800">
<Window.Resources>
<mvm:RankColorConverter x:Key="RCC" />
</Window.Resources>
<DockPanel>
<DockPanel DockPanel.Dock="Top" Margin="10,10">
<TextBlock DockPanel.Dock="Left" Text="{itl:LocalizedText Code=LC_TRAITS_SEARCH_SEARCH}" Margin="0,2,8,0" />

<TextBox Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" />
</DockPanel>

<ListView ItemsSource="{Binding DisplayedOptions}" util:GridViewSort.AutoSort="True">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="{itl:LocalizedText Code=LC_TRAITS_SEARCH_NAME}" util:GridViewSort.PropertyName="Name" Width="Auto">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="{x:Type mvm:PassiveSkillViewModel}">
<StackPanel Orientation="Horizontal">
<Border Background="Black"
CornerRadius="99"
Padding="2"
BorderThickness="0"
Margin="0,0,8,0"
VerticalAlignment="Center"
>
<Rectangle Width="15"
Height="15"
Fill="{Binding Rank, Converter={StaticResource RCC}}">
<Rectangle.OpacityMask>
<ImageBrush ImageSource="{Binding RankIcon}" />
</Rectangle.OpacityMask>
</Rectangle>
</Border>

<TextBlock Text="{Binding Name.Value}" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

<GridViewColumn Header="{itl:LocalizedText Code=LC_TRAITS_SEARCH_DESCRIPTION}"
Width="500"
util:GridViewSort.PropertyName="Description"
>
<GridViewColumn.CellTemplate>
<DataTemplate DataType="{x:Type mvm:PassiveSkillViewModel}">
<TextBlock Text="{Binding Description.Value}" TextWrapping="Wrap" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</Window>
38 changes: 38 additions & 0 deletions PalCalc.UI/View/PassivesSearchWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using CommunityToolkit.Mvvm.ComponentModel;
using PalCalc.UI.ViewModel.Mapped;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PalCalc.UI.View
{
[ObservableObject]
public partial class PassivesSearchWindow : Window
{
[NotifyPropertyChangedFor(nameof(DisplayedOptions))]
[ObservableProperty]
private string searchText;

public List<PassiveSkillViewModel> DisplayedOptions =>
PassiveSkillViewModel.All.Where(p =>
string.IsNullOrEmpty(SearchText) ||
p.Name.Value.Contains(SearchText, StringComparison.OrdinalIgnoreCase) ||
p.Description.Value.Contains(SearchText, StringComparison.OrdinalIgnoreCase)
).ToList();

public PassivesSearchWindow()
{
InitializeComponent();
}
}
}
5 changes: 5 additions & 0 deletions PalCalc.UI/ViewModel/PalTargetViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CommunityToolkit.Mvvm.Input;
using PalCalc.Model;
using PalCalc.UI.Model;
using PalCalc.UI.View;
using PalCalc.UI.ViewModel.Mapped;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -65,6 +66,8 @@ public PalTargetViewModel(SaveGameViewModel sourceSave, PalSpecifierViewModel in
OpenPresetsMenuCommand = new RelayCommand(() => PresetsMenuIsOpen = true);

presets.PresetSelected += (_) => PresetsMenuIsOpen = false;

OpenPassivesSearchCommand = new RelayCommand(() => new PassivesSearchWindow().Show());
}

private void PalSource_PropertyChanged(object sender, PropertyChangedEventArgs e)
Expand Down Expand Up @@ -157,5 +160,7 @@ public IEnumerable<PalInstance> AvailablePals
private bool presetsMenuIsOpen = false;

public IRelayCommand OpenPresetsMenuCommand { get; }

public IRelayCommand OpenPassivesSearchCommand { get; }
}
}

0 comments on commit 07d348d

Please sign in to comment.