18 Commits
0.18 ... 0.20

Author SHA1 Message Date
Ben Wallis
1e26a2ae3e Merge pull request #62 from GlenCFL/fix-reopen
Fix the reading of CustomAlertSounds containing path separators.
2018-09-01 09:57:54 +01:00
GlenCFL
54b72e44b0 Reposition the new custom sound tests. 2018-08-31 21:06:51 -04:00
GlenCFL
24df1d7687 Fix the reading of CustomAlertSounds containing path separators. 2018-08-31 20:01:21 -04:00
Ben Wallis
7162e16b49 Merge pull request #59 from azakhi/improvements
Improvements
2018-08-31 15:28:18 +01:00
azakhi
324ce4d0b3 Fix binding problem 2018-08-31 17:05:21 +03:00
azakhi
de489e8b2c Fix folder bug 2018-08-31 16:54:24 +03:00
azakhi
341b1d1eb2 Make section header parsing more generic 2018-08-31 16:13:57 +03:00
azakhi
6be29dbd28 Add tests and fix theme bug 2018-08-31 16:02:17 +03:00
azakhi
3851ad51e1 Add support for comments between rules 2018-08-31 14:22:26 +03:00
azakhi
65d3e07156 Add comment support for all rule types 2018-08-31 11:21:43 +03:00
azakhi
a86ab3ec8d Use available sounds as combobox source 2018-08-31 09:40:48 +03:00
azakhi
41722e8a57 Update icons 2018-08-31 09:00:31 +03:00
Ben Wallis
3cb0a041d7 Update README.md 2018-08-30 19:31:45 +01:00
Ben Wallis
c8778bb1eb bumped version to 0.19 2018-08-30 19:28:32 +01:00
Ben Wallis
8e849d6a8f Merge pull request #57 from azakhi/master
Fix play effect parsing bug
2018-08-30 19:26:37 +01:00
azakhi
0d3f01a856 Update item classes 2018-08-30 21:23:34 +03:00
azakhi
178ff579c6 Fix PlayEffect parsing 2018-08-30 21:22:20 +03:00
Ben Wallis
30aa52e788 updated Delve Socketable Currency in ItemClasses 2018-08-30 19:20:44 +01:00
24 changed files with 639 additions and 316 deletions

View File

@@ -27,8 +27,6 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
} }
} }
public string Comment { get; set; }
public override string OutputText => Action.GetAttributeDescription(); public override string OutputText => Action.GetAttributeDescription();
public override string PrefixText => string.Empty; public override string PrefixText => string.Empty;

View File

@@ -17,6 +17,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
public abstract Color SummaryBackgroundColor { get; } public abstract Color SummaryBackgroundColor { get; }
public abstract Color SummaryTextColor { get; } public abstract Color SummaryTextColor { get; }
public abstract int SortOrder { get; } public abstract int SortOrder { get; }
public string Comment { get; set; }
public bool IsDirty public bool IsDirty
{ {

View File

@@ -4,6 +4,6 @@ namespace Filtration.ObjectModel
{ {
public interface IBlockItemWithTheme : IItemFilterBlockItem public interface IBlockItemWithTheme : IItemFilterBlockItem
{ {
ThemeComponent ThemeComponent { get; } ThemeComponent ThemeComponent { get; set; }
} }
} }

View File

@@ -14,5 +14,6 @@ namespace Filtration.ObjectModel
int MaximumAllowed { get; } int MaximumAllowed { get; }
int SortOrder { get; } int SortOrder { get; }
bool IsDirty { get; } bool IsDirty { get; }
string Comment { get; set; }
} }
} }

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using Microsoft.Win32; using Microsoft.Win32;
@@ -25,13 +26,34 @@ namespace Filtration.ObjectModel.ThemeEditor
if (_customSoundsAvailable == null || _customSoundsAvailable.Count < 1) if (_customSoundsAvailable == null || _customSoundsAvailable.Count < 1)
{ {
_customSoundsAvailable = new ObservableCollection<string> {
"1maybevaluable.mp3", "2currency.mp3", "3uniques.mp3", "4maps.mp3", "5highmaps.mp3", _customSoundsAvailable = new ObservableCollection<string>();
"6veryvaluable.mp3", "7chancing.mp3", "12leveling.mp3", "placeholder.mp3"
}; var poeFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\";
if(System.IO.Directory.Exists(poeFolderPath))
{
var poeFolderFiles = System.IO.Directory.GetFiles(poeFolderPath).Where(
s => s.EndsWith(".mp3")
|| s.EndsWith(".wav")
|| s.EndsWith(".wma")
|| s.EndsWith(".3gp")
|| s.EndsWith(".aag")
|| s.EndsWith(".m4a")
|| s.EndsWith(".ogg")
).OrderBy(f => f);
foreach (var file in poeFolderFiles)
{
_customSoundsAvailable.Add(file.Replace(poeFolderPath, ""));
}
}
} }
if (_customSoundsAvailable.IndexOf(Value) < 0) if(string.IsNullOrWhiteSpace(Value))
{
Value = _customSoundsAvailable.Count > 0 ? _customSoundsAvailable[0] : "";
}
else if (_customSoundsAvailable.IndexOf(Value) < 0)
{ {
_customSoundsAvailable.Add(Value); _customSoundsAvailable.Add(Value);
} }

View File

