Various refactorings to support ItemFilterPreview

This commit is contained in:
Ben Wallis
2016-01-31 10:51:53 +00:00
parent d159f0b262
commit 86dc03f4ff
49 changed files with 623 additions and 212 deletions

View File

@@ -4,6 +4,8 @@ namespace Filtration.ObjectModel.Enums
{
public enum ItemRarity
{
[Description("Not Set")]
NotSet,
[Description("Normal")]
Normal,
[Description("Magic")]

View File

@@ -0,0 +1,36 @@
namespace Filtration.ObjectModel.Enums
{
public enum PathOfExileNamedColor
{
Default,
ValueDefault,
Pink,
DodgerBlue,
Fire,
Cold,
Lightning,
Chaos,
Augmented,
Crafted,
Unmet,
UniqueItem,
RareItem,
MagicItem,
WhiteItem,
GemItem,
CurrencyItem,
QuestItem,
NemesisMod,
NemesisModOutline,
Title,
Corrupted,
Favour,
SupporterPackNewItem,
SupporterPackItem,
BloodlineMod,
BloodlineModOutline,
TormentMod,
TormentModOutline,
CantTradeorModify
}
}

View File

@@ -1,9 +1,12 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
namespace Filtration.ObjectModel.Enums
{
[Serializable]
public enum SocketColor
{
Yellow,
[Description("R")]
Red,
[Description("G")]

View File

@@ -0,0 +1,39 @@
using System;
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.Extensions
{
public static class ItemRarityExtensions
{
public static Color DefaultRarityTextColor(this ItemRarity itemRarity)
{
switch (itemRarity)
{
case ItemRarity.Magic:
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.MagicItem];
}
case ItemRarity.Normal:
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.WhiteItem];
}
case ItemRarity.Rare:
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.RareItem];
}
case ItemRarity.Unique:
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.UniqueItem];
}
case ItemRarity.NotSet:
{
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.QuestItem];
}
default:
throw new ArgumentOutOfRangeException(nameof(itemRarity), itemRarity, null);
}
}
}
}

View File

@@ -72,6 +72,7 @@
<Compile Include="Enums\SocketColor.cs" />
<Compile Include="Enums\ThemeComponentType.cs" />
<Compile Include="Extensions\EnumHelper.cs" />
<Compile Include="Extensions\ItemRarityExtensions.cs" />
<Compile Include="IAudioVisualBlockItem.cs" />
<Compile Include="IItemFilterBlockItem.cs" />
<Compile Include="ItemFilterBlock.cs" />
@@ -79,6 +80,8 @@
<Compile Include="ItemFilterScript.cs" />
<Compile Include="ItemFilterSection.cs" />
<Compile Include="NumericFilterPredicate.cs" />
<Compile Include="PathOfExileNamedColors.cs" />
<Compile Include="Enums\PathOfExileNamedColor.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReplaceColorsParameterSet.cs" />

View File

@@ -1,8 +1,11 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
namespace Filtration.ObjectModel
{
@@ -13,6 +16,10 @@ namespace Filtration.ObjectModel
ItemFilterBlockGroup BlockGroup { get; set; }
BlockAction Action { get; set; }
ObservableCollection<IItemFilterBlockItem> BlockItems { get; }
Color DisplayBackgroundColor { get; }
Color DisplayTextColor { get; }
Color DisplayBorderColor { get; }
double DisplayFontSize { get; }
int BlockCount(Type type);
bool AddBlockItemAllowed(Type type);
bool HasBlockItemOfType<T>();
@@ -115,5 +122,49 @@ namespace Filtration.ObjectModel
Action = BlockAction.Show;
}
}
public Color DisplayTextColor
{
get
{
var textColorBlockItem = BlockItems.OfType<TextColorBlockItem>().FirstOrDefault();
if (textColorBlockItem != null)
{
return textColorBlockItem.Color;
}
var rarityBlockItem = BlockItems.OfType<RarityBlockItem>().FirstOrDefault();
return rarityBlockItem != null
? ((ItemRarity) rarityBlockItem.FilterPredicate.PredicateOperand).DefaultRarityTextColor()
: PathOfExileNamedColors.Colors[PathOfExileNamedColor.WhiteItem];
}
}
public Color DisplayBackgroundColor
{
get
{
var backgroundColorBlockItem = BlockItems.OfType<BackgroundColorBlockItem>().FirstOrDefault();
return backgroundColorBlockItem?.Color ?? new Color { A = 255, R = 0, G = 0, B = 0 };
}
}
public Color DisplayBorderColor
{
get
{
var borderColorBlockItem = BlockItems.OfType<BorderColorBlockItem>().FirstOrDefault();
return borderColorBlockItem?.Color ?? new Color { A = 255, R = 0, G = 0, B = 0 };
}
}
public double DisplayFontSize
{
get
{
var fontSizeBlockItem = BlockItems.OfType<FontSizeBlockItem>().FirstOrDefault();
return fontSizeBlockItem?.Value ?? 34;
}
}
}
}

