| @ -27,8 +27,6 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public string Comment { get; set; } | ||||
| 
 | ||||
|         public override string OutputText => Action.GetAttributeDescription(); | ||||
| 
 | ||||
|         public override string PrefixText => string.Empty; | ||||
|  | ||||
| @ -17,6 +17,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes | ||||
|         public abstract Color SummaryBackgroundColor { get; } | ||||
|         public abstract Color SummaryTextColor { get; } | ||||
|         public abstract int SortOrder { get; } | ||||
|         public string Comment { get; set; } | ||||
| 
 | ||||
|         public bool IsDirty | ||||
|         { | ||||
|  | ||||
| @ -4,6 +4,6 @@ namespace Filtration.ObjectModel | ||||
| { | ||||
|     public interface IBlockItemWithTheme : IItemFilterBlockItem | ||||
|     { | ||||
|         ThemeComponent ThemeComponent { get; } | ||||
|         ThemeComponent ThemeComponent { get; set; } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -14,5 +14,6 @@ namespace Filtration.ObjectModel | ||||
|         int MaximumAllowed { get; } | ||||
|         int SortOrder { get; } | ||||
|         bool IsDirty { get; } | ||||
|         string Comment { get; set; } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| using System; | ||||
| using System.Collections.ObjectModel; | ||||
| using System.Linq; | ||||
| using Filtration.ObjectModel.Enums; | ||||
| using GalaSoft.MvvmLight.Command; | ||||
| using Microsoft.Win32; | ||||
| @ -25,13 +26,34 @@ namespace Filtration.ObjectModel.ThemeEditor | ||||
| 
 | ||||
|             if (_customSoundsAvailable == null || _customSoundsAvailable.Count < 1) | ||||
|             { | ||||
|                 _customSoundsAvailable = new ObservableCollection<string> { | ||||
|                     "1maybevaluable.mp3", "2currency.mp3", "3uniques.mp3", "4maps.mp3", "5highmaps.mp3", | ||||
|                     "6veryvaluable.mp3", "7chancing.mp3", "12leveling.mp3", "placeholder.mp3" | ||||
|                 }; | ||||
| 
 | ||||
|                 _customSoundsAvailable = new ObservableCollection<string>(); | ||||
| 
 | ||||
|                 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); | ||||
|             } | ||||
|  | ||||
| @ -405,6 +405,24 @@ namespace Filtration.Parser.Tests.Services | ||||
|             Assert.IsTrue(blockItem.BooleanValue); | ||||
|         } | ||||
| 
 | ||||
|         [Test] | ||||
|         public void TranslateStringToItemFilterBlock_MapTier_ReturnsCorrectObject() | ||||
|         { | ||||
|             // Arrange | ||||
|             var inputString = "Show" + Environment.NewLine + | ||||
|                               "    MapTier >= 15"; | ||||
| 
 | ||||
|             // Act | ||||
|             var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); | ||||
| 
 | ||||
|             // Assert | ||||
| 
 | ||||
|             Assert.AreEqual(1, result.BlockItems.Count(b => b is MapTierBlockItem)); | ||||
|             var blockItem = result.BlockItems.OfType<MapTierBlockItem>().First(); | ||||
|             Assert.AreEqual(15, blockItem.FilterPredicate.PredicateOperand); | ||||
|             Assert.AreEqual(FilterPredicateOperator.GreaterThanOrEqual, blockItem.FilterPredicate.PredicateOperator); | ||||
|         } | ||||
| 
 | ||||
