Add DisableDropSound block type

This commit is contained in:
azakhi 2018-08-20 21:19:18 +03:00
parent 738415f10a
commit 2c4096ff2c
5 changed files with 60 additions and 4 deletions

View File

@ -0,0 +1,23 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.ObjectModel.BlockItemTypes
{
public sealed class DisableDropSoundBlockItem : BooleanBlockItem, IAudioVisualBlockItem
{
public DisableDropSoundBlockItem()
{
}
public DisableDropSoundBlockItem(bool booleanValue) : base(booleanValue)
{
}
public override string PrefixText => "DisableDropSound";
public override string DisplayHeading => "Disable Drop Sound";
public override Color SummaryBackgroundColor => Colors.Transparent;
public override Color SummaryTextColor => Colors.Transparent;
public override int SortOrder => 27;
}
}

View File

@ -61,6 +61,7 @@
<Compile Include="BlockItemTypes\BaseTypeBlockItem.cs" />
<Compile Include="BlockItemTypes\BorderColorBlockItem.cs" />
<Compile Include="BlockItemTypes\ClassBlockItem.cs" />
<Compile Include="BlockItemTypes\DisableDropSoundBlockItem.cs" />
<Compile Include="BlockItemTypes\ElderMapBlockItem.cs" />
<Compile Include="BlockItemTypes\GemLevelBlockItem.cs" />
<Compile Include="BlockItemTypes\HasExplicitModBlockItem.cs" />

View File

@ -875,6 +875,23 @@ namespace Filtration.Parser.Tests.Services
Assert.AreEqual(95, blockItem.SecondValue);
}
[Test]
public void TranslateStringToItemFilterBlock_DisableDropSound_ReturnsCorrectObject()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" DisableDropSound True";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is DisableDropSoundBlockItem));
var blockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
Assert.IsTrue(blockItem.BooleanValue);
}
[Test]
public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject()
{
@ -907,7 +924,8 @@ namespace Filtration.Parser.Tests.Services
" SetBackgroundColor 255 100 5" + Environment.NewLine +
" SetBorderColor 0 0 0" + Environment.NewLine +
" SetFontSize 50" + Environment.NewLine +
" PlayAlertSound 3" + Environment.NewLine;
" PlayAlertSound 3" + Environment.NewLine +
" DisableDropSound False" + Environment.NewLine;
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
@ -1009,6 +1027,9 @@ namespace Filtration.Parser.Tests.Services
var soundblockItem = result.BlockItems.OfType<SoundBlockItem>().First();
Assert.AreEqual("3", soundblockItem.Value);
Assert.AreEqual(79, soundblockItem.SecondValue);
var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
Assert.IsFalse(disableDropSoundBlockItem.BooleanValue);
}
[Test]
@ -1861,7 +1882,8 @@ namespace Filtration.Parser.Tests.Services
" SetBackgroundColor 0 0 0" + Environment.NewLine +
" SetBorderColor 255 1 254" + Environment.NewLine +
" SetFontSize 50" + Environment.NewLine +
" PlayAlertSound 6 90";
" PlayAlertSound 6 90" + Environment.NewLine +
" DisableDropSound True";
_testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show));
_testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true));
@ -1904,6 +1926,7 @@ namespace Filtration.Parser.Tests.Services
_testUtility.TestBlock.BlockItems.Add(new ShaperItemBlockItem(false));
_testUtility.TestBlock.BlockItems.Add(new ShapedMapBlockItem(true));
_testUtility.TestBlock.BlockItems.Add(new ElderMapBlockItem(true));
_testUtility.TestBlock.BlockItems.Add(new DisableDropSoundBlockItem(true));
// Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);

View File

@ -286,6 +286,14 @@ namespace Filtration.Parser.Services
AddBooleanItemToBlockItems<ElderMapBlockItem>(block, trimmedLine);
break;
}
case "DisableDropSound":
{
// Only ever use the last DisableDropSound item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<DisableDropSoundBlockItem>(block);
AddBooleanItemToBlockItems<DisableDropSoundBlockItem>(block, trimmedLine);
break;
}
}
}

View File

@ -173,7 +173,8 @@ namespace Filtration.ViewModels
typeof (BorderColorBlockItem),
typeof (FontSizeBlockItem),
typeof (SoundBlockItem),
typeof (PositionalSoundBlockItem)
typeof (PositionalSoundBlockItem),
typeof (DisableDropSoundBlockItem)
};
public bool BlockEnabled