View File

@@ -0,0 +1,44 @@
using System.Collections.Generic;
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel
{
public static class PathOfExileNamedColors
{
public static Dictionary<PathOfExileNamedColor, Color> Colors => new Dictionary<PathOfExileNamedColor, Color>
{
{PathOfExileNamedColor.Default, new Color {A = 255, R = 127, G = 127, B = 127}},
{PathOfExileNamedColor.ValueDefault, new Color {A = 255, R = 255, G = 255, B = 255}},
{PathOfExileNamedColor.Pink, new Color {A = 255, R = 255, G = 192, B = 203}},
{PathOfExileNamedColor.DodgerBlue, new Color {A = 255, R = 30, G = 144, B = 255}},
{PathOfExileNamedColor.Fire, new Color {A = 255, R = 150, G = 0, B = 0}},
{PathOfExileNamedColor.Cold, new Color {A = 255, R = 54, G = 100, B = 146}},
{PathOfExileNamedColor.Lightning, new Color {A = 255, R = 255, G = 215, B = 0}},
{PathOfExileNamedColor.Chaos, new Color {A = 255, R = 208, G = 32, B = 144}},
{PathOfExileNamedColor.Augmented, new Color {A = 255, R = 136, G = 136, B = 255}},
{PathOfExileNamedColor.Crafted, new Color {A = 255, R = 184, G = 218, B = 242}},
{PathOfExileNamedColor.Unmet, new Color {A = 255, R = 210, G = 0, B = 0}},
{PathOfExileNamedColor.UniqueItem, new Color {A = 255, R = 175, G = 96, B = 37}},
{PathOfExileNamedColor.RareItem, new Color {A = 255, R = 255, G = 255, B = 119}},
{PathOfExileNamedColor.MagicItem, new Color {A = 255, R = 136, G = 136, B = 255}},
{PathOfExileNamedColor.WhiteItem, new Color {A = 255, R = 200, G = 200, B = 200}},
{PathOfExileNamedColor.GemItem, new Color {A = 255, R = 27, G = 162, B = 155}},
{PathOfExileNamedColor.CurrencyItem, new Color {A = 255, R = 170, G = 158, B = 130}},
{PathOfExileNamedColor.QuestItem, new Color {A = 255, R = 74, G = 230, B = 58}},
{PathOfExileNamedColor.NemesisMod, new Color {A = 255, R = 255, G = 200, B = 0}},
{PathOfExileNamedColor.NemesisModOutline, new Color {A = 220, R = 255, G = 40, B = 0}},
{PathOfExileNamedColor.Title, new Color {A = 255, R = 231, G = 180, B = 120}},
{PathOfExileNamedColor.Corrupted, new Color {A = 255, R = 210, G = 0, B = 0}},
{PathOfExileNamedColor.Favour, new Color {A = 255, R = 170, G = 158, B = 130}},
{PathOfExileNamedColor.SupporterPackNewItem, new Color {A = 255, R = 180, G = 96, B = 0}},
{PathOfExileNamedColor.SupporterPackItem, new Color {A = 255, R = 163, G = 141, B = 109}},
{PathOfExileNamedColor.BloodlineMod, new Color {A = 255, R = 210, G = 0, B = 220}},
{PathOfExileNamedColor.BloodlineModOutline, new Color {A = 200, R = 74, G = 0, B = 160}},
{PathOfExileNamedColor.TormentMod, new Color {A = 255, R = 50, G = 230, B = 100}},
{PathOfExileNamedColor.TormentModOutline, new Color {A = 200, R = 0, G = 100, B = 150}},
{PathOfExileNamedColor.CantTradeorModify, new Color {A = 255, R = 210, G = 0, B = 0}},
};
}
}

View File

@@ -1,9 +1,15 @@
using Filtration.ObjectModel.Enums;
using System;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel
{
[Serializable]
public class Socket
{
private Socket()
{
}
public Socket(SocketColor color)
{
Color = color;

View File

@@ -3,8 +3,14 @@ using System.Collections.Generic;
namespace Filtration.ObjectModel
{
[Serializable]
public class SocketGroup : List<Socket>
{
private SocketGroup()
{
}
public SocketGroup(List<Socket> sockets, bool linked)
{
if (sockets.Count < 1 || sockets.Count > 6)