|         [Test] | ||||
|         public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject() | ||||
|         { | ||||
| @ -925,7 +943,10 @@ namespace Filtration.Parser.Tests.Services | ||||
|                               "    SetBorderColor 0 0 0" + Environment.NewLine + | ||||
|                               "    SetFontSize 50" + 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 | ||||
|             var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); | ||||
| @ -1024,12 +1045,40 @@ namespace Filtration.Parser.Tests.Services | ||||
|             var fontSizeblockItem = result.BlockItems.OfType<FontSizeBlockItem>().First(); | ||||
|             Assert.AreEqual(50, fontSizeblockItem.Value); | ||||
|              | ||||
|             var soundblockItem = result.BlockItems.OfType<SoundBlockItem>().First(); | ||||
|             Assert.AreEqual("3", soundblockItem.Value); | ||||
|             Assert.AreEqual(79, soundblockItem.SecondValue); | ||||
|             Assert.AreEqual(0, result.BlockItems.OfType<SoundBlockItem>().Count()); | ||||
| 
 | ||||
|             var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); | ||||
|             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] | ||||
|  | ||||
| @ -285,13 +285,11 @@ namespace Filtration.Parser.Tests.Services | ||||
|                                   "    ItemLevel > 2" + Environment.NewLine + | ||||
|                                   "    SetTextColor 255 40 0" + Environment.NewLine + | ||||
|                                   Environment.NewLine + | ||||
|                                   "#Disabled Block Start" + Environment.NewLine + | ||||
|                                   "#Show" + Environment.NewLine + | ||||
|                                   "#    ItemLevel > 2" + Environment.NewLine + | ||||
|                                   "#    SetTextColor 255 215 0" + Environment.NewLine + | ||||
|                                   "#    SetBorderColor 255 105 180" + Environment.NewLine + | ||||
|                                   "#    SetFontSize 32" + Environment.NewLine + | ||||
|                                   "#Disabled Block End" + Environment.NewLine + | ||||
|                                   Environment.NewLine + | ||||
|                                   "Show" + Environment.NewLine + | ||||
|                                   "   ItemLevel > 20" + Environment.NewLine + | ||||
| @ -316,13 +314,11 @@ namespace Filtration.Parser.Tests.Services | ||||
|                                   "    ItemLevel > 2" + Environment.NewLine + | ||||
|                                   "    SetTextColor 255 40 0" + Environment.NewLine + | ||||
|                                   Environment.NewLine + | ||||
|                                   "#Disabled Block Start" + Environment.NewLine + | ||||
|                                   "#Show" + Environment.NewLine + | ||||
|                                   "#    ItemLevel > 2" + Environment.NewLine + | ||||
|                                   "#    SetTextColor 255 215 0" + Environment.NewLine + | ||||
|                                   "#    SetBorderColor 255 105 180" + Environment.NewLine + | ||||
|                                   "#    SetFontSize 32" + Environment.NewLine + | ||||
|                                   "#Disabled Block End" + Environment.NewLine + | ||||
|                                   Environment.NewLine + | ||||
|                                   "Show" + Environment.NewLine + | ||||
|                                   "   ItemLevel > 20" + Environment.NewLine + | ||||
| @ -355,11 +351,9 @@ namespace Filtration.Parser.Tests.Services | ||||
|                                   "    ItemLevel > 2" + Environment.NewLine + | ||||
|                                   "    SetTextColor 255 40 0" + Environment.NewLine + | ||||
|                                   Environment.NewLine + | ||||
|                                   "#Disabled Block Start" + Environment.NewLine + | ||||
|                                   "# This is a disabled block" + Environment.NewLine + | ||||
|                                   "#Show" + Environment.NewLine + | ||||
|                                   "#    ItemLevel > 2" + Environment.NewLine + | ||||
|                                   "#Disabled Block End"; | ||||
|                                   "#    ItemLevel > 2"; | ||||
| 
 | ||||
| 
 | ||||
|             var blockTranslator = new ItemFilterBlockTranslator(Mock.Of<IBlockGroupHierarchyBuilder>()); | ||||
| @ -384,11 +378,9 @@ namespace Filtration.Parser.Tests.Services | ||||
|                                   "    ItemLevel > 2" + Environment.NewLine + | ||||
|                                   "    SetTextColor 255 40 0" + Environment.NewLine + | ||||
|                                   Environment.NewLine + | ||||
|                                   "#Disabled Block Start" + Environment.NewLine + | ||||
|                                   "# This is a disabled block" + Environment.NewLine + | ||||
|                                   "#Show#My Block Group" + Environment.NewLine + | ||||
|                                   "#    ItemLevel > 2" + Environment.NewLine + | ||||
|                                   "#Disabled Block End"; | ||||
|                                   "#    ItemLevel > 2"; | ||||
| 
 | ||||
