Groundwork for loot preview view implemented

This commit is contained in:
Ben Wallis 2016-01-31 14:11:30 +00:00
parent 8bfbe7cc66
commit 76dd9fb22c
15 changed files with 13970 additions and 41 deletions

View File

@ -16,6 +16,7 @@ namespace Filtration.ItemFilterPreview
_container.AddFacility<TypedFactoryFacility>(); _container.AddFacility<TypedFactoryFacility>();
_container.Install(FromAssembly.InThisApplication()); _container.Install(FromAssembly.InThisApplication());
_container.Install(FromAssembly.Named("Filtration.Parser"));
var mainWindow = _container.Resolve<IMainWindow>(); var mainWindow = _container.Resolve<IMainWindow>();
mainWindow.Show(); mainWindow.Show();

View File

@ -60,6 +60,9 @@
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath> <HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@ -95,6 +98,9 @@
<Compile Include="UserControls\ItemSocketsControl.xaml.cs"> <Compile Include="UserControls\ItemSocketsControl.xaml.cs">
<DependentUpon>ItemSocketsControl.xaml</DependentUpon> <DependentUpon>ItemSocketsControl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UserControls\LootExplosionSceneUserControl.xaml.cs">
<DependentUpon>LootExplosionSceneUserControl.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\LootExplosionViewModel.cs" /> <Compile Include="ViewModels\LootExplosionViewModel.cs" />
<Compile Include="ViewModels\MainWindowViewModel.cs" /> <Compile Include="ViewModels\MainWindowViewModel.cs" />
<Compile Include="Views\LootExplosionView.xaml.cs"> <Compile Include="Views\LootExplosionView.xaml.cs">
@ -107,6 +113,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UserControls\LootExplosionSceneUserControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\LootExplosionView.xaml"> <Page Include="Views\LootExplosionView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -166,8 +176,21 @@
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project> <Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name> <Name>Filtration.ObjectModel</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Filtration.Parser.Interface\Filtration.Parser.Interface.csproj">
<Project>{46383f20-02df-48b4-b092-9088fa4acd5a}</Project>
<Name>Filtration.Parser.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.Parser\Filtration.Parser.csproj">
<Project>{10a7c2bc-ec6f-4a38-bdda-e35935004c02}</Project>
<Name>Filtration.Parser</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\neversink.filter.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\muldini.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,7 +1,10 @@
using System.Windows.Media; using System.Data;
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemTypes; using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
namespace Filtration.ItemFilterPreview.Model namespace Filtration.ItemFilterPreview.Model
{ {
@ -13,6 +16,7 @@ namespace Filtration.ItemFilterPreview.Model
Color BackgroundColor { get; } Color BackgroundColor { get; }
Color BorderColor { get; } Color BorderColor { get; }
Color TextColor { get; } Color TextColor { get; }
double FontSize { get; }
} }
public class FilteredItem : IFilteredItem public class FilteredItem : IFilteredItem
@ -21,25 +25,35 @@ namespace Filtration.ItemFilterPreview.Model
{ {
Item = item; Item = item;
ItemFilterBlock = itemFilterBlock; ItemFilterBlock = itemFilterBlock;
BlockAction = itemFilterBlock?.Action ?? BlockAction.Show;
BackgroundColor = itemFilterBlock?.DisplayBackgroundColor ?? new Color { A = 255, R = 0, G = 0, B = 0 };
BorderColor = itemFilterBlock?.DisplayBorderColor ?? new Color {A = 255, R = 0, G = 0, B = 0};
FontSize = (itemFilterBlock?.DisplayFontSize ?? 34) / 1.8;
SetTextColor();
} }
private void SetTextColor()
{
if (ItemFilterBlock == null)
{
TextColor = Item.DefaultTextColor;
return;
}
var textColorBlockItem = ItemFilterBlock.BlockItems.OfType<TextColorBlockItem>().FirstOrDefault();
TextColor = textColorBlockItem?.Color ?? Item.DefaultTextColor;
}
public IItem Item { get; private set; } public IItem Item { get; private set; }
public IItemFilterBlock ItemFilterBlock { get; private set; } public IItemFilterBlock ItemFilterBlock { get; private set; }
public BlockAction BlockAction => ItemFilterBlock?.Action ?? BlockAction.Show; public BlockAction BlockAction { get; private set; }
public Color BackgroundColor => ItemFilterBlock.HasBlockItemOfType<BackgroundColorBlockItem>() ? ItemFilterBlock.DisplayBackgroundColor : new Color { A = 255, R = 0, G = 0, B = 0 }; public Color BackgroundColor { get; private set; }
public Color BorderColor => ItemFilterBlock.HasBlockItemOfType<BorderColorBlockItem>() ? ItemFilterBlock.DisplayBorderColor : new Color { A = 255, R = 0, G = 0, B = 0 }; public Color TextColor { get; private set; }
public Color TextColor public Color BorderColor { get; private set; }
{ public double FontSize { get; private set; }
get
{
if (ItemFilterBlock.HasBlockItemOfType<TextColorBlockItem>())
{
return ItemFilterBlock.DisplayTextColor;
}
return Item.DefaultTextColor;
}
}
} }
} }

