Add a temporary block type for new beam feature
This commit is contained in:
parent
add7514ce7
commit
2a7df9a1ca
|
@ -0,0 +1,21 @@
|
|||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
public class BeamBlockItem : ColorBlockItem
|
||||
{
|
||||
public BeamBlockItem()
|
||||
{
|
||||
}
|
||||
|
||||
public BeamBlockItem(Color color) : base(color)
|
||||
{
|
||||
}
|
||||
|
||||
public override string PrefixText => "BeamColor";
|
||||
public override int MaximumAllowed => 1;
|
||||
public override string DisplayHeading => "Beam Color";
|
||||
public override int SortOrder => 29;
|
||||
}
|
||||
}
|
|
@ -60,6 +60,7 @@
|
|||
<Compile Include="BlockItemBaseTypes\StringListBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\BackgroundColorBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\BaseTypeBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\BeamBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\BorderColorBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\ClassBlockItem.cs" />
|
||||
<Compile Include="BlockItemTypes\DisableDropSoundBlockItem.cs" />
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Filtration.ObjectModel
|
|||
Color DisplayBorderColor { get; }
|
||||
double DisplayFontSize { get; }
|
||||
string DisplayIcon { get; }
|
||||
Color DisplayBeamColor { get; }
|
||||
bool HasBlockItemOfType<T>();
|
||||
bool HasBlockGroupInParentHierarchy(ItemFilterBlockGroup targetBlockGroup, ItemFilterBlockGroup startingBlockGroup);
|
||||
}
|
||||
|
@ -270,5 +271,14 @@ namespace Filtration.ObjectModel
|
|||
return (displayIcon != null) ? displayIcon.Value : "";
|
||||
}
|
||||
}
|
||||
|
||||
public Color DisplayBeamColor
|
||||
{
|
||||
get
|
||||
{
|
||||
var beamBlockItem = BlockItems.OfType<BeamBlockItem>().FirstOrDefault();
|
||||
return beamBlockItem?.Color ?? new Color { A = 0, R = 0, G = 0, B = 0 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -909,6 +909,24 @@ namespace Filtration.Parser.Tests.Services
|
|||
Assert.AreEqual("Icon1", blockItem.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_BeamColor_ReturnsCorrectObject()
|
||||
{
|
||||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" BeamColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BeamBlockItem));
|
||||
var blockItem = result.BlockItems.OfType<BeamBlockItem>().First();
|
||||
Assert.AreEqual(255, blockItem.Color.R);
|
||||
Assert.AreEqual(20, blockItem.Color.G);
|
||||
Assert.AreEqual(100, blockItem.Color.B);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject()
|
||||
{
|
||||
|
@ -943,7 +961,8 @@ namespace Filtration.Parser.Tests.Services
|
|||
" SetFontSize 50" + Environment.NewLine +
|
||||
" PlayAlertSound 3" + Environment.NewLine +
|
||||
" DisableDropSound False" + Environment.NewLine +
|
||||
" Icon Icon2" + Environment.NewLine;
|
||||
" Icon Icon2" + Environment.NewLine +
|
||||
" BeamColor 255 100 5" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
||||
|
@ -1051,6 +1070,11 @@ namespace Filtration.Parser.Tests.Services
|
|||
|
||||
var iconBlockItem = result.BlockItems.OfType<IconBlockItem>().First();
|
||||
Assert.AreEqual("Icon2", iconBlockItem.Value);
|
||||
|
||||
var beamBlockItem = result.BlockItems.OfType<BeamBlockItem>().First();
|
||||
Assert.AreEqual(255, beamBlockItem.Color.R);
|
||||
Assert.AreEqual(100, beamBlockItem.Color.G);
|
||||
Assert.AreEqual(5, beamBlockItem.Color.B);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1877,6 +1901,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Ignore("Ignore until the new block type is fully implemented")]
|
||||
[Test]
|
||||
public void TranslateItemFilterBlockToString_DropIcon_ReturnsCorrectString()
|
||||
{
|
||||
|
@ -1924,8 +1949,9 @@ 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 True";/* + Environment.NewLine +
|
||||
" Icon Icon4";
|
||||
" BeamColor 120 130 140";*/
|
||||
|
||||
_testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show));
|
||||
_testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true));
|
||||
|
@ -1970,6 +1996,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
_testUtility.TestBlock.BlockItems.Add(new ElderMapBlockItem(true));
|
||||
_testUtility.TestBlock.BlockItems.Add(new DisableDropSoundBlockItem(true));
|
||||
_testUtility.TestBlock.BlockItems.Add(new IconBlockItem("Icon4"));
|
||||
_testUtility.TestBlock.BlockItems.Add(new BeamBlockItem(new Color { A = 255, R = 120, G = 130, B = 140 }));
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
|
|
@ -314,6 +314,14 @@ namespace Filtration.Parser.Services
|
|||
}
|
||||
break;
|
||||
}
|
||||
case "BeamColor":
|
||||
{
|
||||
// Only ever use the last BeamColor item encountered as multiples aren't valid.
|
||||
RemoveExistingBlockItemsOfType<BeamBlockItem>(block);
|
||||
|
||||
AddColorItemToBlockItems<BeamBlockItem>(block, trimmedLine);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -587,8 +595,8 @@ namespace Filtration.Parser.Services
|
|||
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||
foreach (var blockItem in block.BlockItems.Where(b => b.GetType() != typeof(ActionBlockItem)).OrderBy(b => b.SortOrder))
|
||||
{
|
||||
// Do not save temporary block until the new feature is fully implemented
|
||||
if (blockItem is IconBlockItem)
|
||||
// Do not save temporary blocks until the new features are fully implemented
|
||||
if (blockItem is IconBlockItem || blockItem is BeamBlockItem)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -175,7 +175,8 @@ namespace Filtration.ViewModels
|
|||
typeof (SoundBlockItem),
|
||||
typeof (PositionalSoundBlockItem),
|
||||
typeof (DisableDropSoundBlockItem),
|
||||
typeof (IconBlockItem)
|
||||
typeof (IconBlockItem),
|
||||
typeof (BeamBlockItem)
|
||||
};
|
||||
|
||||
public bool BlockEnabled
|
||||
|
@ -216,6 +217,7 @@ namespace Filtration.ViewModels
|
|||
public Color DisplayBorderColor => Block.DisplayBorderColor;
|
||||
public double DisplayFontSize => Block.DisplayFontSize/1.8;
|
||||
public string DisplayIcon => Block.DisplayIcon;
|
||||
public Color DisplayBeamColor => Block.DisplayBeamColor;
|
||||
|
||||
public bool HasSound => Block.HasBlockItemOfType<SoundBlockItem>();
|
||||
public bool HasPositionalSound => Block.HasBlockItemOfType<PositionalSoundBlockItem>();
|
||||
|
@ -440,6 +442,7 @@ namespace Filtration.ViewModels
|
|||
RaisePropertyChanged(nameof(DisplayBorderColor));
|
||||
RaisePropertyChanged(nameof(DisplayFontSize));
|
||||
RaisePropertyChanged(nameof(DisplayIcon));
|
||||
RaisePropertyChanged(nameof(DisplayBeamColor));
|
||||
RaisePropertyChanged(nameof(HasSound));
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,12 @@
|
|||
|
||||
<!-- Item Preview Box -->
|
||||
<WrapPanel Grid.Row="0" Grid.Column="2" VerticalAlignment="Center">
|
||||
<Image Source="{Binding DisplayIcon, Converter={StaticResource DropIconConverter}, Mode=OneWay}" Width="30" Height="30" />
|
||||
<Image Source="{Binding DisplayIcon, Converter={StaticResource DropIconConverter}, Mode=OneWay}" Width="30" Height="30" Margin="0,0,10,0" />
|
||||
<Line Y2="41" StrokeThickness="2" Stroke="{Binding DisplayBeamColor, Converter={StaticResource ColorToSolidColorBrushConverter}, Mode=OneWay}" Margin="0,2,10,0" >
|
||||
<Line.Effect>
|
||||
<DropShadowEffect BlurRadius="5" ShadowDepth="0" Color="{Binding DisplayBeamColor, Mode=OneWay}" Direction="0"/>
|
||||
</Line.Effect>
|
||||
</Line>
|
||||
<Button Command="{Binding PlaySoundCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
|
|
Loading…
Reference in New Issue