| 
 | ||||
|             var mockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>(); | ||||
|  | ||||
| @ -39,6 +39,7 @@ | ||||
|       <HintPath>..\packages\Castle.Windsor.3.4.0\lib\net45\Castle.Windsor.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="PresentationCore" /> | ||||
|     <Reference Include="PresentationFramework" /> | ||||
|     <Reference Include="System" /> | ||||
|     <Reference Include="System.Core" /> | ||||
|     <Reference Include="System.Xml.Linq" /> | ||||
|  | ||||
| @ -63,13 +63,35 @@ namespace Filtration.Parser.Services | ||||
| 
 | ||||
|             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; | ||||
|                 } | ||||
| 
 | ||||
|                 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 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. | ||||
|                         if (parentItemFilterScript.ItemFilterScriptSettings.BlockGroupsEnabled) | ||||
|                         { | ||||
|                             AddBlockGroupToBlock(block, trimmedLine); | ||||
|                             AddBlockGroupToBlock(block, fullLine); | ||||
|                         } | ||||
|                         else | ||||
|                         { | ||||
|                             block.ActionBlockItem.Comment = GetTextAfterFirstComment(trimmedLine); | ||||
|                             block.ActionBlockItem.Comment = GetTextAfterFirstComment(fullLine); | ||||
|                         } | ||||
|                         break; | ||||
|                     } | ||||
| @ -193,7 +215,12 @@ namespace Filtration.Parser.Services | ||||
|                         // Only ever use the last SetTextColor item encountered as multiples aren't valid. | ||||
|                         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; | ||||
|                     } | ||||
|                     case "SetBackgroundColor": | ||||
| @ -201,7 +228,12 @@ namespace Filtration.Parser.Services | ||||
|                         // Only ever use the last SetBackgroundColor item encountered as multiples aren't valid. | ||||
|                         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; | ||||
|                     } | ||||
|                     case "SetBorderColor": | ||||
| @ -209,7 +241,12 @@ namespace Filtration.Parser.Services | ||||
|                         // Only ever use the last SetBorderColor item encountered as multiples aren't valid. | ||||
|                         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; | ||||
|                     } | ||||
|                     case "SetFontSize": | ||||
| @ -217,15 +254,12 @@ namespace Filtration.Parser.Services | ||||
|                         // Only ever use the last SetFontSize item encountered as multiples aren't valid. | ||||
|                         RemoveExistingBlockItemsOfType<FontSizeBlockItem>(block); | ||||
| 
 | ||||
|                         var match = Regex.Matches(trimmedLine, @"(\s+(\d+)\s*)([#]?)(.*)"); | ||||
|                         var match = Regex.Matches(trimmedLine, @"(\s+(\d+)\s*)"); | ||||
|                         if (match.Count > 0) | ||||
|                         { | ||||
|                             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); | ||||
|                             themeComponentType = (int)ThemeComponentType.FontSize; | ||||
|                         } | ||||
|                         break; | ||||
|                     } | ||||
| @ -237,7 +271,7 @@ namespace Filtration.Parser.Services | ||||
|                         RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(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) | ||||
|                         { | ||||
| @ -253,12 +287,6 @@ namespace Filtration.Parser.Services | ||||
|                                 secondValue = 79; | ||||
|                             } | ||||
| 
 | ||||
|                             ThemeComponent themeComponent = null; | ||||
|                             if(match.Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[4].Value)) | ||||
|                             { | ||||
|                                 themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, match.Groups[4].Value.Trim(), firstValue, secondValue); | ||||
|                             } | ||||
| 
 | ||||