View File

@ -12,6 +12,7 @@ namespace Filtration.ItemFilterPreview.Model
{ {
public interface IItem public interface IItem
{ {
string Description { get; set; }
string ItemClass { get; set; } string ItemClass { get; set; }
string BaseType { get; set; } string BaseType { get; set; }
int DropLevel { get; set; } int DropLevel { get; set; }
@ -32,6 +33,7 @@ namespace Filtration.ItemFilterPreview.Model
{ {
private List<SocketGroup> _socketGroups; private List<SocketGroup> _socketGroups;
public string Description { get; set; }
public string ItemClass { get; set; } public string ItemClass { get; set; }
public string BaseType { get; set; } public string BaseType { get; set; }
public int DropLevel { get; set; } public int DropLevel { get; set; }
@ -58,9 +60,9 @@ namespace Filtration.ItemFilterPreview.Model
set set
{ {
var socketCount = value.Sum(s => s.Count); var socketCount = value.Sum(s => s.Count);
if (socketCount < 1 || socketCount > 6) if (socketCount < 0 || socketCount > 6)
{ {
throw new InvalidOperationException("An item must have between 1 and 6 sockets"); throw new InvalidOperationException("An item must have between 0 and 6 sockets");
} }
var evenSocketCount = socketCount % 2 == 0; var evenSocketCount = socketCount % 2 == 0;
@ -86,6 +88,23 @@ namespace Filtration.ItemFilterPreview.Model
} }
} }
public Color DefaultTextColor => ItemRarity.DefaultRarityTextColor(); public Color DefaultTextColor
{
get
{
if (ItemClass.Contains("Gems"))
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.GemItem];
}
if (ItemClass.Contains("Quest"))
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.QuestItem];
}
return ItemRarity != ItemRarity.NotSet ? ItemRarity.DefaultRarityTextColor() : PathOfExileNamedColors.Colors[PathOfExileNamedColor.WhiteItem];
}
}
} }
} }

View File

@ -59,5 +59,42 @@ namespace Filtration.ItemFilterPreview.Properties {
resourceCulture = value; resourceCulture = value;
} }
} }
/// <summary>
/// Looks up a localized string similar to ###############################################################################
///################ Path of Exile Item Filter - Script by Muldini ################
///###############################################################################
///############ http://www.pathofexile.com/forum/view-thread/1259059 #############
///
///
///
///
///###############################################################################
///### Overview ##################################################################
///################## [rest of string was truncated]&quot;;.
/// </summary>
internal static string muldini {
get {
return ResourceManager.GetString("muldini", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to #---------------------------------------------------------------------------------------------------------------
///# NeverSink&apos;s Indepth Loot Filter
///# VERSION 3.0 - Full
///#---------------------------------------------------------------------------------------------------------------
///#
///# You can always find the latest version here:
///# http://pastebin.com/Af00CbhA
///# Forum discussion thread. You can post question and feedback here:
///# http://www.pathofexile.com/forum/view-thread/1246208/page/1
///# Please use [rest of string was truncated]&quot;;.
/// </summary>
internal static string neversinkfilter {
get {
return ResourceManager.GetString("neversinkfilter", resourceCulture);
}
}
} }
} }

View File

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
@ -109,9 +112,16 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="muldini" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\muldini.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="neversinkfilter" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\neversink.filter.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root> </root>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,7 @@ namespace Filtration.ItemFilterPreview.Services
private static bool ClassBlockItemMatch(ClassBlockItem classBlockItem, IItem item) private static bool ClassBlockItemMatch(ClassBlockItem classBlockItem, IItem item)
{ {
return classBlockItem.Items.Any(c => item.ItemClass.StartsWith(c)); return classBlockItem.Items.Any(c => item.ItemClass.Contains(c));
} }
private static bool DropLevelBlockItemMatch(DropLevelBlockItem dropLevelBlockItem, IItem item) private static bool DropLevelBlockItemMatch(DropLevelBlockItem dropLevelBlockItem, IItem item)

View File

