diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/NilBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/NilBlockItem.cs new file mode 100644 index 0000000..bc84674 --- /dev/null +++ b/Filtration.ObjectModel/BlockItemBaseTypes/NilBlockItem.cs @@ -0,0 +1,16 @@ +namespace Filtration.ObjectModel.BlockItemBaseTypes +{ + public abstract class NilBlockItem : BlockItemBase + { + protected NilBlockItem() + { + + } + + public override string OutputText => PrefixText; + public override string SummaryText => DisplayHeading; + public override int MaximumAllowed => 1; + + public abstract string Description { get; } + } +} diff --git a/Filtration.ObjectModel/BlockItemTypes/DisableDropSoundBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/DisableDropSoundBlockItem.cs index 282e2f2..d075f6e 100644 --- a/Filtration.ObjectModel/BlockItemTypes/DisableDropSoundBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/DisableDropSoundBlockItem.cs @@ -4,18 +4,15 @@ using Filtration.ObjectModel.Enums; namespace Filtration.ObjectModel.BlockItemTypes { - public sealed class DisableDropSoundBlockItem : BooleanBlockItem, IAudioVisualBlockItem + public sealed class DisableDropSoundBlockItem : NilBlockItem, IAudioVisualBlockItem { - public DisableDropSoundBlockItem() - { - } - - public DisableDropSoundBlockItem(bool booleanValue) : base(booleanValue) + public DisableDropSoundBlockItem() : base() { } public override string PrefixText => "DisableDropSound"; public override string DisplayHeading => "Disable Drop Sound"; + public override string Description => "Default drop sound disabled."; public override Color SummaryBackgroundColor => Colors.Transparent; public override Color SummaryTextColor => Colors.Transparent; public override BlockItemOrdering SortOrder => BlockItemOrdering.DisableDropSound; diff --git a/Filtration.ObjectModel/Filtration.ObjectModel.csproj b/Filtration.ObjectModel/Filtration.ObjectModel.csproj index 06fe4d0..04b58ef 100644 --- a/Filtration.ObjectModel/Filtration.ObjectModel.csproj +++ b/Filtration.ObjectModel/Filtration.ObjectModel.csproj @@ -75,6 +75,7 @@ <Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\EffectColorBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\IconBlockItem.cs" /> + <Compile Include="BlockItemBaseTypes\NilBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\StringBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\StrIntBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\IntegerBlockItem.cs" /> diff --git a/Filtration.Parser.Tests/Services/TestItemFilterBlockTranslator.cs b/Filtration.Parser.Tests/Services/TestItemFilterBlockTranslator.cs index e96760f..88ffde2 100644 --- a/Filtration.Parser.Tests/Services/TestItemFilterBlockTranslator.cs +++ b/Filtration.Parser.Tests/Services/TestItemFilterBlockTranslator.cs @@ -919,7 +919,7 @@ namespace Filtration.Parser.Tests.Services { // Arrange var inputString = "Show" + Environment.NewLine + - " DisableDropSound True"; + " DisableDropSound # Test"; // Act var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); @@ -928,7 +928,7 @@ namespace Filtration.Parser.Tests.Services Assert.AreEqual(1, result.BlockItems.Count(b => b is DisableDropSoundBlockItem)); var blockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); - Assert.IsTrue(blockItem.BooleanValue); + Assert.AreEqual(blockItem.Comment, " Test"); } [Test] @@ -965,7 +965,7 @@ namespace Filtration.Parser.Tests.Services " SetBorderColor 0 0 0" + Environment.NewLine + " SetFontSize 50" + Environment.NewLine + " PlayAlertSound 3" + Environment.NewLine + - " DisableDropSound False" + Environment.NewLine + + " DisableDropSound # False" + Environment.NewLine + " CustomAlertSound \"test.mp3\" # customSoundTheme" + Environment.NewLine + " MinimapIcon 2 Green Triangle # iconTheme" + Environment.NewLine + " PlayEffect Green Temp # effectTheme" + Environment.NewLine; @@ -1075,7 +1075,7 @@ namespace Filtration.Parser.Tests.Services Assert.AreEqual(0, result.BlockItems.OfType<SoundBlockItem>().Count()); var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); - Assert.IsFalse(disableDropSoundBlockItem.BooleanValue); + Assert.AreEqual(disableDropSoundBlockItem.Comment, " False"); var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First(); Assert.AreEqual("test.mp3", customSoundBlockItem.Value); @@ -2065,7 +2065,7 @@ namespace Filtration.Parser.Tests.Services " SetBorderColor 255 1 254" + Environment.NewLine + " SetFontSize 50" + Environment.NewLine + " PlayAlertSound 6 90" + Environment.NewLine + - " DisableDropSound True" + Environment.NewLine + + " DisableDropSound" + Environment.NewLine + " MinimapIcon 1 Blue Circle" + Environment.NewLine + " PlayEffect Red Temp" + Environment.NewLine + " CustomAlertSound \"test.mp3\""; @@ -2120,7 +2120,7 @@ namespace Filtration.Parser.Tests.Services _testUtility.TestBlock.BlockItems.Add(new MapTierBlockItem(FilterPredicateOperator.LessThan, 10)); _testUtility.TestBlock.BlockItems.Add(new MapIconBlockItem(IconSize.Medium, IconColor.Blue, IconShape.Circle)); _testUtility.TestBlock.BlockItems.Add(new PlayEffectBlockItem(EffectColor.Red, true)); - _testUtility.TestBlock.BlockItems.Add(new DisableDropSoundBlockItem(true)); + _testUtility.TestBlock.BlockItems.Add(new DisableDropSoundBlockItem()); // Act var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock); diff --git a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs index 5d876f8..bd49bb3 100644 --- a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs +++ b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs @@ -327,7 +327,7 @@ namespace Filtration.Parser.Services // Only ever use the last DisableDropSound item encountered as multiples aren't valid. RemoveExistingBlockItemsOfType<DisableDropSoundBlockItem>(block); - AddBooleanItemToBlockItems<DisableDropSoundBlockItem>(block, trimmedLine); + AddNilItemToBlockItems<DisableDropSoundBlockItem>(block, trimmedLine); break; } case "MinimapIcon": @@ -512,6 +512,13 @@ namespace Filtration.Parser.Services } } + private static void AddNilItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : NilBlockItem + { + var blockItem = Activator.CreateInstance<T>(); + blockItem.Comment = GetTextAfterFirstComment(inputString); + block.BlockItems.Add(blockItem); + } + private static void AddNumericFilterPredicateItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem { var blockItem = Activator.CreateInstance<T>(); diff --git a/Filtration/UserControls/BlockItemControl.xaml b/Filtration/UserControls/BlockItemControl.xaml index 56ab37b..c5ef873 100644 --- a/Filtration/UserControls/BlockItemControl.xaml +++ b/Filtration/UserControls/BlockItemControl.xaml @@ -246,6 +246,13 @@ </userControls:ThemeComponentSelectionControl> </Grid> </DataTemplate> + + <!-- Disable Drop Sound Template --> + <DataTemplate DataType="{x:Type blockItemBaseTypes:NilBlockItem}"> + <Grid> + <TextBlock Text="{Binding Description}" VerticalAlignment="Center" /> + </Grid> + </DataTemplate> </ContentControl.Resources> </ContentControl> </Grid> diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index 14d4cae..cb4e7d1 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -1309,10 +1309,10 @@ namespace Filtration.ViewModels } } - if (input.Count > 0) - { - _scriptCommandManager.ExecuteCommand(new RemoveBlockItemFromBlocksCommand(input)); - SetDirtyFlag(); + if (input.Count > 0) + { + _scriptCommandManager.ExecuteCommand(new RemoveBlockItemFromBlocksCommand(input)); + SetDirtyFlag(); } } @@ -1335,15 +1335,15 @@ namespace Filtration.ViewModels } if (!found) { - var item = new DisableDropSoundBlockItem(true); + var item = new DisableDropSoundBlockItem(); input.Add(new Tuple<ObservableCollection<IItemFilterBlockItem>, IItemFilterBlockItem>(blockItems, item)); } } - if (input.Count > 0) - { + if (input.Count > 0) + { _scriptCommandManager.ExecuteCommand(new AddBlockItemToBlocksCommand(input)); - SetDirtyFlag(); + SetDirtyFlag(); } }