|                             if (lineOption == "PlayAlertSound") | ||||
|                             { | ||||
|                                 var blockItemValue = new SoundBlockItem | ||||
| @ -266,7 +294,6 @@ namespace Filtration.Parser.Services | ||||
|                                     Value = firstValue, | ||||
|                                     SecondValue = secondValue | ||||
|                                 }; | ||||
|                                 blockItemValue.ThemeComponent = themeComponent; | ||||
|                                 block.BlockItems.Add(blockItemValue); | ||||
|                             } | ||||
|                             else | ||||
| @ -276,9 +303,9 @@ namespace Filtration.Parser.Services | ||||
|                                     Value = firstValue, | ||||
|                                     SecondValue = secondValue | ||||
|                                 }; | ||||
|                                 blockItemValue.ThemeComponent = themeComponent; | ||||
|                                 block.BlockItems.Add(blockItemValue); | ||||
|                             } | ||||
|                             themeComponentType = (int)ThemeComponentType.AlertSound; | ||||
|                         } | ||||
|                         break; | ||||
|                     } | ||||
| @ -336,6 +363,7 @@ namespace Filtration.Parser.Services | ||||
|                                 blockItemValue.ThemeComponent = themeComponent; | ||||
|                             } | ||||
|                             block.BlockItems.Add(blockItemValue); | ||||
|                             themeComponentType = (int)ThemeComponentType.Icon; | ||||
|                         } | ||||
|                         break; | ||||
|                     } | ||||
| @ -345,7 +373,7 @@ namespace Filtration.Parser.Services | ||||
|                         RemoveExistingBlockItemsOfType<PlayEffectBlockItem>(block); | ||||
|                          | ||||
|                         // 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) | ||||
|                         { | ||||
| @ -354,14 +382,8 @@ namespace Filtration.Parser.Services | ||||
|                                 Color = EnumHelper.GetEnumValueFromDescription<EffectColor>(match.Groups[1].Value), | ||||
|                                 Temporary = match.Groups[2].Value.Trim().ToLower() == "temp" | ||||
|                             }; | ||||
|                                  | ||||
|                             if(match.Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[4].Value)) | ||||
|                             { | ||||
|                                 ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Effect, match.Groups[4].Value.Trim(), | ||||
|                                     blockItemValue.Color, blockItemValue.Temporary); | ||||
|                                 blockItemValue.ThemeComponent = themeComponent; | ||||
|                             } | ||||
|                             block.BlockItems.Add(blockItemValue); | ||||
|                             themeComponentType = (int)ThemeComponentType.Effect; | ||||
|                         } | ||||
|                         break; | ||||
|                     } | ||||
| @ -372,7 +394,7 @@ namespace Filtration.Parser.Services | ||||
|                         RemoveExistingBlockItemsOfType<SoundBlockItem>(block); | ||||
|                         RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block); | ||||
| 
 | ||||