@@ -94,7 +94,7 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var inputString = "HideDisabled" + Environment.NewLine + var inputString = "HideDisabled" + Environment.NewLine +
" ItemLevel >= 55"; " ItemLevel >= 55";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
@@ -372,71 +372,89 @@ namespace Filtration.Parser.Tests.Services
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_ElderItem_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_ElderItem_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ElderItem False"; " ElderItem False";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderItemBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderItemBlockItem));
var blockItem = result.BlockItems.OfType<ElderItemBlockItem>().First(); var blockItem = result.BlockItems.OfType<ElderItemBlockItem>().First();
Assert.IsFalse(blockItem.BooleanValue); Assert.IsFalse(blockItem.BooleanValue);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_ShaperItem_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_ShaperItem_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ShaperItem True"; " ShaperItem True";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ShaperItemBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ShaperItemBlockItem));
var blockItem = result.BlockItems.OfType<ShaperItemBlockItem>().First(); var blockItem = result.BlockItems.OfType<ShaperItemBlockItem>().First();
Assert.IsTrue(blockItem.BooleanValue); Assert.IsTrue(blockItem.BooleanValue);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_MapTier_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ShapedMap false"; " MapTier >= 15";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ShapedMapBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is MapTierBlockItem));
var blockItem = result.BlockItems.OfType<ShapedMapBlockItem>().First(); var blockItem = result.BlockItems.OfType<MapTierBlockItem>().First();
Assert.IsFalse(blockItem.BooleanValue); Assert.AreEqual(15, blockItem.FilterPredicate.PredicateOperand);
Assert.AreEqual(FilterPredicateOperator.GreaterThanOrEqual, blockItem.FilterPredicate.PredicateOperator);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_ElderMap_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ElderMap false"; " ShapedMap false";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderMapBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ShapedMapBlockItem));
var blockItem = result.BlockItems.OfType<ElderMapBlockItem>().First(); var blockItem = result.BlockItems.OfType<ShapedMapBlockItem>().First();
Assert.IsFalse(blockItem.BooleanValue); Assert.IsFalse(blockItem.BooleanValue);
}
[Test]
public void TranslateStringToItemFilterBlock_ElderMap_ReturnsCorrectObject()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" ElderMap false";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderMapBlockItem));
var blockItem = result.BlockItems.OfType<ElderMapBlockItem>().First();
Assert.IsFalse(blockItem.BooleanValue);
} }
[Test] [Test]
@@ -775,7 +793,7 @@ namespace Filtration.Parser.Tests.Services
" SetTextColor 255 20 100 # Rare Item Text"; " SetTextColor 255 20 100 # Rare Item Text";
var testComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100}); var testComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent }; var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, Mock.Of<IItemFilterScript>(i => i.ItemFilterScriptSettings.ThemeComponentCollection == testInputThemeComponentCollection)); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, Mock.Of<IItemFilterScript>(i => i.ItemFilterScriptSettings.ThemeComponentCollection == testInputThemeComponentCollection));
@@ -876,22 +894,22 @@ namespace Filtration.Parser.Tests.Services
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_DisableDropSound_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_DisableDropSound_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" DisableDropSound True"; " DisableDropSound True";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is DisableDropSoundBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is DisableDropSoundBlockItem));
var blockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); var blockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
Assert.IsTrue(blockItem.BooleanValue); Assert.IsTrue(blockItem.BooleanValue);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject()
{ {
@@ -925,7 +943,10 @@ namespace Filtration.Parser.Tests.Services
" SetBorderColor 0 0 0" + Environment.NewLine + " SetBorderColor 0 0 0" + Environment.NewLine +
" SetFontSize 50" + Environment.NewLine + " SetFontSize 50" + Environment.NewLine +
" PlayAlertSound 3" + 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;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
@@ -1024,12 +1045,40 @@ namespace Filtration.Parser.Tests.Services
var fontSizeblockItem = result.BlockItems.OfType<FontSizeBlockItem>().First(); var fontSizeblockItem = result.BlockItems.OfType<FontSizeBlockItem>().First();
Assert.AreEqual(50, fontSizeblockItem.Value); Assert.AreEqual(50, fontSizeblockItem.Value);
var soundblockItem = result.BlockItems.OfType<SoundBlockItem>().First(); Assert.AreEqual(0, result.BlockItems.OfType<SoundBlockItem>().Count());
Assert.AreEqual("3", soundblockItem.Value);
Assert.AreEqual(79, soundblockItem.SecondValue);
var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
Assert.IsFalse(disableDropSoundBlockItem.BooleanValue); Assert.IsFalse(disableDropSoundBlockItem.BooleanValue);
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("test.mp3", customSoundBlockItem.Value);
Assert.AreNotEqual(null, customSoundBlockItem.ThemeComponent);
Assert.AreEqual(ThemeComponentType.CustomSound, customSoundBlockItem.ThemeComponent.ComponentType);
Assert.AreEqual("customSoundTheme", customSoundBlockItem.ThemeComponent.ComponentName);
Assert.AreEqual(typeof(StringThemeComponent), customSoundBlockItem.ThemeComponent.GetType());
Assert.AreEqual("test.mp3", ((StringThemeComponent)customSoundBlockItem.ThemeComponent).Value);
var mapIconBlockItem = result.BlockItems.OfType<MapIconBlockItem>().First();
Assert.AreEqual(IconSize.Small, mapIconBlockItem.Size);
Assert.AreEqual(IconColor.Green, mapIconBlockItem.Color);
Assert.AreEqual(IconShape.Triangle, mapIconBlockItem.Shape);
Assert.AreNotEqual(null, mapIconBlockItem.ThemeComponent);
Assert.AreEqual(ThemeComponentType.Icon, mapIconBlockItem.ThemeComponent.ComponentType);
Assert.AreEqual("iconTheme", mapIconBlockItem.ThemeComponent.ComponentName);
Assert.AreEqual(typeof(IconThemeComponent), mapIconBlockItem.ThemeComponent.GetType());
Assert.AreEqual(IconSize.Small, ((IconThemeComponent)mapIconBlockItem.ThemeComponent).IconSize);
Assert.AreEqual(IconColor.Green, ((IconThemeComponent)mapIconBlockItem.ThemeComponent).IconColor);
Assert.AreEqual(IconShape.Triangle, ((IconThemeComponent)mapIconBlockItem.ThemeComponent).IconShape);
var effectColorBlockItem = result.BlockItems.OfType<EffectColorBlockItem>().First();
Assert.AreEqual(EffectColor.Green, effectColorBlockItem.Color);
Assert.IsTrue(effectColorBlockItem.Temporary);
Assert.AreNotEqual(null, effectColorBlockItem.ThemeComponent);
Assert.AreEqual(ThemeComponentType.Effect, effectColorBlockItem.ThemeComponent.ComponentType);
Assert.AreEqual("effectTheme", effectColorBlockItem.ThemeComponent.ComponentName);
Assert.AreEqual(typeof(EffectColorThemeComponent), effectColorBlockItem.ThemeComponent.GetType());
Assert.AreEqual(EffectColor.Green, ((EffectColorThemeComponent)effectColorBlockItem.ThemeComponent).EffectColor);
Assert.IsTrue(((EffectColorThemeComponent)effectColorBlockItem.ThemeComponent).Temporary);
} }
[Test] [Test]
@@ -1038,9 +1087,9 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ItemLevel >= 70" + Environment.NewLine + " ItemLevel >= 70" + Environment.NewLine +
" ItemLevel <= 80" + Environment.NewLine + " ItemLevel <= 80" + Environment.NewLine +
" Quality = 15" + Environment.NewLine + " Quality = 15" + Environment.NewLine +
" Quality < 17"; " Quality < 17";
// Act // Act
@@ -1101,7 +1150,7 @@ namespace Filtration.Parser.Tests.Services
var blockItem = result.BlockItems.OfType<FontSizeBlockItem>().First(); var blockItem = result.BlockItems.OfType<FontSizeBlockItem>().First();
Assert.AreEqual(27, blockItem.Value); Assert.AreEqual(27, blockItem.Value);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_MultipleSoundItems_OnlyLastOneUsed() public void TranslateStringToItemFilterBlock_MultipleSoundItems_OnlyLastOneUsed()
{ {
@@ -1257,6 +1306,86 @@ namespace Filtration.Parser.Tests.Services
Assert.AreEqual(ItemRarity.Magic, (ItemRarity)rarityBlockItem.FilterPredicate.PredicateOperand); Assert.AreEqual(ItemRarity.Magic, (ItemRarity)rarityBlockItem.FilterPredicate.PredicateOperand);
} }
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundDocumentsFile()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"test.mp3\"";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("test.mp3", customSoundBlockItem.Value);
}
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundDocumentsRelativeFile()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"Sounds\test.mp3\"";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("Sounds\test.mp3", customSoundBlockItem.Value);
}
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundFullBackSlashPath()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"C:\\Sounds\\test.mp3\"";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("C:\\Sounds\\test.mp3", customSoundBlockItem.Value);
}
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundFullForwardSlashPath()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"C:/Sounds/test.mp3\"";
//Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("C:/Sounds/test.mp3", customSoundBlockItem.Value);
}
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundFullMixedPath()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"C:\\Sounds/test.mp3\"";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("C:\\Sounds/test.mp3", customSoundBlockItem.Value);
}
[Test] [Test]
public void TranslateItemFilterBlockToString_NothingPopulated_ReturnsCorrectString() public void TranslateItemFilterBlockToString_NothingPopulated_ReturnsCorrectString()
{ {
@@ -1277,13 +1406,13 @@ namespace Filtration.Parser.Tests.Services
{ {
// Arrange // Arrange
var expectedResult = "Show # Child 1 Block Group - Child 2 Block Group"; var expectedResult = "Show # Child 1 Block Group - Child 2 Block Group";
var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null); var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup); var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup);
var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup); var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup);
_testUtility.TestBlock.BlockGroup = child2BlockGroup; _testUtility.TestBlock.BlockGroup = child2BlockGroup;
// TODO: Shouldn't be set to edited this way // TODO: Shouldn't be set to edited this way
_testUtility.TestBlock.IsEdited = true; _testUtility.TestBlock.IsEdited = true;
// Act // Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock); var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
@@ -1802,7 +1931,7 @@ namespace Filtration.Parser.Tests.Services
{ {
// Arrange // Arrange
var expectedResult = "Show" + Environment.NewLine + var expectedResult = "Show" + Environment.NewLine +
" ItemLevel > 56" + Environment.NewLine + " ItemLevel > 56" + Environment.NewLine +
" ItemLevel >= 45" + Environment.NewLine + " ItemLevel >= 45" + Environment.NewLine +
" ItemLevel < 100"; " ItemLevel < 100";
@@ -1844,7 +1973,7 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var expectedResult = "#Show" + Environment.NewLine + var expectedResult = "#Show" + Environment.NewLine +
"# Width = 4"; "# Width = 4";
_testUtility.TestBlock.Enabled = false; _testUtility.TestBlock.Enabled = false;
_testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4)); _testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4));
@@ -1891,7 +2020,7 @@ namespace Filtration.Parser.Tests.Services
" DisableDropSound True" + Environment.NewLine + " DisableDropSound True" + Environment.NewLine +
" MinimapIcon 1 Blue Circle" + Environment.NewLine + " MinimapIcon 1 Blue Circle" + Environment.NewLine +
" PlayEffect Red Temp" + Environment.NewLine + " PlayEffect Red Temp" + Environment.NewLine +
" CustomAlertSound \"test.mp3\""; " CustomAlertSound \"test.mp3\"";
_testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show)); _testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show));
_testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true)); _testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true));
@@ -1959,7 +2088,7 @@ namespace Filtration.Parser.Tests.Services
// Act // Act
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString); _testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
// Assert // Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem; var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem); Assert.IsNotNull(textColorBlockItem);
@@ -2034,7 +2163,7 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine + var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine + "SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
"SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine + "SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine +
"PlayAlertSound 7 280"; "PlayAlertSound 7 280";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>(); var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
@@ -2080,9 +2209,9 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine + var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine + "SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
"SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine + "SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine +
"PlayAlertSound 7 280"; "PlayAlertSound 7 280";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>(); var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
// Act // Act
@@ -2152,9 +2281,9 @@ namespace Filtration.Parser.Tests.Services
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString); _testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
// Assert // Assert
} }
private class ItemFilterBlockTranslatorTestUtility private class ItemFilterBlockTranslatorTestUtility
{ {
public ItemFilterBlockTranslatorTestUtility() public ItemFilterBlockTranslatorTestUtility()

View File

@@ -285,13 +285,11 @@ namespace Filtration.Parser.Tests.Services
" ItemLevel > 2" + Environment.NewLine + " ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine + " SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine + Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine + "#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine + "# ItemLevel > 2" + Environment.NewLine +
"# SetTextColor 255 215 0" + Environment.NewLine + "# SetTextColor 255 215 0" + Environment.NewLine +
"# SetBorderColor 255 105 180" + Environment.NewLine + "# SetBorderColor 255 105 180" + Environment.NewLine +
"# SetFontSize 32" + Environment.NewLine + "# SetFontSize 32" + Environment.NewLine +
"#Disabled Block End" + Environment.NewLine +
Environment.NewLine + Environment.NewLine +
"Show" + Environment.NewLine + "Show" + Environment.NewLine +
" ItemLevel > 20" + Environment.NewLine + " ItemLevel > 20" + Environment.NewLine +
@@ -316,13 +314,11 @@ namespace Filtration.Parser.Tests.Services
" ItemLevel > 2" + Environment.NewLine + " ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine + " SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine + Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine + "#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine + "# ItemLevel > 2" + Environment.NewLine +
"# SetTextColor 255 215 0" + Environment.NewLine + "# SetTextColor 255 215 0" + Environment.NewLine +
"# SetBorderColor 255 105 180" + Environment.NewLine + "# SetBorderColor 255 105 180" + Environment.NewLine +
"# SetFontSize 32" + Environment.NewLine + "# SetFontSize 32" + Environment.NewLine +
"#Disabled Block End" + Environment.NewLine +
Environment.NewLine + Environment.NewLine +
"Show" + Environment.NewLine + "Show" + Environment.NewLine +
" ItemLevel > 20" + Environment.NewLine + " ItemLevel > 20" + Environment.NewLine +
@@ -355,11 +351,9 @@ namespace Filtration.Parser.Tests.Services
" ItemLevel > 2" + Environment.NewLine + " ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine + " SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine + Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"# This is a disabled block" + Environment.NewLine + "# This is a disabled block" + Environment.NewLine +
"#Show" + Environment.NewLine + "#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine + "# ItemLevel > 2";
"#Disabled Block End";
var blockTranslator = new ItemFilterBlockTranslator(Mock.Of<IBlockGroupHierarchyBuilder>()); var blockTranslator = new ItemFilterBlockTranslator(Mock.Of<IBlockGroupHierarchyBuilder>());
@@ -384,11 +378,9 @@ namespace Filtration.Parser.Tests.Services
" ItemLevel > 2" + Environment.NewLine + " ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine + " SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine + Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"# This is a disabled block" + Environment.NewLine + "# This is a disabled block" + Environment.NewLine +
"#Show#My Block Group" + Environment.NewLine + "#Show#My Block Group" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine + "# ItemLevel > 2";
"#Disabled Block End";
var mockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>(); var mockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();

View File

@@ -39,6 +39,7 @@
<HintPath>..\packages\Castle.Windsor.3.4.0\lib\net45\Castle.Windsor.dll</HintPath> <HintPath>..\packages\Castle.Windsor.3.4.0\lib\net45\Castle.Windsor.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />

View File

@@ -41,13 +41,13 @@ namespace Filtration.Parser.Services
itemFilterCommentBlock.Comment += trimmedLine + Environment.NewLine; itemFilterCommentBlock.Comment += trimmedLine + Environment.NewLine;
} }
itemFilterCommentBlock.Comment = itemFilterCommentBlock.Comment.TrimEnd('\r', '\n'); itemFilterCommentBlock.Comment = itemFilterCommentBlock.Comment.TrimEnd('\r', '\n');
itemFilterCommentBlock.IsEdited = false; itemFilterCommentBlock.IsEdited = false;
return itemFilterCommentBlock; return itemFilterCommentBlock;
} }
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks // This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
// and reading ItemFilterScripts from a file. // and reading ItemFilterScripts from a file.
public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "", bool initialiseBlockGroupHierarchyBuilder = false) public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IItemFilterScript parentItemFilterScript, string originalString = "", bool initialiseBlockGroupHierarchyBuilder = false)
{ {
@@ -63,13 +63,35 @@ namespace Filtration.Parser.Services
foreach (var line in new LineReader(() => new StringReader(inputString))) foreach (var line in new LineReader(() => new StringReader(inputString)))
{ {
if (line.StartsWith(@"#") && !showHideFound) if (line.StartsWith(@"#"))
{ {
block.Description = line.TrimStart('#').TrimStart(' '); if(!showHideFound)
{
block.Description = line.TrimStart('#').TrimStart(' ');
}
else
{
if(block.BlockItems.Count > 1)
{
block.BlockItems.Last().Comment += Environment.NewLine + line.TrimStart('#');
}
else
{
block.ActionBlockItem.Comment += Environment.NewLine + line.TrimStart('#');
}
}
continue; continue;
} }
var trimmedLine = line.Trim(); var fullLine = line.Trim();
var trimmedLine = fullLine;
var blockComment = "";
var themeComponentType = -1;
if(trimmedLine.IndexOf('#') > 0)
{
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
}
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length; var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos); var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
@@ -88,11 +110,11 @@ namespace Filtration.Parser.Services
// group hierarchy, if block groups are disabled it is preserved as a simple text comment. // group hierarchy, if block groups are disabled it is preserved as a simple text comment.
if (parentItemFilterScript.ItemFilterScriptSettings.BlockGroupsEnabled) if (parentItemFilterScript.ItemFilterScriptSettings.BlockGroupsEnabled)
{ {
AddBlockGroupToBlock(block, trimmedLine); AddBlockGroupToBlock(block, fullLine);
} }
else else
{ {
block.ActionBlockItem.Comment = GetTextAfterFirstComment(trimmedLine); block.ActionBlockItem.Comment = GetTextAfterFirstComment(fullLine);
} }
break; break;
} }
@@ -193,7 +215,12 @@ namespace Filtration.Parser.Services
// Only ever use the last SetTextColor item encountered as multiples aren't valid. // Only ever use the last SetTextColor item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<TextColorBlockItem>(block); RemoveExistingBlockItemsOfType<TextColorBlockItem>(block);
AddColorItemToBlockItems<TextColorBlockItem>(block, trimmedLine); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new TextColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.TextColor;
break; break;
} }
case "SetBackgroundColor": case "SetBackgroundColor":
@@ -201,7 +228,12 @@ namespace Filtration.Parser.Services
// Only ever use the last SetBackgroundColor item encountered as multiples aren't valid. // Only ever use the last SetBackgroundColor item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<BackgroundColorBlockItem>(block); RemoveExistingBlockItemsOfType<BackgroundColorBlockItem>(block);
AddColorItemToBlockItems<BackgroundColorBlockItem>(block, trimmedLine); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BackgroundColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.BackgroundColor;
break; break;
} }
case "SetBorderColor": case "SetBorderColor":
@@ -209,7 +241,12 @@ namespace Filtration.Parser.Services
// Only ever use the last SetBorderColor item encountered as multiples aren't valid. // Only ever use the last SetBorderColor item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<BorderColorBlockItem>(block); RemoveExistingBlockItemsOfType<BorderColorBlockItem>(block);
AddColorItemToBlockItems<BorderColorBlockItem>(block, trimmedLine); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BorderColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.BorderColor;
break; break;
} }
case "SetFontSize": case "SetFontSize":
@@ -217,15 +254,12 @@ namespace Filtration.Parser.Services
// Only ever use the last SetFontSize item encountered as multiples aren't valid. // Only ever use the last SetFontSize item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<FontSizeBlockItem>(block); RemoveExistingBlockItemsOfType<FontSizeBlockItem>(block);
var match = Regex.Matches(trimmedLine, @"(\s+(\d+)\s*)([#]?)(.*)"); var match = Regex.Matches(trimmedLine, @"(\s+(\d+)\s*)");
if (match.Count > 0) if (match.Count > 0)
{ {
var blockItem = new FontSizeBlockItem(Convert.ToInt16(match[0].Groups[2].Value)); var blockItem = new FontSizeBlockItem(Convert.ToInt16(match[0].Groups[2].Value));
if(match[0].Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match[0].Groups[4].Value))
{
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize, match[0].Groups[4].Value.Trim(), blockItem.Value);
}
block.BlockItems.Add(blockItem); block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.FontSize;
} }
break; break;
} }
@@ -237,49 +271,42 @@ namespace Filtration.Parser.Services
RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block); RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block);
RemoveExistingBlockItemsOfType<CustomSoundBlockItem>(block); RemoveExistingBlockItemsOfType<CustomSoundBlockItem>(block);
var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?\s*([#]?)(.*)"); var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?");
if (match.Success) if (match.Success)
{ {
string firstValue = match.Groups[1].Value; string firstValue = match.Groups[1].Value;
int secondValue; int secondValue;
if (match.Groups[2].Success) if (match.Groups[2].Success)
{ {
secondValue = Convert.ToInt16(match.Groups[2].Value); secondValue = Convert.ToInt16(match.Groups[2].Value);
} }
else else
{ {
secondValue = 79; secondValue = 79;
} }
ThemeComponent themeComponent = null; if (lineOption == "PlayAlertSound")
if(match.Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[4].Value)) {
{ var blockItemValue = new SoundBlockItem
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, match.Groups[4].Value.Trim(), firstValue, secondValue); {
} Value = firstValue,
SecondValue = secondValue
if (lineOption == "PlayAlertSound") };
{ block.BlockItems.Add(blockItemValue);
var blockItemValue = new SoundBlockItem }
{ else
Value = firstValue, {
SecondValue = secondValue var blockItemValue = new PositionalSoundBlockItem
}; {
blockItemValue.ThemeComponent = themeComponent; Value = firstValue,
block.BlockItems.Add(blockItemValue); SecondValue = secondValue
} };
else block.BlockItems.Add(blockItemValue);
{ }
var blockItemValue = new PositionalSoundBlockItem themeComponentType = (int)ThemeComponentType.AlertSound;
{ }
Value = firstValue,
SecondValue = secondValue
};
blockItemValue.ThemeComponent = themeComponent;
block.BlockItems.Add(blockItemValue);
}
}
break; break;
} }
case "GemLevel": case "GemLevel":
@@ -314,54 +341,49 @@ namespace Filtration.Parser.Services
{ {
// Only ever use the last Icon item encountered as multiples aren't valid. // Only ever use the last Icon item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<MapIconBlockItem>(block); RemoveExistingBlockItemsOfType<MapIconBlockItem>(block);
// TODO: Get size, color, shape values programmatically // TODO: Get size, color, shape values programmatically
var match = Regex.Match(trimmedLine, var match = Regex.Match(trimmedLine,
@"\S+\s+(0|1|2)\s+(Red|Green|Blue|Brown|White|Yellow)\s+(Circle|Diamond|Hexagon|Square|Star|Triangle)\s*([#]?)(.*)", @"\S+\s+(0|1|2)\s+(Red|Green|Blue|Brown|White|Yellow)\s+(Circle|Diamond|Hexagon|Square|Star|Triangle)\s*([#]?)(.*)",
RegexOptions.IgnoreCase); RegexOptions.IgnoreCase);
if (match.Success) if (match.Success)
{ {
var blockItemValue = new MapIconBlockItem var blockItemValue = new MapIconBlockItem
{ {
Size = (IconSize)Int16.Parse(match.Groups[1].Value), Size = (IconSize)Int16.Parse(match.Groups[1].Value),
Color = EnumHelper.GetEnumValueFromDescription<IconColor>(match.Groups[2].Value), Color = EnumHelper.GetEnumValueFromDescription<IconColor>(match.Groups[2].Value),
Shape = EnumHelper.GetEnumValueFromDescription<IconShape>(match.Groups[3].Value) Shape = EnumHelper.GetEnumValueFromDescription<IconShape>(match.Groups[3].Value)
}; };
if(match.Groups[4].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[5].Value)) if(match.Groups[4].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[5].Value))
{ {
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Icon, match.Groups[5].Value.Trim(), ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Icon, match.Groups[5].Value.Trim(),
blockItemValue.Size, blockItemValue.Color, blockItemValue.Shape); blockItemValue.Size, blockItemValue.Color, blockItemValue.Shape);
blockItemValue.ThemeComponent = themeComponent; blockItemValue.ThemeComponent = themeComponent;
} }
block.BlockItems.Add(blockItemValue); block.BlockItems.Add(blockItemValue);
} themeComponentType = (int)ThemeComponentType.Icon;
}
break; break;
} }
case "PlayEffect": case "PlayEffect":
{ {
// Only ever use the last BeamColor item encountered as multiples aren't valid. // Only ever use the last BeamColor item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<PlayEffectBlockItem>(block); RemoveExistingBlockItemsOfType<PlayEffectBlockItem>(block);
// TODO: Get colors programmatically // TODO: Get colors programmatically
var match = Regex.Match(trimmedLine, @"\S+\s+(Red|Green|Blue|Brown|White|Yellow)\s+(Temp)?\s*([#]?)(.*)", RegexOptions.IgnoreCase); var match = Regex.Match(trimmedLine, @"\S+\s+(Red|Green|Blue|Brown|White|Yellow)\s*(Temp)?", RegexOptions.IgnoreCase);
if (match.Success) if (match.Success)
{ {
var blockItemValue = new PlayEffectBlockItem var blockItemValue = new PlayEffectBlockItem
{ {
Color = EnumHelper.GetEnumValueFromDescription<EffectColor>(match.Groups[1].Value), Color = EnumHelper.GetEnumValueFromDescription<EffectColor>(match.Groups[1].Value),
Temporary = match.Groups[2].Value.Trim().ToLower() == "temp" Temporary = match.Groups[2].Value.Trim().ToLower() == "temp"
}; };
block.BlockItems.Add(blockItemValue);
if(match.Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[4].Value)) themeComponentType = (int)ThemeComponentType.Effect;
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Effect, match.Groups[4].Value.Trim(),
blockItemValue.Color, blockItemValue.Temporary);
blockItemValue.ThemeComponent = themeComponent;
}
block.BlockItems.Add(blockItemValue);
} }
break; break;
} }
@@ -372,22 +394,17 @@ namespace Filtration.Parser.Services
RemoveExistingBlockItemsOfType<SoundBlockItem>(block); RemoveExistingBlockItemsOfType<SoundBlockItem>(block);
RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block); RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block);
var match = Regex.Match(trimmedLine, @"\S+\s+""(\S+)""\s*([#]?)(.*)"); var match = Regex.Match(trimmedLine, @"\S+\s+""([^\*\<\>\?|]+)""");
if (match.Success) if (match.Success)
{ {
var blockItemValue = new CustomSoundBlockItem var blockItemValue = new CustomSoundBlockItem
{ {
Value = match.Groups[1].Value Value = match.Groups[1].Value
}; };
block.BlockItems.Add(blockItemValue);
if(match.Groups[2].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[3].Value)) themeComponentType = (int)ThemeComponentType.CustomSound;
{ }
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.CustomSound, match.Groups[3].Value.Trim(), blockItemValue.Value);
blockItemValue.ThemeComponent = themeComponent;
}
block.BlockItems.Add(blockItemValue);
}
break; break;
} }
case "MapTier": case "MapTier":
@@ -396,8 +413,87 @@ namespace Filtration.Parser.Services
break; break;
} }
} }
}
if (!string.IsNullOrWhiteSpace(blockComment) && block.BlockItems.Count > 1)
{
var blockItemWithTheme = block.BlockItems.Last() as IBlockItemWithTheme;
if(blockItemWithTheme == null)
{
block.BlockItems.Last().Comment = blockComment;
}
else
{
switch((ThemeComponentType)themeComponentType)
{
case ThemeComponentType.AlertSound:
{
ThemeComponent themeComponent = null;
if(blockItemWithTheme is SoundBlockItem)
{
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
((SoundBlockItem)blockItemWithTheme).Value, ((SoundBlockItem)blockItemWithTheme).SecondValue);
}
else
{
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
((PositionalSoundBlockItem)blockItemWithTheme).Value, ((PositionalSoundBlockItem)blockItemWithTheme).SecondValue);
}
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.BackgroundColor:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
blockComment.Trim(), ((BackgroundColorBlockItem)blockItemWithTheme).Color);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.BorderColor:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
blockComment.Trim(), ((BorderColorBlockItem)blockItemWithTheme).Color);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.CustomSound:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.CustomSound,
blockComment.Trim(), ((CustomSoundBlockItem)blockItemWithTheme).Value);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.Effect:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Effect,
blockComment.Trim(), ((EffectColorBlockItem)blockItemWithTheme).Color, ((EffectColorBlockItem)blockItemWithTheme).Temporary);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.FontSize:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize,
blockComment.Trim(), ((FontSizeBlockItem)blockItemWithTheme).Value);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.Icon:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Icon, blockComment.Trim(),
((IconBlockItem)blockItemWithTheme).Size, ((IconBlockItem)blockItemWithTheme).Color, ((IconBlockItem)blockItemWithTheme).Shape);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.TextColor:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
blockComment.Trim(), ((TextColorBlockItem)blockItemWithTheme).Color);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
}
}
}
}
block.IsEdited = false; block.IsEdited = false;
return block; return block;
} }
@@ -427,7 +523,7 @@ namespace Filtration.Parser.Services
private static void AddNumericFilterPredicateItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem private static void AddNumericFilterPredicateItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem
{ {
var blockItem = Activator.CreateInstance<T>(); var blockItem = Activator.CreateInstance<T>();
SetNumericFilterPredicateFromString(blockItem.FilterPredicate, inputString); SetNumericFilterPredicateFromString(blockItem.FilterPredicate, inputString);
block.BlockItems.Add(blockItem); block.BlockItems.Add(blockItem);
} }
@@ -460,48 +556,6 @@ namespace Filtration.Parser.Services
} }
} }
private void AddColorItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : ColorBlockItem
{
block.BlockItems.Add(GetColorBlockItemFromString<T>(inputString));
}
private T GetColorBlockItemFromString<T>(string inputString) where T: ColorBlockItem
{
var blockItem = Activator.CreateInstance<T>();
var result = Regex.Matches(inputString, @"([\w\s]*)[#]?(.*)");
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
var componentName = result[0].Groups[2].Value.Trim();
if (!string.IsNullOrEmpty(componentName))
{
ThemeComponentType componentType;
if (typeof(T) == typeof(TextColorBlockItem))
{
componentType = ThemeComponentType.TextColor;
}
else if (typeof(T) == typeof(BackgroundColorBlockItem))
{
componentType = ThemeComponentType.BackgroundColor;
}
else if (typeof(T) == typeof(BorderColorBlockItem))
{
componentType = ThemeComponentType.BorderColor;
}
else
{
throw new Exception("Parsing error - unknown theme component type");
}
if (_masterComponentCollection != null)
{
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(componentType, componentName,
blockItem.Color);
}
}
return blockItem;
}
public void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString) public void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString)
{ {
// Reverse iterate to remove existing IAudioVisualBlockItems // Reverse iterate to remove existing IAudioVisualBlockItems
@@ -516,42 +570,93 @@ namespace Filtration.Parser.Services
foreach (var line in new LineReader(() => new StringReader(inputString))) foreach (var line in new LineReader(() => new StringReader(inputString)))
{ {
var matches = Regex.Match(line, @"(\w+)"); var matches = Regex.Match(line, @"(\w+)");
var blockComment = "";
var trimmedLine = line.Trim();
if (trimmedLine.IndexOf('#') > 0)
{
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
}
switch (matches.Value) switch (matches.Value)
{ {
case "PlayAlertSound": case "PlayAlertSound":
{ {
var match = Regex.Match(line, @"\s+(\S+) (\d+)"); var match = Regex.Match(trimmedLine, @"\s+(\S+) (\d+)");
if (!match.Success) break; if (!match.Success) break;
blockItems.Add(new SoundBlockItem(match.Groups[1].Value, Convert.ToInt16(match.Groups[2].Value))); var blockItem = new SoundBlockItem(match.Groups[1].Value, Convert.ToInt16(match.Groups[2].Value));
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound,
blockComment, blockItem.Value, blockItem.SecondValue);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
case "SetTextColor": case "SetTextColor":
{ {
blockItems.Add(GetColorBlockItemFromString<TextColorBlockItem>(line)); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new TextColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
blockComment, blockItem.Color);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
case "SetBackgroundColor": case "SetBackgroundColor":
{ {
blockItems.Add(GetColorBlockItemFromString<BackgroundColorBlockItem>(line)); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BackgroundColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
blockComment, blockItem.Color);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
case "SetBorderColor": case "SetBorderColor":
{ {
blockItems.Add(GetColorBlockItemFromString<BorderColorBlockItem>(line)); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BorderColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
blockComment, blockItem.Color);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
case "SetFontSize": case "SetFontSize":
{ {
var match = Regex.Match(line, @"\s+(\d+)"); var match = Regex.Match(trimmedLine, @"\s+(\d+)");
if (!match.Success) break; if (!match.Success) break;
blockItems.Add(new FontSizeBlockItem(Convert.ToInt16(match.Value))); var blockItem = new FontSizeBlockItem(Convert.ToInt16(match.Value));
if (_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize,
blockComment, blockItem.Value);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
} }
} }
} }
private void AddBlockGroupToBlock(IItemFilterBlock block, string inputString) private void AddBlockGroupToBlock(IItemFilterBlock block, string inputString)
{ {
var blockGroupText = GetTextAfterFirstComment(inputString); var blockGroupText = GetTextAfterFirstComment(inputString);
@@ -618,15 +723,15 @@ namespace Filtration.Parser.Services
// TODO: Private // TODO: Private
public string TranslateItemFilterCommentBlockToString(IItemFilterCommentBlock itemFilterCommentBlock) public string TranslateItemFilterCommentBlockToString(IItemFilterCommentBlock itemFilterCommentBlock)
{ {
if (!itemFilterCommentBlock.IsEdited) if (!itemFilterCommentBlock.IsEdited)
{ {
return itemFilterCommentBlock.OriginalText; return itemFilterCommentBlock.OriginalText;
} }
// TODO: Tests // TODO: Tests
// TODO: # Section: text? // TODO: # Section: text?
var commentWithHashes = string.Empty; var commentWithHashes = string.Empty;
// Add "# " to the beginning of each line of the comment before saving it // Add "# " to the beginning of each line of the comment before saving it
foreach (var line in new LineReader(() => new StringReader(itemFilterCommentBlock.Comment))) foreach (var line in new LineReader(() => new StringReader(itemFilterCommentBlock.Comment)))
{ {
@@ -636,15 +741,15 @@ namespace Filtration.Parser.Services
// Remove trailing newline // Remove trailing newline
return commentWithHashes.TrimEnd('\r', '\n'); return commentWithHashes.TrimEnd('\r', '\n');
} }
// This method converts an ItemFilterBlock object into a string. This is used for copying a ItemFilterBlock // This method converts an ItemFilterBlock object into a string. This is used for copying a ItemFilterBlock
// to the clipboard, and when saving a ItemFilterScript. // to the clipboard, and when saving a ItemFilterScript.
// TODO: Private // TODO: Private
public string TranslateItemFilterBlockToString(IItemFilterBlock block) public string TranslateItemFilterBlockToString(IItemFilterBlock block)
{ {
if(!block.IsEdited) if(!block.IsEdited)
{ {
return block.OriginalText; return block.OriginalText;
} }
var outputString = string.Empty; var outputString = string.Empty;
@@ -672,14 +777,14 @@ namespace Filtration.Parser.Services
{ {
outputString += (!block.Enabled ? _disabledNewLine : _newLine) + blockItem.OutputText; outputString += (!block.Enabled ? _disabledNewLine : _newLine) + blockItem.OutputText;
} }
} }
//TODO: Disabled for the time being. A better solution is needed. //TODO: Disabled for the time being. A better solution is needed.
// Replace 'Maelström' to prevent encoding problems in other editors // Replace 'Maelström' to prevent encoding problems in other editors
//outputString.Replace("Maelström Staff", "Maelstr"); //outputString.Replace("Maelström Staff", "Maelstr");
//outputString.Replace("Maelström of Chaos", "Maelstr"); //outputString.Replace("Maelström of Chaos", "Maelstr");
//outputString.Replace("Maelström", "Maelstr"); //outputString.Replace("Maelström", "Maelstr");
return outputString; return outputString;
} }
} }

View File

@@ -2,8 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows;
using Filtration.Common.Utilities; using Filtration.Common.Utilities;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.Factories; using Filtration.ObjectModel.Factories;
@@ -48,18 +48,58 @@ namespace Filtration.Parser.Services
_itemFilterScriptFactory = itemFilterScriptFactory; _itemFilterScriptFactory = itemFilterScriptFactory;
} }
public static string PreprocessDisabledBlocks(string inputString) public static string PreprocessDisabledBlocks(string inputString, out List<bool> inBlock)
{ {
bool inDisabledBlock = false; bool inDisabledBlock = false;
inBlock = new List<bool>();
var lines = Regex.Split(inputString, "\r\n|\r|\n").ToList(); var lines = Regex.Split(inputString, "\r\n|\r|\n").ToList();
// find first show/hide and check script
for (var i = 0; i < lines.Count; i++)
{
inBlock.Add(false);
lines[i] = lines[i].Trim();
if(!lines[i].StartsWith("#"))
{
string curLine = Regex.Replace(lines[i], @"\s+", "");
if ((curLine.StartsWith("Show") || curLine.StartsWith("Hide")) && (curLine.Length == 4 || curLine[4] == '#')) // found
{
inBlock[i] = true;
break;
}
else // This means script has wrong syntax, just replace those lines with empty string
{
lines[i] = "";
}
}
}
// find remaining boundaries
var lastInBlock = inBlock.Count - 1;
for (var i = inBlock.Count; i < lines.Count; i++)
{
inBlock.Add(false);
lines[i] = lines[i].Trim();
if (!lines[i].StartsWith("#") && lines[i].Length > 0)
{
if (!lines[i].StartsWith("Show") && !lines[i].StartsWith("Hide")) // Continuing inline
{
for(int j = lastInBlock + 1; j < i; j++)
{
inBlock[j] = true;
}
}
lastInBlock = i;
inBlock[i] = true;
}
}
for (var i = 0; i < lines.Count; i++) for (var i = 0; i < lines.Count; i++)
{ {
if (!inDisabledBlock && lines[i].StartsWith("#")) if (!inDisabledBlock && lines[i].StartsWith("#"))
{ {
string curLine = Regex.Replace(lines[i].Substring(1), @"\s+", ""); string curLine = Regex.Replace(lines[i].Substring(1), @"\s+", "");
if ((curLine.StartsWith("Show") || curLine.StartsWith("Hide")) && (curLine.Length == 4 || curLine[4] == '#')) if ((curLine.StartsWith("Show") || curLine.StartsWith("Hide")) && (curLine.Length == 4 || curLine[4] == '#') && !inBlock[i])
{ {
inDisabledBlock = true; inDisabledBlock = true;
lines[i] = lines[i].Substring(1).TrimStart(' '); lines[i] = lines[i].Substring(1).TrimStart(' ');
@@ -88,16 +128,29 @@ namespace Filtration.Parser.Services
var script = _itemFilterScriptFactory.Create(); var script = _itemFilterScriptFactory.Create();
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First()); _blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
//Remove old disabled tags if(Regex.Matches(inputString, @"#Disabled\sBlock\s(Start|End).*?\n").Count > 0)
inputString = Regex.Replace(inputString, @"#Disabled\sBlock\s(Start|End).*?\n", ""); {
inputString = (inputString.EndsWith("\n#Disabled Block End")) ? inputString.Substring(0, inputString.Length - 19) : inputString; if (MessageBox.Show(
"Loaded script contains special '#Disabled Block Start' lines." +
" These may be coming from old versions of Filtration or Greengroove's filter." +
"It is suggested to remove them however this may cause problems with original source" +
Environment.NewLine + "(There is no in game effect of those lines)" +
Environment.NewLine + Environment.NewLine + "Would you like to remove them?", "Special Comment Lines Found",
MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
{
//Remove old disabled tags
inputString = Regex.Replace(inputString, @"#Disabled\sBlock\s(Start|End).*?\n", "");
inputString = (inputString.EndsWith("\n#Disabled Block End")) ? inputString.Substring(0, inputString.Length - 19) : inputString;
}
}
var originalLines = Regex.Split(inputString, "\r\n|\r|\n"); var originalLines = Regex.Split(inputString, "\r\n|\r|\n");
inputString = inputString.Replace("\t", ""); inputString = inputString.Replace("\t", "");
inputString = PreprocessDisabledBlocks(inputString); List<bool> inBlock;
inputString = PreprocessDisabledBlocks(inputString, out inBlock);
var conditionBoundaries = IdentifyBlockBoundaries(inputString); var conditionBoundaries = IdentifyBlockBoundaries(inputString, inBlock);
var lines = Regex.Split(inputString, "\r\n|\r|\n"); var lines = Regex.Split(inputString, "\r\n|\r|\n");
@@ -158,7 +211,7 @@ namespace Filtration.Parser.Services
return script; return script;
} }
private static LinkedList<ItemFilterBlockBoundary> IdentifyBlockBoundaries(string inputString) private static LinkedList<ItemFilterBlockBoundary> IdentifyBlockBoundaries(string inputString, List<bool> inBlock)
{ {
var blockBoundaries = new LinkedList<ItemFilterBlockBoundary>(); var blockBoundaries = new LinkedList<ItemFilterBlockBoundary>();
var previousLine = string.Empty; var previousLine = string.Empty;
@@ -177,9 +230,10 @@ namespace Filtration.Parser.Services
continue; continue;
} }
// A line starting with a comment when we're inside a ItemFilterBlock boundary represents the end of that block // A line starting with a comment when we're inside a ItemFilterBlock boundary may represent the end of that block
// as ItemFilterBlocks cannot have comment lines after the block description // or a block item comment
if (trimmedLine.StartsWith("#") && currentItemFilterBlockBoundary.BoundaryType == ItemFilterBlockBoundaryType.ItemFilterBlock) if (trimmedLine.StartsWith("#") && !inBlock[currentLine] &&
currentItemFilterBlockBoundary.BoundaryType == ItemFilterBlockBoundaryType.ItemFilterBlock)
{ {
blockBoundaries.AddLast(currentItemFilterBlockBoundary); blockBoundaries.AddLast(currentItemFilterBlockBoundary);
currentItemFilterBlockBoundary = new ItemFilterBlockBoundary(currentLine, ItemFilterBlockBoundaryType.CommentBlock); currentItemFilterBlockBoundary = new ItemFilterBlockBoundary(currentLine, ItemFilterBlockBoundaryType.CommentBlock);

View File

@@ -209,7 +209,7 @@ namespace Filtration.ThemeEditor.ViewModels
Components.Add(new StrIntThemeComponent(themeComponentType, "Untitled Component", "1", 100)); Components.Add(new StrIntThemeComponent(themeComponentType, "Untitled Component", "1", 100));
break; break;
case ThemeComponentType.CustomSound: case ThemeComponentType.CustomSound:
Components.Add(new StringThemeComponent(themeComponentType, "Untitled Component", "placeholder.mp3")); Components.Add(new StringThemeComponent(themeComponentType, "Untitled Component", ""));
break; break;
case ThemeComponentType.Icon: case ThemeComponentType.Icon:
Components.Add(new IconThemeComponent(themeComponentType, "Untitled Component", IconSize.Largest, IconColor.Red, IconShape.Circle)); Components.Add(new IconThemeComponent(themeComponentType, "Untitled Component", IconSize.Largest, IconColor.Red, IconShape.Circle));

View File

@@ -11,7 +11,7 @@ namespace Filtration.Converters
{ {
if (values[0] == DependencyProperty.UnsetValue || if (values[0] == DependencyProperty.UnsetValue ||
values[1] == DependencyProperty.UnsetValue) values[1] == DependencyProperty.UnsetValue)
return null; return new Rect(0, 0, 0, 0);
var size = (int)(values[0]); var size = (int)(values[0]);
var color = (int)(values[1]); var color = (int)(values[1]);

View File

@@ -50,7 +50,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.18")] [assembly: AssemblyVersion("0.19")]
[assembly: InternalsVisibleTo("Filtration.Tests")] [assembly: InternalsVisibleTo("Filtration.Tests")]
[assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")] [assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

@@ -9,7 +9,7 @@ Bows
Claws Claws
Currency Currency
Daggers Daggers
Delve Stackable Currency Delve Socketable Currency
Divination Card Divination Card
Fishing Rods Fishing Rods
Flasks Flasks

View File

@@ -251,6 +251,13 @@ namespace Filtration.ViewModels
var newBlockItem = (IItemFilterBlockItem) Activator.CreateInstance(blockItemType); var newBlockItem = (IItemFilterBlockItem) Activator.CreateInstance(blockItemType);
newBlockItem.PropertyChanged += OnBlockItemChanged; newBlockItem.PropertyChanged += OnBlockItemChanged;
var customSoundBlockItem = newBlockItem as CustomSoundBlockItem;
if(customSoundBlockItem != null && _parentScriptViewModel.CustomSoundsAvailable.Count > 0)
{
customSoundBlockItem.Value = _parentScriptViewModel.CustomSoundsAvailable[0];
}
BlockItems.Add(newBlockItem); BlockItems.Add(newBlockItem);
OnBlockItemChanged(this, EventArgs.Empty); OnBlockItemChanged(this, EventArgs.Empty);
IsDirty = true; IsDirty = true;

View File

@@ -1,6 +1,7 @@
using Filtration.ObjectModel; using Filtration.ObjectModel;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
using System; using System;
using System.Text.RegularExpressions;
namespace Filtration.ViewModels namespace Filtration.ViewModels
{ {
@@ -61,7 +62,7 @@ namespace Filtration.ViewModels
{ {
string[] commentLines = ItemFilterCommentBlock.Comment.Split(new[] { Environment.NewLine }, StringSplitOptions.None); string[] commentLines = ItemFilterCommentBlock.Comment.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
var titleOffset = 1; var titleOffset = 1;
if (commentLines.Length > 1 && (commentLines[0].TrimStart(' ').StartsWith(@"============") || commentLines[0].TrimStart(' ').StartsWith(@"------------"))) if (commentLines.Length > 1 && !Regex.Match(commentLines[0], "[a-zA-Z]+").Success)
{ {
titleOffset = 3; titleOffset = 3;
commentLines[0] = commentLines[1]; commentLines[0] = commentLines[1];

View File

@@ -166,10 +166,22 @@ namespace Filtration.ViewModels
_viewItemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>(); _viewItemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
_customSoundsAvailable = new ObservableCollection<string> { _customSoundsAvailable = new ObservableCollection<string>();
"1maybevaluable.mp3", "2currency.mp3", "3uniques.mp3", "4maps.mp3", "5highmaps.mp3",
"6veryvaluable.mp3", "7chancing.mp3", "12leveling.mp3", "placeholder.mp3" var poeFolderFiles = Directory.GetFiles(persistenceService.DefaultPathOfExileDirectory() + "\\").Where(
}; s => s.EndsWith(".mp3")
|| s.EndsWith(".wav")
|| s.EndsWith(".wma")
|| s.EndsWith(".3gp")
|| s.EndsWith(".aag")
|| s.EndsWith(".m4a")
|| s.EndsWith(".ogg")
).OrderBy(f => f);
foreach(var file in poeFolderFiles)
{
_customSoundsAvailable.Add(file.Replace(persistenceService.DefaultPathOfExileDirectory() + "\\", ""));
}
} }
public void Initialise(IItemFilterScript itemFilterScript, bool newScript) public void Initialise(IItemFilterScript itemFilterScript, bool newScript)

View File

@@ -2,10 +2,10 @@
Filtration is an editor for Path of Exile item filter scripts. Filtration is an editor for Path of Exile item filter scripts.
## Current Release (Released 2017-12-08) ## Current Release (Released 2018-08-30)
<b>Installer</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.17/filtration_0.17_setup.exe">filtration_0.17_setup.exe</a> <b>Installer</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.19/filtration_0.19_setup.exe">filtration_0.19_setup.exe</a>
<b>Zip File</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.17/filtration_0.17.zip">filtration_0.17.zip</a> <b>Zip File</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.19/filtration_0.19.zip">filtration_0.19.zip</a>
## System Requirements ## System Requirements
Filtration requires .NET Framework 4.6.1 installed. Filtration requires .NET Framework 4.6.1 installed.