Skip to content

Commit

Permalink
Change style of body part list, add a filter for the unit and race li…
Browse files Browse the repository at this point in the history
…sts, and change required .net version.
  • Loading branch information
RosaryMala committed Jun 23, 2016
1 parent bc0f217 commit cb7e042
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 94 deletions.
8 changes: 4 additions & 4 deletions Dwarf Portrait/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

<supportedRuntime version="v2.0.50727"/></startup>
</configuration>
8 changes: 1 addition & 7 deletions Dwarf Portrait/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;

namespace Dwarf_Portrait
{
Expand Down
11 changes: 11 additions & 0 deletions Dwarf Portrait/BodyPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,16 @@ public BodyPart()
public List<BodyPartLayer> Layers { get; set; }
public List<BodyPartMod> AppearanceMods { get; set; }
public ColorMod ColorMod { get; set; }
public bool IsInternal
{
get
{
if (OriginalPart == null)
return false;
else
return
OriginalPart.flags[(int)UnitFlags.body_part_raw_flags.INTERNAL];
}
}
}
}
10 changes: 9 additions & 1 deletion Dwarf Portrait/BodyPartInternalSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ class BodyPartInternalSelector : DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
return base.SelectTemplate(item, container);
FrameworkElement element = container as FrameworkElement;
BodyPart part = item as BodyPart;
if(item == null)
return base.SelectTemplate(item, container);

if(part.IsInternal)
return element.FindResource("BodyPartInternalTemplate") as HierarchicalDataTemplate;
else
return element.FindResource("BodyPartExternalTemplate") as HierarchicalDataTemplate;
}
}
}
6 changes: 1 addition & 5 deletions Dwarf Portrait/BodyPartLayer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using RemoteFortressReader;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RemoteFortressReader;