|                         var match = Regex.Match(trimmedLine, @"\S+\s+""(\S+)""\s*([#]?)(.*)"); | ||||
|                         var match = Regex.Match(trimmedLine, @"\S+\s+""(\S+)"""); | ||||
|                          | ||||
|                         if (match.Success) | ||||
|                         { | ||||
| @ -380,13 +402,8 @@ namespace Filtration.Parser.Services | ||||
|                             { | ||||
|                                 Value = match.Groups[1].Value | ||||
|                             }; | ||||
|                                  | ||||
|                             if(match.Groups[2].Value == "#" && !string.IsNullOrWhiteSpace(match.Groups[3].Value)) | ||||
|                             { | ||||
|                                 ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.CustomSound, match.Groups[3].Value.Trim(), blockItemValue.Value); | ||||
|                                 blockItemValue.ThemeComponent = themeComponent; | ||||
|                             } | ||||
|                             block.BlockItems.Add(blockItemValue); | ||||
|                             themeComponentType = (int)ThemeComponentType.CustomSound; | ||||
|                         } | ||||
|                         break; | ||||
|                     } | ||||
| @ -396,8 +413,87 @@ namespace Filtration.Parser.Services | ||||
|                         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; | ||||
|             return block; | ||||
|         } | ||||
| @ -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) | ||||
|         { | ||||
|             // Reverse iterate to remove existing IAudioVisualBlockItems | ||||
| @ -516,36 +570,87 @@ namespace Filtration.Parser.Services | ||||
|             foreach (var line in new LineReader(() => new StringReader(inputString))) | ||||
|             { | ||||
|                 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) | ||||
|                 { | ||||
|                     case "PlayAlertSound": | ||||
|                     { | ||||
|                         var match = Regex.Match(line, @"\s+(\S+) (\d+)"); | ||||
|                         var match = Regex.Match(trimmedLine, @"\s+(\S+) (\d+)"); | ||||
|                         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; | ||||
|                     } | ||||
|                     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; | ||||
|                     } | ||||
|                     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; | ||||
|                     } | ||||
|                     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; | ||||
|                     } | ||||
|                     case "SetFontSize": | ||||
|                     { | ||||
|                         var match = Regex.Match(line, @"\s+(\d+)"); | ||||
|                         var match = Regex.Match(trimmedLine, @"\s+(\d+)"); | ||||
|                         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; | ||||
|                     } | ||||
|                 }  | ||||
|  | ||||
| @ -2,8 +2,8 @@ | ||||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Runtime.InteropServices; | ||||
| using System.Text.RegularExpressions; | ||||
| using System.Windows; | ||||
| using Filtration.Common.Utilities; | ||||
| using Filtration.ObjectModel; | ||||
| using Filtration.ObjectModel.Factories; | ||||
| @ -48,18 +48,58 @@ namespace Filtration.Parser.Services | ||||
|             _itemFilterScriptFactory = itemFilterScriptFactory; | ||||
|         } | ||||
| 
 | ||||
