Fix the reading of CustomAlertSounds containing path separators.
This commit is contained in:
		
							parent
							
								
									7162e16b49
								
							
						
					
					
						commit
						24df1d7687
					
				| @ -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,37 +372,37 @@ 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] | ||||||
| @ -424,37 +424,37 @@ namespace Filtration.Parser.Tests.Services | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         [Test] |         [Test] | ||||||
|         public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject() |         public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject() | ||||||
|         { |         { | ||||||
|             // Arrange |             // Arrange | ||||||
|             var inputString = "Show" + Environment.NewLine + |             var inputString = "Show" + Environment.NewLine + | ||||||
|                               "    ShapedMap 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 ShapedMapBlockItem)); |             Assert.AreEqual(1, result.BlockItems.Count(b => b is ShapedMapBlockItem)); | ||||||
|             var blockItem = result.BlockItems.OfType<ShapedMapBlockItem>().First(); |             var blockItem = result.BlockItems.OfType<ShapedMapBlockItem>().First(); | ||||||
|             Assert.IsFalse(blockItem.BooleanValue); |             Assert.IsFalse(blockItem.BooleanValue); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         [Test] |         [Test] | ||||||
|         public void TranslateStringToItemFilterBlock_ElderMap_ReturnsCorrectObject() |         public void TranslateStringToItemFilterBlock_ElderMap_ReturnsCorrectObject() | ||||||
|         { |         { | ||||||
|             // Arrange |             // Arrange | ||||||
|             var inputString = "Show" + Environment.NewLine + |             var inputString = "Show" + Environment.NewLine + | ||||||
|                               "    ElderMap false"; |                               "    ElderMap 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 ElderMapBlockItem)); | ||||||
|             var blockItem = result.BlockItems.OfType<ElderMapBlockItem>().First(); |             var blockItem = result.BlockItems.OfType<ElderMapBlockItem>().First(); | ||||||
|             Assert.IsFalse(blockItem.BooleanValue); |             Assert.IsFalse(blockItem.BooleanValue); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         [Test] |         [Test] | ||||||
| @ -793,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)); | ||||||
| 
 | 
 | ||||||
| @ -894,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() | ||||||
|         { |         { | ||||||
| @ -1044,7 +1044,7 @@ 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); | ||||||
|              | 
 | ||||||
|             Assert.AreEqual(0, result.BlockItems.OfType<SoundBlockItem>().Count()); |             Assert.AreEqual(0, result.BlockItems.OfType<SoundBlockItem>().Count()); | ||||||
| 
 | 
 | ||||||
|             var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); |             var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); | ||||||
| @ -1087,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 | ||||||
| @ -1150,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() | ||||||
|         { |         { | ||||||
| @ -1271,6 +1271,86 @@ namespace Filtration.Parser.Tests.Services | |||||||
|             Assert.AreEqual(ItemRarity.Rare, (ItemRarity)rarityBlockItem.FilterPredicate.PredicateOperand); |             Assert.AreEqual(ItemRarity.Rare, (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 TranslateStringToItemFilterBlock_SpecificTest_2() |         public void TranslateStringToItemFilterBlock_SpecificTest_2() | ||||||
|         { |         { | ||||||
| @ -1326,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); | ||||||
| @ -1851,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"; | ||||||
| 
 | 
 | ||||||
| @ -1893,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)); | ||||||
| @ -1940,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)); | ||||||
| @ -2008,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); | ||||||
| @ -2083,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>(); | ||||||
| @ -2129,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 | ||||||
| @ -2201,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() | ||||||
|  | |||||||
| @ -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) | ||||||
|         { |         { | ||||||
| @ -65,20 +65,20 @@ namespace Filtration.Parser.Services | |||||||
|             { |             { | ||||||
|                 if (line.StartsWith(@"#")) |                 if (line.StartsWith(@"#")) | ||||||
|                 { |                 { | ||||||
|                     if(!showHideFound) |                     if(!showHideFound) | ||||||
|                     { |                     { | ||||||
|                         block.Description = line.TrimStart('#').TrimStart(' '); |                         block.Description = line.TrimStart('#').TrimStart(' '); | ||||||
|                     } |                     } | ||||||
|                     else |                     else | ||||||
|                     { |                     { | ||||||
|                         if(block.BlockItems.Count > 1) |                         if(block.BlockItems.Count > 1) | ||||||
|                         { |                         { | ||||||
|                             block.BlockItems.Last().Comment += Environment.NewLine + line.TrimStart('#'); |                             block.BlockItems.Last().Comment += Environment.NewLine + line.TrimStart('#'); | ||||||
|                         } |                         } | ||||||
|                         else |                         else | ||||||
|                         { |                         { | ||||||
|                             block.ActionBlockItem.Comment += Environment.NewLine + line.TrimStart('#'); |                             block.ActionBlockItem.Comment += Environment.NewLine + line.TrimStart('#'); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
| @ -87,10 +87,10 @@ namespace Filtration.Parser.Services | |||||||
|                 var trimmedLine = fullLine; |                 var trimmedLine = fullLine; | ||||||
|                 var blockComment = ""; |                 var blockComment = ""; | ||||||
|                 var themeComponentType = -1; |                 var themeComponentType = -1; | ||||||
|                 if(trimmedLine.IndexOf('#') > 0) |                 if(trimmedLine.IndexOf('#') > 0) | ||||||
|                 { |                 { | ||||||
|                     blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1); |                     blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1); | ||||||
|                     trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim(); |                     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; | ||||||
| 
 | 
 | ||||||
| @ -216,7 +216,7 @@ namespace Filtration.Parser.Services | |||||||
|                         RemoveExistingBlockItemsOfType<TextColorBlockItem>(block); |                         RemoveExistingBlockItemsOfType<TextColorBlockItem>(block); | ||||||
| 
 | 
 | ||||||
|                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); |                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); | ||||||
|                          | 
 | ||||||
|                         var blockItem = new TextColorBlockItem(); |                         var blockItem = new TextColorBlockItem(); | ||||||
|                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); |                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); | ||||||
|                         block.BlockItems.Add(blockItem); |                         block.BlockItems.Add(blockItem); | ||||||
| @ -229,7 +229,7 @@ namespace Filtration.Parser.Services | |||||||
|                         RemoveExistingBlockItemsOfType<BackgroundColorBlockItem>(block); |                         RemoveExistingBlockItemsOfType<BackgroundColorBlockItem>(block); | ||||||
| 
 | 
 | ||||||
|                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); |                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); | ||||||
|                          | 
 | ||||||
|                         var blockItem = new BackgroundColorBlockItem(); |                         var blockItem = new BackgroundColorBlockItem(); | ||||||
|                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); |                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); | ||||||
|                         block.BlockItems.Add(blockItem); |                         block.BlockItems.Add(blockItem); | ||||||
| @ -242,7 +242,7 @@ namespace Filtration.Parser.Services | |||||||
|                         RemoveExistingBlockItemsOfType<BorderColorBlockItem>(block); |                         RemoveExistingBlockItemsOfType<BorderColorBlockItem>(block); | ||||||
| 
 | 
 | ||||||
|                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); |                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); | ||||||
|                          | 
 | ||||||