namespace Dwarf_Portrait
{
Expand Down
7 changes: 1 addition & 6 deletions Dwarf Portrait/BodyPartMod.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RemoteFortressReader;
using RemoteFortressReader;

namespace Dwarf_Portrait
{
Expand Down
6 changes: 1 addition & 5 deletions Dwarf Portrait/ColorMod.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using RemoteFortressReader;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RemoteFortressReader;

namespace Dwarf_Portrait
{
Expand Down
46 changes: 45 additions & 1 deletion Dwarf Portrait/Dwarf Portrait.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dwarf_Portrait</RootNamespace>
<AssemblyName>Dwarf Portrait</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>D:\DF\Dwarf-Portrait\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -34,6 +52,19 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>84EE8E902FAD3192058C72A5375D9A3312C0BD7A</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>Dwarf Portrait_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<PropertyGroup />
<ItemGroup>
<Reference Include="protobuf-net, Version=2.0.0.668, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -108,6 +139,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Dwarf Portrait_TemporaryKey.pfx" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -117,6 +149,18 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
55 changes: 29 additions & 26 deletions Dwarf Portrait/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,36 @@
<Window.Resources>
<flags:BodyPartRawFLagsConverter x:Key="BodyPartRawFLagsConverter"/>
<DataTemplate x:Key="MonotonePatternTemplate">
<Border Width="24" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Border Width="16" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Grid Background="{Binding Colors[0]}">
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="IrisEyePatternTemplate">
<Border Width="24" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Border Width="16" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Grid Background="{Binding Colors[0]}">
<Ellipse Height="14" Width="14" Fill="{Binding Colors[2]}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Ellipse Height="6" Width="6" Fill="{Binding Colors[1]}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="PupilEyePatternTemplate">
<Border Width="24" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Border Width="16" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Grid Background="{Binding Colors[0]}">
<Ellipse Height="6" Width="6" Fill="{Binding Colors[1]}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="StripesPatternTemplate">
<Border Width="24" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Border Width="23" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Grid>
<Rectangle Width="5" Fill="{Binding Colors[0]}" HorizontalAlignment="Left"/>
<Rectangle Width="6" Fill="{Binding Colors[1]}" HorizontalAlignment="Left" Margin="5,0,0,0"/>
<Rectangle Width="6" Fill="{Binding Colors[0]}" HorizontalAlignment="Left" Margin="11,0,0,0"/>
<Rectangle Width="5" Fill="{Binding Colors[1]}" HorizontalAlignment="Left" Margin="17,0,0,0"/>
<Rectangle Width="3" Fill="{Binding Colors[0]}" HorizontalAlignment="Left"/>
<Rectangle Width="3" Fill="{Binding Colors[1]}" HorizontalAlignment="Left" Margin="3,0,0,0"/>
<Rectangle Width="3" Fill="{Binding Colors[0]}" HorizontalAlignment="Left" Margin="6,0,0,0"/>
<Rectangle Width="3" Fill="{Binding Colors[1]}" HorizontalAlignment="Left" Margin="9,0,0,0"/>
<Rectangle Width="3" Fill="{Binding Colors[0]}" HorizontalAlignment="Left" Margin="12,0,0,0"/>
<Rectangle Width="3" Fill="{Binding Colors[1]}" HorizontalAlignment="Left" Margin="15,0,0,0"/>
<Rectangle Width="3" Fill="{Binding Colors[0]}" HorizontalAlignment="Left" Margin="18,0,0,0"/>
</Grid>
</Border>
</DataTemplate>
Expand Down Expand Up @@ -83,13 +86,20 @@
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="BodyPartExternalTemplate">
<HierarchicalDataTemplate x:Key="BodyPartExternalTemplate" DataType="{x:Type local:BodyPart}" ItemsSource="{Binding Children}">
<WrapPanel>
<TextBlock Text="{Binding OriginalPart.token}"/>
<TextBlock Text=" - "/>
<TextBlock Text="{Binding OriginalPart.category}" FontSize="12"/>
<TextBlock Text="{Binding OriginalPart.token}" FontWeight="Bold"/>
<TextBlock Text=" - " FontSize="8" VerticalAlignment="Bottom"/>
<TextBlock Text="{Binding OriginalPart.category}" FontSize="8" VerticalAlignment="Bottom"/>
</WrapPanel>
</DataTemplate>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="BodyPartInternalTemplate" DataType="{x:Type local:BodyPart}" ItemsSource="{Binding Children}">
<WrapPanel>
<TextBlock Text="{Binding OriginalPart.token}" FontSize="10" VerticalAlignment="Bottom"/>
<TextBlock Text=" - " FontSize="8" VerticalAlignment="Bottom"/>
<TextBlock Text="{Binding OriginalPart.category}" FontSize="8" VerticalAlignment="Bottom"/>
</WrapPanel>
</HierarchicalDataTemplate>
<local:ColorPatternTemplateSelector x:Key="colorPatternTemplateSelector"/>
<local:BodyPartInternalSelector x:Key="bodyPartInternalSelector"/>
</Window.Resources>
Expand All @@ -100,7 +110,7 @@
<ColumnDefinition Width="210"/>
</Grid.ColumnDefinitions>
<Button x:Name="fetchButton" Content="Fetch Info" Margin="10,0,10,10" Height="20" VerticalAlignment="Bottom" Click="fetchButton_Click" Grid.Column="2"/>
<TabControl Margin="10,10,10,35" Grid.Column="2" >
<TabControl Margin="10,38,10,35" Grid.Column="2" >
<TabItem Header="Units">
<ListBox x:Name="unitListView" Margin="10" SelectionChanged="creatureList_SelectionChanged" Background="Black" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
Expand Down Expand Up @@ -247,16 +257,7 @@
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TreeView x:Name="treeView" Margin="10,10,10,0" Grid.Column="0" ItemsSource="{Binding BodypartTree}" SelectedItemChanged="treeView_SelectedItemChanged" >
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local:BodyPart}" ItemsSource="{Binding Children}">
<WrapPanel>
<TextBlock Text="{Binding OriginalPart.token}"/>
<TextBlock Text=" - "/>
<TextBlock Text="{Binding OriginalPart.category}" FontSize="12"/>
</WrapPanel>
</HierarchicalDataTemplate>
</TreeView.Resources>
<TreeView x:Name="treeView" Margin="10,10,10,0" Grid.Column="0" ItemsSource="{Binding BodypartTree}" SelectedItemChanged="treeView_SelectedItemChanged" ItemTemplateSelector="{StaticResource bodyPartInternalSelector}">
</TreeView>
<StackPanel Grid.Row="1">
<TextBlock Margin="10,10,0,0" Text="Body Modifiers: "/>
Expand Down Expand Up @@ -402,7 +403,7 @@
</Grid>
</Grid>
</TabItem>
<TabItem Header="Portrait">
<!--<TabItem Header="Portrait">
<Canvas>
<Border Width="24" Height="16" BorderBrush="Black" BorderThickness="1,1,1,1">
<Grid Background="Orange">
Expand All @@ -429,7 +430,9 @@
</Grid>
</Border>
</Canvas>
</TabItem>
</TabItem>-->
</TabControl>
<TextBox x:Name="unitFilterTextbox" Grid.Column="2" Height="23" Margin="54,10,10,0" TextWrapping="Wrap" VerticalAlignment="Top" TextChanged="unitFilterTextbox_TextChanged"/>
<Label x:Name="label" Content="Filter:" Grid.Column="2" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="23"/>
</Grid>
</Window>
22 changes: 21 additions & 1 deletion Dwarf Portrait/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
Expand Down Expand Up @@ -92,6 +93,7 @@ private void fetchButton_Click(object sender, RoutedEventArgs e)
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(unitListView.ItemsSource);
view.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
view.SortDescriptions.Add(new SortDescription("Race", ListSortDirection.Ascending));
view.Filter = UnitlistFilter;
}
if(DFConnection.creatureRawList != null)
{
Expand Down Expand Up @@ -129,6 +131,7 @@ private void fetchButton_Click(object sender, RoutedEventArgs e)
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(raceListView.ItemsSource);
view.SortDescriptions.Add(new SortDescription("Race", ListSortDirection.Ascending));
view.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
view.Filter = UnitlistFilter;
}
}

Expand Down Expand Up @@ -180,5 +183,22 @@ private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEv
BodyPart part = e.NewValue as BodyPart;
bodyPartPropertyGrid.DataContext = part;
}

private bool UnitlistFilter (object item)
{
if (string.IsNullOrEmpty(unitFilterTextbox.Text))
return true;
else
return ((item as Creature).Name.IndexOf(unitFilterTextbox.Text, StringComparison.OrdinalIgnoreCase) >= 0)
|| ((item as Creature).Race.IndexOf(unitFilterTextbox.Text, StringComparison.OrdinalIgnoreCase) >= 0);
}

private void unitFilterTextbox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
if(unitListView.ItemsSource != null)
CollectionViewSource.GetDefaultView(unitListView.ItemsSource).Refresh();
if(raceListView.ItemsSource != null)
CollectionViewSource.GetDefaultView(raceListView.ItemsSource).Refresh();
}
}
}
Loading

0 comments on commit cb7e042

Please sign in to comment.