@ -15,7 +15,7 @@ namespace Filtration.ItemFilterPreview.Services
{ {
private readonly IBlockItemMatcher _blockItemMatcher; private readonly IBlockItemMatcher _blockItemMatcher;
internal ItemFilterProcessor(IBlockItemMatcher blockItemMatcher) public ItemFilterProcessor(IBlockItemMatcher blockItemMatcher)
{ {
_blockItemMatcher = blockItemMatcher; _blockItemMatcher = blockItemMatcher;
} }

View File

@ -1,12 +1,17 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.ItemFilterPreview.Model;
using Moq;
namespace Filtration.ItemFilterPreview.UserControls.DesignTime namespace Filtration.ItemFilterPreview.UserControls.DesignTime
{ {
public class DesignTimeItemControl public class DesignTimeItemControl
{ {
public Color BackgroundColor => Colors.Bisque; public IFilteredItem FilteredItem
public Color TextColor => Colors.Maroon; {
public Color BorderColor => Colors.CornflowerBlue; get
public int FontSize => 15; {
return Mock.Of<IFilteredItem>(f => f.BackgroundColor == Colors.Bisque && f.TextColor == Colors.Maroon && f.BorderColor == Colors.CornflowerBlue && f.FontSize == 15);
}
}
} }
} }

View File

@ -9,10 +9,10 @@
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeItemControl, IsDesignTimeCreatable=True}" d:DataContext="{d:DesignInstance Type=designTime:DesignTimeItemControl, IsDesignTimeCreatable=True}"
d:DesignHeight="35" d:DesignWidth="170"> d:DesignHeight="35" d:DesignWidth="170">
<UserControl.Resources> <UserControl.Resources>
<converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" /> <Style x:Key="PathOfExileFont" TargetType="{x:Type TextBlock}">
<Style x:Key="PathOfExileFont"> <Setter Property="FontFamily" Value="pack://application:,,,/resources/#Fontin SmallCaps" />
<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/resources/#Fontin SmallCaps" />
</Style> </Style>
<converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter"/>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -25,16 +25,13 @@
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Row="1" Grid.Column="1" Margin="3" Padding="4,0,4,0" BorderThickness="1"> <Border Grid.Row="1" Grid.Column="1" Margin="3" Padding="4,0,4,0" BorderThickness="1" BorderBrush="{Binding FilteredItem.BorderColor, Converter={StaticResource ColorToSolidColorBrushConverter}}">
<Border.Background> <Border.Background>
<SolidColorBrush Color="{Binding BackgroundColor}" /> <SolidColorBrush Color="{Binding FilteredItem.BackgroundColor}" />
</Border.Background> </Border.Background>
<Border.BorderBrush> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding FilteredItem.Item.Description}" Style="{StaticResource PathOfExileFont}" FontSize="{Binding FilteredItem.FontSize}">
<SolidColorBrush Color="{Binding BorderColor}" />
</Border.BorderBrush>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Item Preview" Style="{StaticResource PathOfExileFont}" FontSize="{Binding FontSize}">
<TextBlock.Foreground> <TextBlock.Foreground>
<SolidColorBrush Color="{Binding TextColor}" /> <SolidColorBrush Color="{Binding FilteredItem.TextColor}" />
</TextBlock.Foreground> </TextBlock.Foreground>
</TextBlock> </TextBlock>
</Border> </Border>

View File

@ -0,0 +1,24 @@
<UserControl x:Class="Filtration.ItemFilterPreview.UserControls.LootExplosionSceneUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:Filtration.ItemFilterPreview.UserControls"
xmlns:model="clr-namespace:Filtration.ItemFilterPreview.Model"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance local:LootExplosionSceneUserControl}">
<Grid Background="DimGray">
<ItemsControl ItemsSource="{Binding FilteredItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type model:IFilteredItem}">
<local:ItemControl FilteredItem="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>

View File

@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using Filtration.ItemFilterPreview.Model;
namespace Filtration.ItemFilterPreview.UserControls
{
public partial class LootExplosionSceneUserControl : UserControl
{
public LootExplosionSceneUserControl()
{
InitializeComponent();
}
public static readonly DependencyProperty FilteredItemsProperty = DependencyProperty.Register(
"FilteredItems",
typeof(IEnumerable<IFilteredItem>),
typeof(LootExplosionSceneUserControl),
new FrameworkPropertyMetadata()
);
public IEnumerable<IFilteredItem> FilteredItems
{
get { return (IEnumerable<IFilteredItem>)GetValue(FilteredItemsProperty); }
set { SetValue(FilteredItemsProperty, value); }
}
}
}

View File

@ -133,6 +133,19 @@ namespace Filtration.ObjectModel
return textColorBlockItem.Color; return textColorBlockItem.Color;
} }
var itemClassBlockItem = BlockItems.OfType<ClassBlockItem>().FirstOrDefault();
if (itemClassBlockItem != null)
{
if (itemClassBlockItem.Items.All(i => i.Contains("Gems")))
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.GemItem];
}
if (itemClassBlockItem.Items.All(i => i.Contains("Quest")))
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.QuestItem];
}
}
var rarityBlockItem = BlockItems.OfType<RarityBlockItem>().FirstOrDefault(); var rarityBlockItem = BlockItems.OfType<RarityBlockItem>().FirstOrDefault();
return rarityBlockItem != null return rarityBlockItem != null
? ((ItemRarity) rarityBlockItem.FilterPredicate.PredicateOperand).DefaultRarityTextColor() ? ((ItemRarity) rarityBlockItem.FilterPredicate.PredicateOperand).DefaultRarityTextColor()