|                         var blockItem = new BorderColorBlockItem(); |                         var blockItem = new BorderColorBlockItem(); | ||||||
|                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); |                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); | ||||||
|                         block.BlockItems.Add(blockItem); |                         block.BlockItems.Add(blockItem); | ||||||
| @ -272,41 +272,41 @@ namespace Filtration.Parser.Services | |||||||
|                         RemoveExistingBlockItemsOfType<CustomSoundBlockItem>(block); |                         RemoveExistingBlockItemsOfType<CustomSoundBlockItem>(block); | ||||||
| 
 | 
 | ||||||
|                         var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?"); |                         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 |  | ||||||
|                             { |  | ||||||
|                                 secondValue = 79; |  | ||||||
|                             } |  | ||||||
| 
 |  | ||||||
|                             if (lineOption == "PlayAlertSound") |  | ||||||
|                             { |  | ||||||
|                                 var blockItemValue = new SoundBlockItem |  | ||||||
|                                 { |  | ||||||
|                                     Value = firstValue, |  | ||||||
|                                     SecondValue = secondValue |  | ||||||
|                                 }; |  | ||||||
|                                 block.BlockItems.Add(blockItemValue); |  | ||||||
|                             } |  | ||||||
|                             else |  | ||||||
|                             { |  | ||||||
|                                 var blockItemValue = new PositionalSoundBlockItem |  | ||||||
|                                 { |  | ||||||
|                                     Value = firstValue, |  | ||||||
|                                     SecondValue = secondValue |  | ||||||
|                                 }; |  | ||||||
|                                 block.BlockItems.Add(blockItemValue); |  | ||||||
|                             } |                             } | ||||||
|                             themeComponentType = (int)ThemeComponentType.AlertSound; |                             else | ||||||
|                         } |                             { | ||||||
|  |                                 secondValue = 79; | ||||||
|  |                             } | ||||||
|  | 
 | ||||||
