13 Commits
0.19 ... 0.20

Author SHA1 Message Date
Ben Wallis
1e26a2ae3e Merge pull request #62 from GlenCFL/fix-reopen
Fix the reading of CustomAlertSounds containing path separators.
2018-09-01 09:57:54 +01:00
GlenCFL
54b72e44b0 Reposition the new custom sound tests. 2018-08-31 21:06:51 -04:00
GlenCFL
24df1d7687 Fix the reading of CustomAlertSounds containing path separators. 2018-08-31 20:01:21 -04:00
Ben Wallis
7162e16b49 Merge pull request #59 from azakhi/improvements
Improvements
2018-08-31 15:28:18 +01:00
azakhi
324ce4d0b3 Fix binding problem 2018-08-31 17:05:21 +03:00
azakhi
de489e8b2c Fix folder bug 2018-08-31 16:54:24 +03:00
azakhi
341b1d1eb2 Make section header parsing more generic 2018-08-31 16:13:57 +03:00
azakhi
6be29dbd28 Add tests and fix theme bug 2018-08-31 16:02:17 +03:00
azakhi
3851ad51e1 Add support for comments between rules 2018-08-31 14:22:26 +03:00
azakhi
65d3e07156 Add comment support for all rule types 2018-08-31 11:21:43 +03:00
azakhi
a86ab3ec8d Use available sounds as combobox source 2018-08-31 09:40:48 +03:00
azakhi
41722e8a57 Update icons 2018-08-31 09:00:31 +03:00
Ben Wallis
3cb0a041d7 Update README.md 2018-08-30 19:31:45 +01:00
22 changed files with 637 additions and 314 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -405,6 +405,24 @@ namespace Filtration.Parser.Tests.Services
Assert.IsTrue(blockItem.BooleanValue); 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] [Test]
public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject()
{ {
@@ -925,7 +943,10 @@ namespace Filtration.Parser.Tests.Services
" SetBorderColor 0 0 0" + Environment.NewLine + " SetBorderColor 0 0 0" + Environment.NewLine +
" SetFontSize 50" + Environment.NewLine + " SetFontSize 50" + Environment.NewLine +
" PlayAlertSound 3" + Environment.NewLine + " PlayAlertSound 3" + Environment.NewLine +
" DisableDropSound False" + Environment.NewLine; " DisableDropSound False" + Environment.NewLine +
" CustomAlertSound \"test.mp3\" # customSoundTheme" + Environment.NewLine +
" MinimapIcon 2 Green Triangle # iconTheme" + Environment.NewLine +
" PlayEffect Green Temp # effectTheme" + Environment.NewLine;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
@@ -1024,12 +1045,40 @@ namespace Filtration.Parser.Tests.Services
var fontSizeblockItem = result.BlockItems.OfType<FontSizeBlockItem>().First(); var fontSizeblockItem = result.BlockItems.OfType<FontSizeBlockItem>().First();
Assert.AreEqual(50, fontSizeblockItem.Value); Assert.AreEqual(50, fontSizeblockItem.Value);
var soundblockItem = result.BlockItems.OfType<SoundBlockItem>().First(); Assert.AreEqual(0, result.BlockItems.OfType<SoundBlockItem>().Count());
Assert.AreEqual("3", soundblockItem.Value);
Assert.AreEqual(79, soundblockItem.SecondValue);
var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
Assert.IsFalse(disableDropSoundBlockItem.BooleanValue); Assert.IsFalse(disableDropSoundBlockItem.BooleanValue);
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("test.mp3", customSoundBlockItem.Value);
Assert.AreNotEqual(null, customSoundBlockItem.ThemeComponent);
Assert.AreEqual(ThemeComponentType.CustomSound, customSoundBlockItem.ThemeComponent.ComponentType);
Assert.AreEqual("customSoundTheme", customSoundBlockItem.ThemeComponent.ComponentName);
Assert.AreEqual(typeof(StringThemeComponent), customSoundBlockItem.ThemeComponent.GetType());
Assert.AreEqual("test.mp3", ((StringThemeComponent)customSoundBlockItem.ThemeComponent).Value);
var mapIconBlockItem = result.BlockItems.OfType<MapIconBlockItem>().First();
Assert.AreEqual(IconSize.Small, mapIconBlockItem.Size);
Assert.AreEqual(IconColor.Green, mapIconBlockItem.Color);
Assert.AreEqual(IconShape.Triangle, mapIconBlockItem.Shape);
Assert.AreNotEqual(null, mapIconBlockItem.ThemeComponent);
Assert.AreEqual(ThemeComponentType.Icon, mapIconBlockItem.ThemeComponent.ComponentType);
Assert.AreEqual("iconTheme", mapIconBlockItem.ThemeComponent.ComponentName);
Assert.AreEqual(typeof(IconThemeComponent), mapIconBlockItem.ThemeComponent.GetType());
Assert.AreEqual(IconSize.Small, ((IconThemeComponent)mapIconBlockItem.ThemeComponent).IconSize);
Assert.AreEqual(IconColor.Green, ((IconThemeComponent)mapIconBlockItem.ThemeComponent).IconColor);
Assert.AreEqual(IconShape.Triangle, ((IconThemeComponent)mapIconBlockItem.ThemeComponent).IconShape);
var effectColorBlockItem = result.BlockItems.OfType<EffectColorBlockItem>().First();
Assert.AreEqual(EffectColor.Green, effectColorBlockItem.Color);
Assert.IsTrue(effectColorBlockItem.Temporary);
Assert.AreNotEqual(null, effectColorBlockItem.ThemeComponent);
Assert.AreEqual(ThemeComponentType.Effect, effectColorBlockItem.ThemeComponent.ComponentType);
Assert.AreEqual("effectTheme", effectColorBlockItem.ThemeComponent.ComponentName);
Assert.AreEqual(typeof(EffectColorThemeComponent), effectColorBlockItem.ThemeComponent.GetType());
Assert.AreEqual(EffectColor.Green, ((EffectColorThemeComponent)effectColorBlockItem.ThemeComponent).EffectColor);
Assert.IsTrue(((EffectColorThemeComponent)effectColorBlockItem.ThemeComponent).Temporary);
} }
[Test] [Test]
@@ -1257,6 +1306,86 @@ namespace Filtration.Parser.Tests.Services
Assert.AreEqual(ItemRarity.Magic, (ItemRarity)rarityBlockItem.FilterPredicate.PredicateOperand); Assert.AreEqual(ItemRarity.Magic, (ItemRarity)rarityBlockItem.FilterPredicate.PredicateOperand);
} }
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundDocumentsFile()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"test.mp3\"";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("test.mp3", customSoundBlockItem.Value);
}
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundDocumentsRelativeFile()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"Sounds\test.mp3\"";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("Sounds\test.mp3", customSoundBlockItem.Value);
}
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundFullBackSlashPath()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"C:\\Sounds\\test.mp3\"";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("C:\\Sounds\\test.mp3", customSoundBlockItem.Value);
}
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundFullForwardSlashPath()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"C:/Sounds/test.mp3\"";
//Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("C:/Sounds/test.mp3", customSoundBlockItem.Value);
}
[Test]
public void TranslateStringToItemFilterBlock_CustomSoundFullMixedPath()
{
// Arrange
var inputString = @"Show" + Environment.NewLine +
"CustomAlertSound \"C:\\Sounds/test.mp3\"";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is CustomSoundBlockItem));
var customSoundBlockItem = result.BlockItems.OfType<CustomSoundBlockItem>().First();
Assert.AreEqual("C:\\Sounds/test.mp3", customSoundBlockItem.Value);
}
[Test] [Test]
public void TranslateItemFilterBlockToString_NothingPopulated_ReturnsCorrectString() public void TranslateItemFilterBlockToString_NothingPopulated_ReturnsCorrectString()
{ {

View File

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

View File

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

View File

@@ -63,13 +63,35 @@ namespace Filtration.Parser.Services
foreach (var line in new LineReader(() => new StringReader(inputString))) foreach (var line in new LineReader(() => new StringReader(inputString)))
{ {
if (line.StartsWith(@"#") && !showHideFound) if (line.StartsWith(@"#"))
{
if(!showHideFound)
{ {
block.Description = line.TrimStart('#').TrimStart(' '); block.Description = line.TrimStart('#').TrimStart(' ');
}
else
{
if(block.BlockItems.Count > 1)
{
block.BlockItems.Last().Comment += Environment.NewLine + line.TrimStart('#');
}
else
{
block.ActionBlockItem.Comment += Environment.NewLine + line.TrimStart('#');
}
}
continue; continue;
} }
var trimmedLine = line.Trim(); var fullLine = line.Trim();
var trimmedLine = fullLine;
var blockComment = "";
var themeComponentType = -1;
if(trimmedLine.IndexOf('#') > 0)
{
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
}
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length; var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos); var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
@@ -88,11 +110,11 @@ namespace Filtration.Parser.Services
// group hierarchy, if block groups are disabled it is preserved as a simple text comment. // group hierarchy, if block groups are disabled it is preserved as a simple text comment.
if (parentItemFilterScript.ItemFilterScriptSettings.BlockGroupsEnabled) if (parentItemFilterScript.ItemFilterScriptSettings.BlockGroupsEnabled)
{ {
AddBlockGroupToBlock(block, trimmedLine); AddBlockGroupToBlock(block, fullLine);
} }
else else
{ {
block.ActionBlockItem.Comment = GetTextAfterFirstComment(trimmedLine); block.ActionBlockItem.Comment = GetTextAfterFirstComment(fullLine);
} }
break; break;
} }
@@ -193,7 +215,12 @@ namespace Filtration.Parser.Services
// Only ever use the last SetTextColor item encountered as multiples aren't valid. // Only ever use the last SetTextColor item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<TextColorBlockItem>(block); RemoveExistingBlockItemsOfType<TextColorBlockItem>(block);
AddColorItemToBlockItems<TextColorBlockItem>(block, trimmedLine); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new TextColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.TextColor;
break; break;
} }
case "SetBackgroundColor": case "SetBackgroundColor":
@@ -201,7 +228,12 @@ namespace Filtration.Parser.Services
// Only ever use the last SetBackgroundColor item encountered as multiples aren't valid. // Only ever use the last SetBackgroundColor item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<BackgroundColorBlockItem>(block); RemoveExistingBlockItemsOfType<BackgroundColorBlockItem>(block);
AddColorItemToBlockItems<BackgroundColorBlockItem>(block, trimmedLine); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BackgroundColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.BackgroundColor;
break; break;
} }
case "SetBorderColor": case "SetBorderColor":
@@ -209,7 +241,12 @@ namespace Filtration.Parser.Services
// Only ever use the last SetBorderColor item encountered as multiples aren't valid. // Only ever use the last SetBorderColor item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<BorderColorBlockItem>(block); RemoveExistingBlockItemsOfType<BorderColorBlockItem>(block);
AddColorItemToBlockItems<BorderColorBlockItem>(block, trimmedLine); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BorderColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.BorderColor;
break; break;
} }
case "SetFontSize": case "SetFontSize":
@@ -217,15 +254,12 @@ namespace Filtration.Parser.Services
// Only ever use the last SetFontSize item encountered as multiples aren't valid. // Only ever use the last SetFontSize item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<FontSizeBlockItem>(block); RemoveExistingBlockItemsOfType<FontSizeBlockItem>(block);
var match = Regex.Matches(trimmedLine, @"(\s+(\d+)\s*)([#]?)(.*)"); var match = Regex.Matches(trimmedLine, @"(\s+(\d+)\s*)");
if (match.Count > 0) if (match.Count > 0)
{ {
var blockItem = new FontSizeBlockItem(Convert.ToInt16(match[0].Groups[2].Value)); var blockItem = new FontSizeBlockItem(Convert.ToInt16(match[0].Groups[2].Value));
if(match[0].Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match[0].Groups[4].Value))
{
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize, match[0].Groups[4].Value.Trim(), blockItem.Value);
}
block.BlockItems.Add(blockItem); block.BlockItems.Add(blockItem);
themeComponentType = (int)ThemeComponentType.FontSize;
} }
break; break;
} }
@@ -237,7 +271,7 @@ namespace Filtration.Parser.Services
RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block); RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block);
RemoveExistingBlockItemsOfType<CustomSoundBlockItem>(block); RemoveExistingBlockItemsOfType<CustomSoundBlockItem>(block);
var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?\s*([#]?)(.*)"); var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?");
if (match.Success) if (match.Success)
{ {
@@ -253,12 +287,6 @@ namespace Filtration.Parser.Services
secondValue = 79; 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") if (lineOption == "PlayAlertSound")
{ {
var blockItemValue = new SoundBlockItem var blockItemValue = new SoundBlockItem
@@ -266,7 +294,6 @@ namespace Filtration.Parser.Services
Value = firstValue, Value = firstValue,
SecondValue = secondValue SecondValue = secondValue
}; };
blockItemValue.ThemeComponent = themeComponent;
block.BlockItems.Add(blockItemValue); block.BlockItems.Add(blockItemValue);
} }
else else
@@ -276,9 +303,9 @@ namespace Filtration.Parser.Services
Value = firstValue, Value = firstValue,
SecondValue = secondValue SecondValue = secondValue
}; };
blockItemValue.ThemeComponent = themeComponent;
block.BlockItems.Add(blockItemValue); block.BlockItems.Add(blockItemValue);
} }
themeComponentType = (int)ThemeComponentType.AlertSound;
} }
break; break;
} }
@@ -336,6 +363,7 @@ namespace Filtration.Parser.Services
blockItemValue.ThemeComponent = themeComponent; blockItemValue.ThemeComponent = themeComponent;
} }
block.BlockItems.Add(blockItemValue); block.BlockItems.Add(blockItemValue);
themeComponentType = (int)ThemeComponentType.Icon;
} }
break; break;
} }
@@ -345,7 +373,7 @@ namespace Filtration.Parser.Services
RemoveExistingBlockItemsOfType<PlayEffectBlockItem>(block); RemoveExistingBlockItemsOfType<PlayEffectBlockItem>(block);
// TODO: Get colors programmatically // TODO: Get colors programmatically
var match = Regex.Match(trimmedLine, @"\S+\s+(Red|Green|Blue|Brown|White|Yellow)\s*(Temp)?\s*([#]?)(.*)", RegexOptions.IgnoreCase); var match = Regex.Match(trimmedLine, @"\S+\s+(Red|Green|Blue|Brown|White|Yellow)\s*(Temp)?", RegexOptions.IgnoreCase);
if (match.Success) if (match.Success)
{ {
@@ -354,14 +382,8 @@ namespace Filtration.Parser.Services
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"
}; };
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); block.BlockItems.Add(blockItemValue);
themeComponentType = (int)ThemeComponentType.Effect;
} }
break; break;
} }
@@ -372,7 +394,7 @@ namespace Filtration.Parser.Services
RemoveExistingBlockItemsOfType<SoundBlockItem>(block); RemoveExistingBlockItemsOfType<SoundBlockItem>(block);
RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block); RemoveExistingBlockItemsOfType<PositionalSoundBlockItem>(block);
var match = Regex.Match(trimmedLine, @"\S+\s+""(\S+)""\s*([#]?)(.*)"); var match = Regex.Match(trimmedLine, @"\S+\s+""([^\*\<\>\?|]+)""");
if (match.Success) if (match.Success)
{ {
@@ -380,13 +402,8 @@ namespace Filtration.Parser.Services
{ {
Value = match.Groups[1].Value 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); block.BlockItems.Add(blockItemValue);
themeComponentType = (int)ThemeComponentType.CustomSound;
} }
break; break;
} }
@@ -396,8 +413,87 @@ namespace Filtration.Parser.Services
break; break;
} }
} }
}
if (!string.IsNullOrWhiteSpace(blockComment) && block.BlockItems.Count > 1)
{
var blockItemWithTheme = block.BlockItems.Last() as IBlockItemWithTheme;
if(blockItemWithTheme == null)
{
block.BlockItems.Last().Comment = blockComment;
}
else
{
switch((ThemeComponentType)themeComponentType)
{
case ThemeComponentType.AlertSound:
{
ThemeComponent themeComponent = null;
if(blockItemWithTheme is SoundBlockItem)
{
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
((SoundBlockItem)blockItemWithTheme).Value, ((SoundBlockItem)blockItemWithTheme).SecondValue);
}
else
{
themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound, blockComment.Trim(),
((PositionalSoundBlockItem)blockItemWithTheme).Value, ((PositionalSoundBlockItem)blockItemWithTheme).SecondValue);
}
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.BackgroundColor:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
blockComment.Trim(), ((BackgroundColorBlockItem)blockItemWithTheme).Color);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.BorderColor:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
blockComment.Trim(), ((BorderColorBlockItem)blockItemWithTheme).Color);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.CustomSound:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.CustomSound,
blockComment.Trim(), ((CustomSoundBlockItem)blockItemWithTheme).Value);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.Effect:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Effect,
blockComment.Trim(), ((EffectColorBlockItem)blockItemWithTheme).Color, ((EffectColorBlockItem)blockItemWithTheme).Temporary);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.FontSize:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize,
blockComment.Trim(), ((FontSizeBlockItem)blockItemWithTheme).Value);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.Icon:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.Icon, blockComment.Trim(),
((IconBlockItem)blockItemWithTheme).Size, ((IconBlockItem)blockItemWithTheme).Color, ((IconBlockItem)blockItemWithTheme).Shape);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
case ThemeComponentType.TextColor:
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
blockComment.Trim(), ((TextColorBlockItem)blockItemWithTheme).Color);
blockItemWithTheme.ThemeComponent = themeComponent;
break;
}
}
}
}
}
block.IsEdited = false; block.IsEdited = false;
return block; return block;
} }
@@ -460,48 +556,6 @@ namespace Filtration.Parser.Services
} }
} }
private void AddColorItemToBlockItems<T>(IItemFilterBlock block, string inputString) where T : ColorBlockItem
{
block.BlockItems.Add(GetColorBlockItemFromString<T>(inputString));
}
private T GetColorBlockItemFromString<T>(string inputString) where T: ColorBlockItem
{
var blockItem = Activator.CreateInstance<T>();
var result = Regex.Matches(inputString, @"([\w\s]*)[#]?(.*)");
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
var componentName = result[0].Groups[2].Value.Trim();
if (!string.IsNullOrEmpty(componentName))
{
ThemeComponentType componentType;
if (typeof(T) == typeof(TextColorBlockItem))
{
componentType = ThemeComponentType.TextColor;
}
else if (typeof(T) == typeof(BackgroundColorBlockItem))
{
componentType = ThemeComponentType.BackgroundColor;
}
else if (typeof(T) == typeof(BorderColorBlockItem))
{
componentType = ThemeComponentType.BorderColor;
}
else
{
throw new Exception("Parsing error - unknown theme component type");
}
if (_masterComponentCollection != null)
{
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(componentType, componentName,
blockItem.Color);
}
}
return blockItem;
}
public void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString) public void ReplaceAudioVisualBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString)
{ {
// Reverse iterate to remove existing IAudioVisualBlockItems // Reverse iterate to remove existing IAudioVisualBlockItems
@@ -516,36 +570,87 @@ namespace Filtration.Parser.Services
foreach (var line in new LineReader(() => new StringReader(inputString))) foreach (var line in new LineReader(() => new StringReader(inputString)))
{ {
var matches = Regex.Match(line, @"(\w+)"); var matches = Regex.Match(line, @"(\w+)");
var blockComment = "";
var trimmedLine = line.Trim();
if (trimmedLine.IndexOf('#') > 0)
{
blockComment = trimmedLine.Substring(trimmedLine.IndexOf('#') + 1);
trimmedLine = trimmedLine.Substring(0, trimmedLine.IndexOf('#')).Trim();
}
switch (matches.Value) switch (matches.Value)
{ {
case "PlayAlertSound": case "PlayAlertSound":
{ {
var match = Regex.Match(line, @"\s+(\S+) (\d+)"); var match = Regex.Match(trimmedLine, @"\s+(\S+) (\d+)");
if (!match.Success) break; if (!match.Success) break;
blockItems.Add(new SoundBlockItem(match.Groups[1].Value, Convert.ToInt16(match.Groups[2].Value))); var blockItem = new SoundBlockItem(match.Groups[1].Value, Convert.ToInt16(match.Groups[2].Value));
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.AlertSound,
blockComment, blockItem.Value, blockItem.SecondValue);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
case "SetTextColor": case "SetTextColor":
{ {
blockItems.Add(GetColorBlockItemFromString<TextColorBlockItem>(line)); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new TextColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.TextColor,
blockComment, blockItem.Color);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
case "SetBackgroundColor": case "SetBackgroundColor":
{ {
blockItems.Add(GetColorBlockItemFromString<BackgroundColorBlockItem>(line)); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BackgroundColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BackgroundColor,
blockComment, blockItem.Color);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
case "SetBorderColor": case "SetBorderColor":
{ {
blockItems.Add(GetColorBlockItemFromString<BorderColorBlockItem>(line)); var result = Regex.Matches(trimmedLine, @"([\w\s]*)");
var blockItem = new BorderColorBlockItem();
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
if(_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.BorderColor,
blockComment, blockItem.Color);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
case "SetFontSize": case "SetFontSize":
{ {
var match = Regex.Match(line, @"\s+(\d+)"); var match = Regex.Match(trimmedLine, @"\s+(\d+)");
if (!match.Success) break; if (!match.Success) break;
blockItems.Add(new FontSizeBlockItem(Convert.ToInt16(match.Value))); var blockItem = new FontSizeBlockItem(Convert.ToInt16(match.Value));
if (_masterComponentCollection != null && !string.IsNullOrWhiteSpace(blockComment))
{
ThemeComponent themeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize,
blockComment, blockItem.Value);
blockItem.ThemeComponent = themeComponent;
}
blockItems.Add(blockItem);
break; break;
} }
} }

View File

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

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

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

View File

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

View File

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

View File

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