Improve test block for beam feature
This commit is contained in:
parent
2a7df9a1ca
commit
4c76dc9bab
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
public abstract class ColorBooleanBlockItem : BlockItemBase, IAudioVisualBlockItem
|
||||
{
|
||||
private Color _color;
|
||||
private bool _booleanValue;
|
||||
|
||||
protected ColorBooleanBlockItem()
|
||||
{
|
||||
}
|
||||
|
||||
protected ColorBooleanBlockItem(Color color, bool booleanValue)
|
||||
{
|
||||
Color = color;
|
||||
BooleanValue = booleanValue;
|
||||
}
|
||||
|
||||
public override string OutputText => PrefixText + " " + +Color.R + " " + Color.G + " "
|
||||
+ Color.B + (Color.A < 255 ? " " + Color.A : string.Empty) +
|
||||
(BooleanValue ? " True" : " False");
|
||||
|
||||
public override string SummaryText => string.Empty;
|
||||
|
||||
public override Color SummaryBackgroundColor => Colors.Transparent;
|
||||
public override Color SummaryTextColor => Colors.Transparent;
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
IsDirty = true;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool BooleanValue
|
||||
{
|
||||
get { return _booleanValue; }
|
||||
set
|
||||
{
|
||||
_booleanValue = value;
|
||||
IsDirty = true;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,13 +3,13 @@ using Filtration.ObjectModel.BlockItemBaseTypes;
|
|||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
public class BeamBlockItem : ColorBlockItem
|
||||
public class BeamBlockItem : ColorBooleanBlockItem
|
||||
{
|
||||
public BeamBlockItem()
|
||||
{
|
||||
}
|
||||
|
||||
public BeamBlockItem(Color color) : base(color)
|
||||
public BeamBlockItem(Color color, bool booleanValue) : base(color, booleanValue)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<Compile Include="BlockItemBaseTypes\BlockItemBase.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\BooleanBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\ColorBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\ColorBooleanBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\StringBlockItem.cs" />
|
||||
<Compile Include="BlockItemBaseTypes\StringIntBlockItem.cs" />
|
||||
|
|
|
@ -914,7 +914,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
{
|
||||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" BeamColor 255 20 100";
|
||||
" BeamColor 255 20 100 True";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
||||
|
@ -925,6 +925,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
Assert.AreEqual(255, blockItem.Color.R);
|
||||
Assert.AreEqual(20, blockItem.Color.G);
|
||||
Assert.AreEqual(100, blockItem.Color.B);
|
||||
Assert.IsTrue(blockItem.BooleanValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -962,7 +963,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
" PlayAlertSound 3" + Environment.NewLine +
|
||||
" DisableDropSound False" + Environment.NewLine +
|
||||
" Icon Icon2" + Environment.NewLine +
|
||||
" BeamColor 255 100 5" + Environment.NewLine;
|
||||
" BeamColor 255 100 5 false" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
|
||||
|
@ -1075,6 +1076,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
Assert.AreEqual(255, beamBlockItem.Color.R);
|
||||
Assert.AreEqual(100, beamBlockItem.Color.G);
|
||||
Assert.AreEqual(5, beamBlockItem.Color.B);
|
||||
Assert.IsFalse(beamBlockItem.BooleanValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1951,7 +1953,7 @@ namespace Filtration.Parser.Tests.Services
|
|||
" PlayAlertSound 6 90" + Environment.NewLine +
|
||||
" DisableDropSound True";/* + Environment.NewLine +
|
||||
" Icon Icon4";
|
||||
" BeamColor 120 130 140";*/
|
||||
" BeamColor 120 130 140 False";*/
|
||||
|
||||
_testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show));
|
||||
_testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true));
|
||||
|
@ -1996,7 +1998,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 }));
|
||||
_testUtility.TestBlock.BlockItems.Add(new BeamBlockItem(new Color { A = 255, R = 120, G = 130, B = 140 }, false));
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||
|
|
|
@ -308,7 +308,7 @@ namespace Filtration.Parser.Services
|
|||
{
|
||||
var blockItemValue = new IconBlockItem
|
||||
{
|
||||
Value = match.Groups[1].Value,
|
||||
Value = match.Groups[1].Value
|
||||
};
|
||||
block.BlockItems.Add(blockItemValue);
|
||||
}
|
||||
|
@ -319,7 +319,14 @@ namespace Filtration.Parser.Services
|
|||
// Only ever use the last BeamColor item encountered as multiples aren't valid.
|
||||
RemoveExistingBlockItemsOfType<BeamBlockItem>(block);
|
||||
|
||||
AddColorItemToBlockItems<BeamBlockItem>(block, trimmedLine);
|
||||
var result = Regex.Matches(trimmedLine, @"([\w\s]*)(True|False)[#]?(.*)", RegexOptions.IgnoreCase);
|
||||
var color = GetColorFromString(result[0].Groups[1].Value);
|
||||
var beamBlockItem = new BeamBlockItem
|
||||
{
|
||||
Color = GetColorFromString(result[0].Groups[1].Value),
|
||||
BooleanValue = result[0].Groups[2].Value.Trim().ToLowerInvariant() == "true"
|
||||
};
|
||||
block.BlockItems.Add(beamBlockItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,17 @@
|
|||
<userControls:EditableListBoxControl Margin="5,5,5,5" ItemsSource="{Binding Items}" />
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Beam Block Template -->
|
||||
<DataTemplate DataType="{x:Type blockItemTypes:BeamBlockItem}">
|
||||
<StackPanel>
|
||||
<WrapPanel VerticalAlignment="Center" Margin="5,5,5,5">
|
||||
<RadioButton IsChecked="{Binding BooleanValue}" Margin="0,0,10,0">Permanent</RadioButton>
|
||||
<RadioButton IsChecked="{Binding BooleanValue, Converter={StaticResource BoolInverterConverter}}" >Temporary</RadioButton>
|
||||
</WrapPanel>
|
||||
<xctk:ColorPicker SelectedColor="{Binding Color}" AvailableColors="{Binding ElementName=BlockItemContentControl, Path=DataContext.AvailableColors }" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Color Template -->
|
||||
<DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}">
|
||||
<StackPanel>
|
||||
|
|
Loading…
Reference in New Issue