|  |                             if (lineOption == "PlayAlertSound") | ||||||
|  |                             { | ||||||
|  |                                 var blockItemValue = new SoundBlockItem | ||||||
|  |                                 { | ||||||
|  |                                     Value = firstValue, | ||||||
|  |                                     SecondValue = secondValue | ||||||
|  |                                 }; | ||||||
|  |                                 block.BlockItems.Add(blockItemValue); | ||||||
|  |                             } | ||||||
|  |                             else | ||||||
|  |                             { | ||||||
|  |                                 var blockItemValue = new PositionalSoundBlockItem | ||||||
|  |                                 { | ||||||
|  |                                     Value = firstValue, | ||||||
|  |                                     SecondValue = secondValue | ||||||
|  |                                 }; | ||||||
|  |                                 block.BlockItems.Add(blockItemValue); | ||||||
|  |                             } | ||||||
|  |                             themeComponentType = (int)ThemeComponentType.AlertSound; | ||||||
|  |                         } | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
|                     case "GemLevel": |                     case "GemLevel": | ||||||
| @ -341,49 +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; |                             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)?", 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); |                             block.BlockItems.Add(blockItemValue); | ||||||
|                             themeComponentType = (int)ThemeComponentType.Effect; |                             themeComponentType = (int)ThemeComponentType.Effect; | ||||||
|                         } |                         } | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
| @ -394,17 +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+)"""); | 	                    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); |                             block.BlockItems.Add(blockItemValue); | ||||||
|                             themeComponentType = (int)ThemeComponentType.CustomSound; |                             themeComponentType = (int)ThemeComponentType.CustomSound; | ||||||
|                         } |                         } | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
|                     case "MapTier": |                     case "MapTier": | ||||||
| @ -412,88 +412,88 @@ namespace Filtration.Parser.Services | |||||||
|                         AddNumericFilterPredicateItemToBlockItems<MapTierBlockItem>(block, trimmedLine); |                         AddNumericFilterPredicateItemToBlockItems<MapTierBlockItem>(block, trimmedLine); | ||||||
|                         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; |  | ||||||
|                             } |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                 } |                 } | ||||||
|             } | 
 | ||||||
|  |                 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; | ||||||
|         } |         } | ||||||
| @ -523,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); | ||||||
|         } |         } | ||||||
| @ -572,12 +572,12 @@ namespace Filtration.Parser.Services | |||||||
|                 var matches = Regex.Match(line, @"(\w+)"); |                 var matches = Regex.Match(line, @"(\w+)"); | ||||||
|                 var blockComment = ""; |                 var blockComment = ""; | ||||||
|                 var trimmedLine = line.Trim(); |                 var trimmedLine = line.Trim(); | ||||||
|                 if (trimmedLine.IndexOf('#') > 0) |                 if (trimmedLine.IndexOf('#') > 0) | ||||||
|                 { |                 { | ||||||
|                     blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1); |                     blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1); | ||||||
|                     trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim(); |                     trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim(); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 switch (matches.Value) |                 switch (matches.Value) | ||||||
|                 { |                 { | ||||||
|                     case "PlayAlertSound": |                     case "PlayAlertSound": | ||||||
| @ -585,11 +585,11 @@ namespace Filtration.Parser.Services | |||||||
|                         var match = Regex.Match(trimmedLine, @"\s+(\S+) (\d+)"); |                         var match = Regex.Match(trimmedLine, @"\s+(\S+) (\d+)"); | ||||||
|                         if (!match.Success) break; |                         if (!match.Success) break; | ||||||
|                         var blockItem = 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)) |                         if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) | ||||||
|                         { |                         { | ||||||
|                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, |                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, | ||||||
|                                 blockComment, blockItem.Value, blockItem.SecondValue); |                                 blockComment, blockItem.Value, blockItem.SecondValue); | ||||||
|                                 blockItem.ThemeComponent = themeComponent; |                                 blockItem.ThemeComponent = themeComponent; | ||||||
|                         } |                         } | ||||||
|                         blockItems.Add(blockItem); |                         blockItems.Add(blockItem); | ||||||
|                         break; |                         break; | ||||||
| @ -597,14 +597,14 @@ namespace Filtration.Parser.Services | |||||||
|                     case "SetTextColor": |                     case "SetTextColor": | ||||||
|                     { |                     { | ||||||
|                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); |                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); | ||||||
|                          | 
 | ||||||
|                         var blockItem = new TextColorBlockItem(); |                         var blockItem = new TextColorBlockItem(); | ||||||
|                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); |                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); | ||||||
|                         if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) |                         if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) | ||||||
|                         { |                         { | ||||||
|                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor, |                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor, | ||||||
|                                 blockComment, blockItem.Color); |                                 blockComment, blockItem.Color); | ||||||
|                             blockItem.ThemeComponent = themeComponent; |                             blockItem.ThemeComponent = themeComponent; | ||||||
|                         } |                         } | ||||||
|                         blockItems.Add(blockItem); |                         blockItems.Add(blockItem); | ||||||
|                         break; |                         break; | ||||||
| @ -612,14 +612,14 @@ namespace Filtration.Parser.Services | |||||||
|                     case "SetBackgroundColor": |                     case "SetBackgroundColor": | ||||||
|                     { |                     { | ||||||
|                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); |                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); | ||||||
|                          | 
 | ||||||
|                         var blockItem = new BackgroundColorBlockItem(); |                         var blockItem = new BackgroundColorBlockItem(); | ||||||
|                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); |                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); | ||||||
|                         if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) |                         if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) | ||||||
|                         { |                         { | ||||||
|                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor, |                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor, | ||||||
|                                 blockComment, blockItem.Color); |                                 blockComment, blockItem.Color); | ||||||
|                             blockItem.ThemeComponent = themeComponent; |                             blockItem.ThemeComponent = themeComponent; | ||||||
|                         } |                         } | ||||||
|                         blockItems.Add(blockItem); |                         blockItems.Add(blockItem); | ||||||
|                         break; |                         break; | ||||||
| @ -627,14 +627,14 @@ namespace Filtration.Parser.Services | |||||||
|                     case "SetBorderColor": |                     case "SetBorderColor": | ||||||
|                     { |                     { | ||||||
|                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); |                         var result = Regex.Matches(trimmedLine, @"([\w\s]*)"); | ||||||
|                          | 
 | ||||||
|                         var blockItem = new BorderColorBlockItem(); |                         var blockItem = new BorderColorBlockItem(); | ||||||
|                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); |                         blockItem.Color = GetColorFromString(result[0].Groups[1].Value); | ||||||
|                         if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) |                         if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) | ||||||
|                         { |                         { | ||||||
|                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor, |                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor, | ||||||
|                                 blockComment, blockItem.Color); |                                 blockComment, blockItem.Color); | ||||||
|                             blockItem.ThemeComponent = themeComponent; |                             blockItem.ThemeComponent = themeComponent; | ||||||
|                         } |                         } | ||||||
|                         blockItems.Add(blockItem); |                         blockItems.Add(blockItem); | ||||||
|                         break; |                         break; | ||||||
| @ -644,19 +644,19 @@ namespace Filtration.Parser.Services | |||||||
|                         var match = Regex.Match(trimmedLine, @"\s+(\d+)"); |                         var match = Regex.Match(trimmedLine, @"\s+(\d+)"); | ||||||
|                         if (!match.Success) break; |                         if (!match.Success) break; | ||||||
|                         var blockItem = new FontSizeBlockItem(Convert.ToInt16(match.Value)); |                         var blockItem = new FontSizeBlockItem(Convert.ToInt16(match.Value)); | ||||||
|                         if (_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) |                         if (_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment)) | ||||||
|                         { |                         { | ||||||
|                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize, |                             ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize, | ||||||
|                                 blockComment, blockItem.Value); |                                 blockComment, blockItem.Value); | ||||||
|                             blockItem.ThemeComponent = themeComponent; |                             blockItem.ThemeComponent = themeComponent; | ||||||
|                         } |                         } | ||||||
|                         blockItems.Add(blockItem); |                         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); | ||||||
| @ -723,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))) | ||||||
|             { |             { | ||||||
| @ -741,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; | ||||||
| @ -777,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; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user