|         public static string PreprocessDisabledBlocks(string inputString) | ||||
|         public static string PreprocessDisabledBlocks(string inputString, out List<bool> inBlock) | ||||
|         { | ||||
|             bool inDisabledBlock = false; | ||||
|             inBlock = new List<bool>(); | ||||
| 
 | ||||
|             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++) | ||||
|             { | ||||
|                 if (!inDisabledBlock && lines[i].StartsWith("#")) | ||||
|                 { | ||||
|                     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; | ||||
|                         lines[i] = lines[i].Substring(1).TrimStart(' '); | ||||
| @ -88,16 +128,29 @@ namespace Filtration.Parser.Services | ||||
|             var script = _itemFilterScriptFactory.Create(); | ||||
|             _blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First()); | ||||
| 
 | ||||
|             //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; | ||||
|             if(Regex.Matches(inputString, @"#Disabled\sBlock\s(Start|End).*?\n").Count > 0) | ||||
|             { | ||||
|                 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"); | ||||
| 
 | ||||
|             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"); | ||||
| 
 | ||||
| @ -158,7 +211,7 @@ namespace Filtration.Parser.Services | ||||
|             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 previousLine = string.Empty; | ||||
| @ -177,9 +230,10 @@ namespace Filtration.Parser.Services | ||||
|                     continue; | ||||
|                 } | ||||
| 
 | ||||
|                 // A line starting with a comment when we're inside a ItemFilterBlock boundary represents the end of that block  | ||||
|                 // as ItemFilterBlocks cannot have comment lines after the block description | ||||
|                 if (trimmedLine.StartsWith("#") && currentItemFilterBlockBoundary.BoundaryType == ItemFilterBlockBoundaryType.ItemFilterBlock) | ||||
|                 // A line starting with a comment when we're inside a ItemFilterBlock boundary may represent the end of that block  | ||||
|                 // or a block item comment | ||||
|                 if (trimmedLine.StartsWith("#") && !inBlock[currentLine] && | ||||
|                     currentItemFilterBlockBoundary.BoundaryType == ItemFilterBlockBoundaryType.ItemFilterBlock) | ||||
|                 { | ||||
|                     blockBoundaries.AddLast(currentItemFilterBlockBoundary); | ||||
|                     currentItemFilterBlockBoundary = new ItemFilterBlockBoundary(currentLine, ItemFilterBlockBoundaryType.CommentBlock); | ||||
|  | ||||
| @ -209,7 +209,7 @@ namespace Filtration.ThemeEditor.ViewModels | ||||
|                     Components.Add(new StrIntThemeComponent(themeComponentType, "Untitled Component", "1", 100)); | ||||
|                     break; | ||||
|                 case ThemeComponentType.CustomSound: | ||||
|                     Components.Add(new StringThemeComponent(themeComponentType, "Untitled Component", "placeholder.mp3")); | ||||
|                     Components.Add(new StringThemeComponent(themeComponentType, "Untitled Component", "")); | ||||
|                     break; | ||||
|                 case ThemeComponentType.Icon: | ||||
|                     Components.Add(new IconThemeComponent(themeComponentType, "Untitled Component", IconSize.Largest, IconColor.Red, IconShape.Circle)); | ||||
|  | ||||
| @ -11,7 +11,7 @@ namespace Filtration.Converters | ||||
|         { | ||||
|             if (values[0] == DependencyProperty.UnsetValue || | ||||
|                 values[1] == DependencyProperty.UnsetValue) | ||||
|                 return null; | ||||
|                 return new Rect(0, 0, 0, 0); | ||||
| 
 | ||||
|             var size = (int)(values[0]); | ||||
|             var color = (int)(values[1]); | ||||
|  | ||||
| Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 106 KiB | 
| Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 84 KiB | 
| Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 107 KiB | 
| Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 96 KiB | 
| Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 83 KiB | 
| Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 77 KiB | 
| @ -251,6 +251,13 @@ namespace Filtration.ViewModels | ||||
|             var newBlockItem = (IItemFilterBlockItem) Activator.CreateInstance(blockItemType); | ||||
| 
 | ||||
|             newBlockItem.PropertyChanged += OnBlockItemChanged; | ||||
| 
 | ||||
|             var customSoundBlockItem = newBlockItem as CustomSoundBlockItem; | ||||
|             if(customSoundBlockItem != null && _parentScriptViewModel.CustomSoundsAvailable.Count > 0) | ||||
|             { | ||||
|                 customSoundBlockItem.Value = _parentScriptViewModel.CustomSoundsAvailable[0]; | ||||
|             } | ||||
| 
 | ||||
|             BlockItems.Add(newBlockItem); | ||||
|             OnBlockItemChanged(this, EventArgs.Empty); | ||||
|             IsDirty = true; | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| using Filtration.ObjectModel; | ||||
| using GalaSoft.MvvmLight.CommandWpf; | ||||
| using System; | ||||
| using System.Text.RegularExpressions; | ||||
| 
 | ||||
| namespace Filtration.ViewModels | ||||
| { | ||||
| @ -61,7 +62,7 @@ namespace Filtration.ViewModels | ||||
|             { | ||||
|                 string[] commentLines = ItemFilterCommentBlock.Comment.Split(new[] { Environment.NewLine }, StringSplitOptions.None); | ||||
|                 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; | ||||
|                     commentLines[0] = commentLines[1]; | ||||
|  | ||||
| @ -166,10 +166,22 @@ namespace Filtration.ViewModels | ||||
| 
 | ||||
|             _viewItemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>(); | ||||
| 
 | ||||
|             _customSoundsAvailable = new ObservableCollection<string> { | ||||
|                 "1maybevaluable.mp3", "2currency.mp3", "3uniques.mp3", "4maps.mp3", "5highmaps.mp3", | ||||
|                 "6veryvaluable.mp3", "7chancing.mp3", "12leveling.mp3", "placeholder.mp3" | ||||
|             }; | ||||
|             _customSoundsAvailable = new ObservableCollection<string>(); | ||||
|              | ||||
|             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) | ||||
|  | ||||