From 79a59b14eceb89e303d7d3b9a15008fc93161007 Mon Sep 17 00:00:00 2001 From: azakhi Date: Wed, 6 Mar 2019 16:02:19 +0300 Subject: [PATCH] Add new block types --- .../BlockItemTypes/AnyEnchantmentBlockItem.cs | 23 +++++++++++ .../BlockItemTypes/FracturedItemBlockItem.cs | 23 +++++++++++ .../BlockItemTypes/HasEnchantmentBlockItem.cs | 39 +++++++++++++++++++ .../SynthesisedItemBlockItem.cs | 23 +++++++++++ .../Enums/BlockItemOrdering.cs | 4 ++ .../Filtration.ObjectModel.csproj | 4 ++ .../Services/ItemFilterBlockTranslator.cs | 20 ++++++++++ Filtration/Filtration.csproj | 1 + Filtration/Properties/Resources.Designer.cs | 13 ++++++- Filtration/Properties/Resources.resx | 3 ++ Filtration/Resources/Enchantments.txt | 1 + Filtration/Services/StaticDataService.cs | 4 ++ Filtration/UserControls/BlockItemControl.xaml | 5 +++ .../DesignTimeItemFilterBlockViewModel.cs | 6 ++- .../ViewModels/ItemFilterBlockViewModel.cs | 8 +++- 15 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 Filtration.ObjectModel/BlockItemTypes/AnyEnchantmentBlockItem.cs create mode 100644 Filtration.ObjectModel/BlockItemTypes/FracturedItemBlockItem.cs create mode 100644 Filtration.ObjectModel/BlockItemTypes/HasEnchantmentBlockItem.cs create mode 100644 Filtration.ObjectModel/BlockItemTypes/SynthesisedItemBlockItem.cs create mode 100644 Filtration/Resources/Enchantments.txt diff --git a/Filtration.ObjectModel/BlockItemTypes/AnyEnchantmentBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/AnyEnchantmentBlockItem.cs new file mode 100644 index 0000000..cf3659d --- /dev/null +++ b/Filtration.ObjectModel/BlockItemTypes/AnyEnchantmentBlockItem.cs @@ -0,0 +1,23 @@ +using System.Windows.Media; +using Filtration.ObjectModel.BlockItemBaseTypes; +using Filtration.ObjectModel.Enums; + +namespace Filtration.ObjectModel.BlockItemTypes +{ + public sealed class AnyEnchantmentBlockItem : BooleanBlockItem + { + public AnyEnchantmentBlockItem() + { + } + + public AnyEnchantmentBlockItem(bool booleanValue) : base(booleanValue) + { + } + + public override string PrefixText => "AnyEnchantment"; + public override string DisplayHeading => "Any Enchantment"; + public override Color SummaryBackgroundColor => Colors.YellowGreen; + public override Color SummaryTextColor => Colors.Black; + public override BlockItemOrdering SortOrder => BlockItemOrdering.AnyEnchantment; + } +} diff --git a/Filtration.ObjectModel/BlockItemTypes/FracturedItemBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/FracturedItemBlockItem.cs new file mode 100644 index 0000000..b64bba6 --- /dev/null +++ b/Filtration.ObjectModel/BlockItemTypes/FracturedItemBlockItem.cs @@ -0,0 +1,23 @@ +using System.Windows.Media; +using Filtration.ObjectModel.BlockItemBaseTypes; +using Filtration.ObjectModel.Enums; + +namespace Filtration.ObjectModel.BlockItemTypes +{ + public sealed class FracturedItemBlockItem : BooleanBlockItem + { + public FracturedItemBlockItem() + { + } + + public FracturedItemBlockItem(bool booleanValue) : base(booleanValue) + { + } + + public override string PrefixText => "FracturedItem"; + public override string DisplayHeading => "Fractured Item"; + public override Color SummaryBackgroundColor => Colors.Salmon; + public override Color SummaryTextColor => Colors.Black; + public override BlockItemOrdering SortOrder => BlockItemOrdering.FracturedItem; + } +} diff --git a/Filtration.ObjectModel/BlockItemTypes/HasEnchantmentBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/HasEnchantmentBlockItem.cs new file mode 100644 index 0000000..3f4a897 --- /dev/null +++ b/Filtration.ObjectModel/BlockItemTypes/HasEnchantmentBlockItem.cs @@ -0,0 +1,39 @@ +using System.Linq; +using System.Windows.Media; +using Filtration.ObjectModel.BlockItemBaseTypes; +using Filtration.ObjectModel.Enums; + +namespace Filtration.ObjectModel.BlockItemTypes +{ + public class HasEnchantmentBlockItem : StringListBlockItem + { + public override string PrefixText => "HasEnchantment"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Has Enchantment"; + + public override string SummaryText + { + get + { + if (Items.Count > 0 && Items.Count < 4) + { + return "Enchantments: " + + Items.Aggregate(string.Empty, (current, i) => current + i + ", ").TrimEnd(' ').TrimEnd(','); + } + if (Items.Count >= 4) + { + var remaining = Items.Count - 3; + return "Enchantments: " + Items.Take(3) + .Aggregate(string.Empty, (current, i) => current + i + ", ") + .TrimEnd(' ') + .TrimEnd(',') + " (+" + remaining + " more)"; + } + return "Enchantments: (none)"; + } + } + + public override Color SummaryBackgroundColor => Colors.PaleGreen; + public override Color SummaryTextColor => Colors.Black; + public override BlockItemOrdering SortOrder => BlockItemOrdering.HasEnchantment; + } +} diff --git a/Filtration.ObjectModel/BlockItemTypes/SynthesisedItemBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/SynthesisedItemBlockItem.cs new file mode 100644 index 0000000..4407a93 --- /dev/null +++ b/Filtration.ObjectModel/BlockItemTypes/SynthesisedItemBlockItem.cs @@ -0,0 +1,23 @@ +using System.Windows.Media; +using Filtration.ObjectModel.BlockItemBaseTypes; +using Filtration.ObjectModel.Enums; + +namespace Filtration.ObjectModel.BlockItemTypes +{ + public sealed class SynthesisedItemBlockItem : BooleanBlockItem + { + public SynthesisedItemBlockItem() + { + } + + public SynthesisedItemBlockItem(bool booleanValue) : base(booleanValue) + { + } + + public override string PrefixText => "SynthesisedItem"; + public override string DisplayHeading => "Synthesised Item"; + public override Color SummaryBackgroundColor => Colors.Salmon; + public override Color SummaryTextColor => Colors.Black; + public override BlockItemOrdering SortOrder => BlockItemOrdering.SynthesisedItem; + } +} diff --git a/Filtration.ObjectModel/Enums/BlockItemOrdering.cs b/Filtration.ObjectModel/Enums/BlockItemOrdering.cs index a9fcd08..a9ec310 100644 --- a/Filtration.ObjectModel/Enums/BlockItemOrdering.cs +++ b/Filtration.ObjectModel/Enums/BlockItemOrdering.cs @@ -12,6 +12,9 @@ namespace Filtration.ObjectModel.Enums Corrupted, ElderItem, ShaperItem, + SynthesisedItem, + FracturedItem, + AnyEnchantment, MapTier, ShapedMap, ElderMap, @@ -27,6 +30,7 @@ namespace Filtration.ObjectModel.Enums BaseType, Prophecy, HasExplicitMod, + HasEnchantment, SetTextColor, SetBackgroundColor, SetBorderColor, diff --git a/Filtration.ObjectModel/Filtration.ObjectModel.csproj b/Filtration.ObjectModel/Filtration.ObjectModel.csproj index 04b58ef..b6fd981 100644 --- a/Filtration.ObjectModel/Filtration.ObjectModel.csproj +++ b/Filtration.ObjectModel/Filtration.ObjectModel.csproj @@ -81,8 +81,11 @@ + + + @@ -95,6 +98,7 @@ + diff --git a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs index 21d8d8c..372e766 100644 --- a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs +++ b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs @@ -184,6 +184,21 @@ namespace Filtration.Parser.Services AddBooleanItemToBlockItems(block, trimmedLine); break; } + case "SynthesisedItem": + { + AddBooleanItemToBlockItems(block, trimmedLine); + break; + } + case "FracturedItem": + { + AddBooleanItemToBlockItems(block, trimmedLine); + break; + } + case "AnyEnchantment": + { + AddBooleanItemToBlockItems(block, trimmedLine); + break; + } case "ShapedMap": { AddBooleanItemToBlockItems(block, trimmedLine); @@ -317,6 +332,11 @@ namespace Filtration.Parser.Services AddStringListItemToBlockItems(block, trimmedLine); break; } + case "HasEnchantment": + { + AddStringListItemToBlockItems(block, trimmedLine); + break; + } case "ElderMap": { AddBooleanItemToBlockItems(block, trimmedLine); diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index cd85216..24ea0ba 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -463,6 +463,7 @@ Settings.settings True + diff --git a/Filtration/Properties/Resources.Designer.cs b/Filtration/Properties/Resources.Designer.cs index 2ac594b..013aaa0 100644 --- a/Filtration/Properties/Resources.Designer.cs +++ b/Filtration/Properties/Resources.Designer.cs @@ -388,7 +388,18 @@ namespace Filtration.Properties { return ResourceManager.GetString("Prophecies", resourceCulture); } } - + + /// + /// Looks up a localized string similar to Enchantment Decree of Force. + /// + internal static string Enchantments + { + get + { + return ResourceManager.GetString("Enchantments", resourceCulture); + } + } + /// /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. /// diff --git a/Filtration/Properties/Resources.resx b/Filtration/Properties/Resources.resx index 89e5bc4..87f7089 100644 --- a/Filtration/Properties/Resources.resx +++ b/Filtration/Properties/Resources.resx @@ -214,4 +214,7 @@ ..\Resources\Prophecies.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + ..\Resources\Enchantments.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + \ No newline at end of file diff --git a/Filtration/Resources/Enchantments.txt b/Filtration/Resources/Enchantments.txt new file mode 100644 index 0000000..c9e3ed4 --- /dev/null +++ b/Filtration/Resources/Enchantments.txt @@ -0,0 +1 @@ +Enchantment Decree of Force \ No newline at end of file diff --git a/Filtration/Services/StaticDataService.cs b/Filtration/Services/StaticDataService.cs index 5591306..1e73f42 100644 --- a/Filtration/Services/StaticDataService.cs +++ b/Filtration/Services/StaticDataService.cs @@ -12,6 +12,7 @@ namespace Filtration.Services IEnumerable ItemClasses { get; } IEnumerable ItemMods { get; } IEnumerable Prophecies { get; } + IEnumerable Enchantments { get; } } internal class StaticDataService : IStaticDataService @@ -29,12 +30,15 @@ namespace Filtration.Services public IEnumerable Prophecies { get; private set; } + public IEnumerable Enchantments { get; private set; } + private void PopulateStaticData() { ItemBaseTypes = new LineReader(() => new StringReader(Resources.ItemBaseTypes)).ToList(); ItemClasses = new LineReader(() => new StringReader(Resources.ItemClasses)).ToList(); ItemMods = new LineReader(() => new StringReader(Resources.ItemMods)).ToList(); Prophecies = new LineReader(() => new StringReader(Resources.Prophecies)).ToList(); + Enchantments = new LineReader(() => new StringReader(Resources.Enchantments)).ToList(); } } } diff --git a/Filtration/UserControls/BlockItemControl.xaml b/Filtration/UserControls/BlockItemControl.xaml index 5be1988..f6d77e6 100644 --- a/Filtration/UserControls/BlockItemControl.xaml +++ b/Filtration/UserControls/BlockItemControl.xaml @@ -87,6 +87,11 @@ + + + + + diff --git a/Filtration/ViewModels/DesignTime/DesignTimeItemFilterBlockViewModel.cs b/Filtration/ViewModels/DesignTime/DesignTimeItemFilterBlockViewModel.cs index 817a01d..47f9c90 100644 --- a/Filtration/ViewModels/DesignTime/DesignTimeItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/DesignTime/DesignTimeItemFilterBlockViewModel.cs @@ -131,12 +131,16 @@ namespace Filtration.ViewModels.DesignTime typeof (CorruptedBlockItem), typeof (ElderItemBlockItem), typeof (ShaperItemBlockItem), + typeof (SynthesisedItemBlockItem), + typeof (FracturedItemBlockItem), + typeof (AnyEnchantmentBlockItem), typeof (MapTierBlockItem), typeof (ShapedMapBlockItem), typeof (ElderMapBlockItem), typeof (GemLevelBlockItem), typeof (StackSizeBlockItem), - typeof (HasExplicitModBlockItem) + typeof (HasExplicitModBlockItem), + typeof (HasEnchantmentBlockItem) }; public List AudioVisualBlockItemTypesAvailable { get; } public Color DisplayTextColor => Colors.Red; diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index d4dc7d0..e239556 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -208,6 +208,8 @@ namespace Filtration.ViewModels public IEnumerable AutocompleteItemMods => _staticDataService.ItemMods; + public IEnumerable AutocompleteEnchantments => _staticDataService.Enchantments; + public List BlockItemTypesAvailable => new List { typeof (ItemLevelBlockItem), @@ -226,12 +228,16 @@ namespace Filtration.ViewModels typeof (CorruptedBlockItem), typeof (ElderItemBlockItem), typeof (ShaperItemBlockItem), + typeof (SynthesisedItemBlockItem), + typeof (FracturedItemBlockItem), + typeof (AnyEnchantmentBlockItem), typeof (MapTierBlockItem), typeof (ShapedMapBlockItem), typeof (ElderMapBlockItem), typeof (GemLevelBlockItem), typeof (StackSizeBlockItem), - typeof (HasExplicitModBlockItem) + typeof (HasExplicitModBlockItem), + typeof (HasEnchantmentBlockItem) }; public List AudioVisualBlockItemTypesAvailable => new List