Create a nil value type for DisableDropSound. (#114)
This commit is contained in:
parent
892b2f15f2
commit
2415be089b
|
@ -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; }
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>();
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1335,7 +1335,7 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
|
||||
if (!found) {
|
||||
var item = new DisableDropSoundBlockItem(true);
|
||||
var item = new DisableDropSoundBlockItem();
|
||||
input.Add(new Tuple<ObservableCollection<IItemFilterBlockItem>, IItemFilterBlockItem>(blockItems, item));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue