Skip to content

Commit

Permalink
v1.6.17 release
Browse files Browse the repository at this point in the history
• Added province filtering
• Added hex value tooltip on color in the prov table
• Removed shown provinces indication from color picker page
• Added to the prov table page an indication of the current number of provinces displayed
• Changed province table icon
  • Loading branch information
Alex4SSB committed Dec 13, 2022
1 parent 0fcb0cf commit 4cd45a9
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 23 deletions.
2 changes: 1 addition & 1 deletion EU4-PCP.Packaging/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity
Name="57163AlexSSB.EU4-PCP"
Publisher="CN=23CA18F3-0DFA-4F77-B8D7-9EF595185D27"
Version="1.6.16.0" />
Version="1.6.17.0" />

<Properties>
<DisplayName>EU4-PCP</DisplayName>
Expand Down
1 change: 0 additions & 1 deletion EU4-PCP/Models/PCP_Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public static class PCP_Data
public static string ModDupliProvinceCount;
public static string ModIllegalProvinceCount;
public static string ModMaxProvinces;
public static string ProvincesShown;
public static double ProvTableIndex = 0;
public static Color ColorPickerPickedColor;
public static TableProvince ChosenProv;
Expand Down
2 changes: 0 additions & 2 deletions EU4-PCP/Models/PCP_Implementations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,6 @@ public static bool AddProv(Province newProv)

if (Storage.RetrieveBool(General.UpdateMaxProv) && !WriteDefMap(ModMaxProvinces))
return false;

ProvincesShown = Provinces.Values.Count(prov => prov && prov.Show).ToString();
}

if (!WriteProvinces())
Expand Down
1 change: 0 additions & 1 deletion EU4-PCP/Models/PCP_Logic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ public static void UpdateProperties()
{
prov.Show = !prov.IsRNW() || (ShowRnw && !string.IsNullOrEmpty(prov.Name.ToString()));
}
ProvincesShown = Provinces.Values.Count(prov => prov && prov.Show).ToString();

DupliPrep();
}
Expand Down
2 changes: 1 addition & 1 deletion EU4-PCP/Properties/Resources.Designer.cs

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

2 changes: 1 addition & 1 deletion EU4-PCP/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<value>EU4 Province Color Picker</value>
</data>
<data name="AppVersion" xml:space="preserve">
<value>1.6.16</value>
<value>1.6.17</value>
</data>
<data name="AutoLoad" xml:space="preserve">
<value>Auto-Load</value>
Expand Down
10 changes: 0 additions & 10 deletions EU4-PCP/Views/ColorPickerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,6 @@
Text=""
ToolTip="{x:Static properties:Resources.ColorPickerIllegalDesc}" />
</Grid>
<Separator />
<StackPanel Orientation="Horizontal">
<TextBlock Margin="4" Text="Provinces in table:" />
<TextBlock
x:Name="ProvShownBlock"
Margin="4"
VerticalAlignment="Bottom"
FontFamily="Consolas"
Text="" />
</StackPanel>
<Separator Margin="0,10,0,0" />
<TextBlock
x:Name="BookmarkBlock"
Expand Down
3 changes: 0 additions & 3 deletions EU4-PCP/Views/ColorPickerPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ private void InitializeData()
IllegalProvCountGrid.Visibility = Visibility.Collapsed;
DupliCountGrid.Visibility = Visibility.Collapsed;

ProvShownBlock.Text = ProvincesShown;

NoBooks();
BookmarkComboBox.ItemsSource = BookmarkList;
BookmarkComboBox.SelectedIndex = SelectedBookmarkIndex;
Expand Down Expand Up @@ -167,7 +165,6 @@ private async void EnactChange(CriticalScope scope)
case CriticalScope.Mod:
ChosenProv = null;
ChangeMod();
ProvincesShown = Provinces.Values.Count(prov => prov && prov.Show).ToString();
UpdatePicker();
break;
case CriticalScope.Bookmark:
Expand Down
30 changes: 29 additions & 1 deletion EU4-PCP/Views/ProvTablePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
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:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:properties="clr-namespace:EU4_PCP.Properties"
d:DesignHeight="450"
d:DesignWidth="800"
DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
Style="{DynamicResource MahApps.Styles.Page}"
mc:Ignorable="d">
<Page.Resources>
Expand All @@ -18,14 +20,39 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="48" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock
x:Name="PageTitle"
Margin="{StaticResource MediumLeftMargin}"
HorizontalAlignment="Left"
Style="{StaticResource PageTitleStyle}"
Text="{x:Static properties:Resources.ProvTablePageTitle}" />
<Grid Grid.Row="1">
<Grid Grid.Row="1" Margin="8">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="80" />
<ColumnDefinition Width="6*" />
</Grid.ColumnDefinitions>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock Text="{Binding ElementName=ProvTable, Path=Items.Count}" />
<TextBlock Text=" Provinces" />
</StackPanel>
<TextBox
x:Name="ProvTableFilterBox"
Grid.Column="1"
MinWidth="100"
Margin="20,0"
Padding="4,6,4,4"
mah:TextBoxHelper.ClearTextButton="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Text.Length}"
mah:TextBoxHelper.Watermark="Filter"
Text="{Binding FilterText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
<Separator Grid.Row="1" VerticalAlignment="Bottom" />
<Grid Grid.Row="2">
<Grid
x:Name="MarkerGrid"
Width="12"
Expand Down Expand Up @@ -81,6 +108,7 @@
<Setter Property="Text" Value="{Binding IsColorLegal}" />
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
<Setter Property="ToolTip" Value="{Binding Color}" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
Expand Down
43 changes: 42 additions & 1 deletion EU4-PCP/Views/ProvTablePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using EU4_PCP.Contracts.Views;
using EU4_PCP.Models;
using EU4_PCP.Services;
using System;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using static EU4_PCP.PCP_Const;
using static EU4_PCP.PCP_Data;
Expand All @@ -18,10 +21,27 @@ namespace EU4_PCP.Views
{
public partial class ProvTablePage : Page, INotifyPropertyChanged, INavigationAware
{
private string filterText = "";
public string FilterText
{
get => filterText;
set => Set(ref filterText, value);
}

public ProvTablePage()
{
InitializeComponent();
DataContext = this;

PropertyChanged += ProvTablePage_PropertyChanged;
}

private void ProvTablePage_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(FilterText))
{
FilterProvs();
}
}

public void OnNavigatedTo(object parameter)
Expand All @@ -35,13 +55,34 @@ where prov && prov.Show
orderby prov.Index
select new TableProvince(prov);

ProvincesShown = ProvTable.Items.Count.ToString();
FilterProvs();

PaintMarkers();

ProvTable.SelectedIndex = SelectedGridRow;
}

private void FilterProvs()
{
var collectionView = CollectionViewSource.GetDefaultView(ProvTable.ItemsSource);

collectionView.Filter = new(NameFilter(FilterText.ToLower()));

ProvTableFilterBox.Background = ProvTable.Items.Count == 0 ? new SolidColorBrush(Colors.Crimson) : null;
}

private static Predicate<object> NameFilter(string filter) => p =>
{
if (p is not TableProvince prov)
return false;

return prov.province.Name.Definition?.ToLower().Contains(filter) is true
|| prov.province.Name.AltDefin?.ToLower().Contains(filter) is true
|| prov.province.Name.Localisation?.ToLower().Contains(filter) is true
|| prov.province.Name.Dynamic?.ToLower().Contains(filter) is true
|| prov.Index.ToString().Contains(filter);
};

public void OnNavigatedFrom()
{
}
Expand Down
2 changes: 1 addition & 1 deletion EU4-PCP/Views/ShellWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public HamburgerMenuItem SelectedOptionsMenuItem
// TODO WTS: Change the icons and titles for all HamburgerMenuItems here.
public ObservableCollection<HamburgerMenuItem> MenuItems { get; } = new ObservableCollection<HamburgerMenuItem>()
{
new HamburgerMenuGlyphItem() { Label = Properties.Resources.ShellProvTablePage, Glyph = "\uF0E2", TargetPageType = typeof(ProvTablePage) },
new HamburgerMenuGlyphItem() { Label = Properties.Resources.ShellProvTablePage, Glyph = "\uE82D", TargetPageType = typeof(ProvTablePage) },
new HamburgerMenuGlyphItem() { Label = Properties.Resources.ShellColorPickerPage, Glyph = "\uE790", TargetPageType = typeof(ColorPickerPage) },
};

Expand Down

0 comments on commit 4cd45a9

Please sign in to comment.