7 Commits

Author SHA1 Message Date
Ben Wallis
992bd21570 Fixed UpdateService which was erroneously using the local update manager instead of the GitHub update manager for several parts of the update process 2018-09-28 20:24:09 +01:00
Ben Wallis
7d8b32b2e7 Fixup after merging missed commit from master 2018-09-28 17:58:16 +01:00
Ben Wallis
ac904c31ff * Added default colours for TextColor, BorderColor and BackgroundColor block items (previously the default color was completely transparent)
* Bumped version to 1.0.0-beta3
2018-09-28 17:47:23 +01:00
Ben Wallis
0209de3817 Update README.md 2018-09-01 10:15:38 +01:00
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
13 changed files with 900 additions and 782 deletions

View File

@@ -7,6 +7,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
{ {
public BackgroundColorBlockItem() public BackgroundColorBlockItem()
{ {
Color = new Color { A = 240, R = 0, G = 0, B = 0 };
} }
public BackgroundColorBlockItem(Color color) : base(color) public BackgroundColorBlockItem(Color color) : base(color)

View File

@@ -7,6 +7,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
{ {
public BorderColorBlockItem() public BorderColorBlockItem()
{ {
Color = new Color {A = 240, R = 0, G = 0, B = 0};
} }
public BorderColorBlockItem(Color color) : base(color) public BorderColorBlockItem(Color color) : base(color)

View File

@@ -1,5 +1,6 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
@@ -7,6 +8,7 @@ namespace Filtration.ObjectModel.BlockItemTypes
{ {
public TextColorBlockItem() public TextColorBlockItem()
{ {
Color = PathOfExileNamedColors.Colors[PathOfExileNamedColor.WhiteItem];
} }
public TextColorBlockItem(Color color) : base(color) public TextColorBlockItem(Color color) : base(color)

View File

@@ -94,7 +94,7 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var inputString = "HideDisabled" + Environment.NewLine + var inputString = "HideDisabled" + Environment.NewLine +
" ItemLevel >= 55"; " ItemLevel >= 55";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
@@ -374,37 +374,37 @@ namespace Filtration.Parser.Tests.Services
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_ElderItem_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_ElderItem_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ElderItem False"; " ElderItem False";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderItemBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderItemBlockItem));
var blockItem = result.BlockItems.OfType<ElderItemBlockItem>().First(); var blockItem = result.BlockItems.OfType<ElderItemBlockItem>().First();
Assert.IsFalse(blockItem.BooleanValue); Assert.IsFalse(blockItem.BooleanValue);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_ShaperItem_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_ShaperItem_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ShaperItem True"; " ShaperItem True";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ShaperItemBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ShaperItemBlockItem));
var blockItem = result.BlockItems.OfType<ShaperItemBlockItem>().First(); var blockItem = result.BlockItems.OfType<ShaperItemBlockItem>().First();
Assert.IsTrue(blockItem.BooleanValue); Assert.IsTrue(blockItem.BooleanValue);
} }
[Test] [Test]
@@ -426,37 +426,37 @@ namespace Filtration.Parser.Tests.Services
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_ShapedMap_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ShapedMap false"; " ShapedMap false";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ShapedMapBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ShapedMapBlockItem));
var blockItem = result.BlockItems.OfType<ShapedMapBlockItem>().First(); var blockItem = result.BlockItems.OfType<ShapedMapBlockItem>().First();
Assert.IsFalse(blockItem.BooleanValue); Assert.IsFalse(blockItem.BooleanValue);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_ElderMap_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_ElderMap_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ElderMap false"; " ElderMap false";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderMapBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ElderMapBlockItem));
var blockItem = result.BlockItems.OfType<ElderMapBlockItem>().First(); var blockItem = result.BlockItems.OfType<ElderMapBlockItem>().First();
Assert.IsFalse(blockItem.BooleanValue); Assert.IsFalse(blockItem.BooleanValue);
} }
[Test] [Test]
@@ -795,7 +795,7 @@ namespace Filtration.Parser.Tests.Services
" SetTextColor 255 20 100 # Rare Item Text"; " SetTextColor 255 20 100 # Rare Item Text";
var testComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { A = 240, R = 255, G = 20, B = 100}); var testComponent = new ColorThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { A = 240, R = 255, G = 20, B = 100});
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent }; var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, Mock.Of<IItemFilterScript>(i => i.ItemFilterScriptSettings.ThemeComponentCollection == testInputThemeComponentCollection)); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, Mock.Of<IItemFilterScript>(i => i.ItemFilterScriptSettings.ThemeComponentCollection == testInputThemeComponentCollection));
@@ -896,22 +896,22 @@ namespace Filtration.Parser.Tests.Services
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_DisableDropSound_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_DisableDropSound_ReturnsCorrectObject()
{ {
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" DisableDropSound True"; " DisableDropSound True";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is DisableDropSoundBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is DisableDropSoundBlockItem));
var blockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); var blockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
Assert.IsTrue(blockItem.BooleanValue); Assert.IsTrue(blockItem.BooleanValue);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject()
{ {
@@ -1046,7 +1046,7 @@ namespace Filtration.Parser.Tests.Services
var fontSizeblockItem = result.BlockItems.OfType<FontSizeBlockItem>().First(); var fontSizeblockItem = result.BlockItems.OfType<FontSizeBlockItem>().First();
Assert.AreEqual(50, fontSizeblockItem.Value); Assert.AreEqual(50, fontSizeblockItem.Value);
Assert.AreEqual(0, result.BlockItems.OfType<SoundBlockItem>().Count()); Assert.AreEqual(0, result.BlockItems.OfType<SoundBlockItem>().Count());
var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First(); var disableDropSoundBlockItem = result.BlockItems.OfType<DisableDropSoundBlockItem>().First();
@@ -1089,9 +1089,9 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" ItemLevel >= 70" + Environment.NewLine + " ItemLevel >= 70" + Environment.NewLine +
" ItemLevel <= 80" + Environment.NewLine + " ItemLevel <= 80" + Environment.NewLine +
" Quality = 15" + Environment.NewLine + " Quality = 15" + Environment.NewLine +
" Quality < 17"; " Quality < 17";
// Act // Act
@@ -1152,7 +1152,7 @@ namespace Filtration.Parser.Tests.Services
var blockItem = result.BlockItems.OfType<FontSizeBlockItem>().First(); var blockItem = result.BlockItems.OfType<FontSizeBlockItem>().First();
Assert.AreEqual(27, blockItem.Value); Assert.AreEqual(27, blockItem.Value);
} }
[Test] [Test]
public void TranslateStringToItemFilterBlock_MultipleSoundItems_OnlyLastOneUsed() public void TranslateStringToItemFilterBlock_MultipleSoundItems_OnlyLastOneUsed()
{ {
@@ -1308,6 +1308,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()
{ {
@@ -1328,13 +1408,13 @@ namespace Filtration.Parser.Tests.Services
{ {
// Arrange // Arrange
var expectedResult = "Show # Child 1 Block Group - Child 2 Block Group"; var expectedResult = "Show # Child 1 Block Group - Child 2 Block Group";
var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null); var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup); var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup);
var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup); var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup);
_testUtility.TestBlock.BlockGroup = child2BlockGroup; _testUtility.TestBlock.BlockGroup = child2BlockGroup;
// TODO: Shouldn't be set to edited this way // TODO: Shouldn't be set to edited this way
_testUtility.TestBlock.IsEdited = true; _testUtility.TestBlock.IsEdited = true;
// Act // Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock); var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
@@ -1853,7 +1933,7 @@ namespace Filtration.Parser.Tests.Services
{ {
// Arrange // Arrange
var expectedResult = "Show" + Environment.NewLine + var expectedResult = "Show" + Environment.NewLine +
" ItemLevel > 56" + Environment.NewLine + " ItemLevel > 56" + Environment.NewLine +
" ItemLevel >= 45" + Environment.NewLine + " ItemLevel >= 45" + Environment.NewLine +
" ItemLevel < 100"; " ItemLevel < 100";
@@ -1895,7 +1975,7 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var expectedResult = "#Show" + Environment.NewLine + var expectedResult = "#Show" + Environment.NewLine +
"# Width = 4"; "# Width = 4";
_testUtility.TestBlock.Enabled = false; _testUtility.TestBlock.Enabled = false;
_testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4)); _testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4));
@@ -1942,7 +2022,7 @@ namespace Filtration.Parser.Tests.Services
" DisableDropSound True" + Environment.NewLine + " DisableDropSound True" + Environment.NewLine +
" MinimapIcon 1 Blue Circle" + Environment.NewLine + " MinimapIcon 1 Blue Circle" + Environment.NewLine +
" PlayEffect Red Temp" + Environment.NewLine + " PlayEffect Red Temp" + Environment.NewLine +
" CustomAlertSound \"test.mp3\""; " CustomAlertSound \"test.mp3\"";
_testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show)); _testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show));
_testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true)); _testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true));
@@ -2010,7 +2090,7 @@ namespace Filtration.Parser.Tests.Services
// Act // Act
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString); _testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
// Assert // Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem; var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem); Assert.IsNotNull(textColorBlockItem);
@@ -2085,7 +2165,7 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine + var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine + "SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
"SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine + "SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine +
"PlayAlertSound 7 280"; "PlayAlertSound 7 280";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>(); var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
@@ -2131,9 +2211,9 @@ namespace Filtration.Parser.Tests.Services
// Arrange // Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine + var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine + "SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
"SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine + "SetBorderColor 255 255 255 # Rarest Currency Border" + Environment.NewLine +
"PlayAlertSound 7 280"; "PlayAlertSound 7 280";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>(); var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
// Act // Act
@@ -2203,9 +2283,9 @@ namespace Filtration.Parser.Tests.Services
_testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString); _testUtility.Translator.ReplaceAudioVisualBlockItemsFromString(testInputBlockItems, testInputString);
// Assert // Assert
} }
private class ItemFilterBlockTranslatorTestUtility private class ItemFilterBlockTranslatorTestUtility
{ {
public ItemFilterBlockTranslatorTestUtility() public ItemFilterBlockTranslatorTestUtility()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Filtration.Enums
{
internal enum UpdateSource
{
GitHub,
Local
}
}

View File

@@ -203,6 +203,7 @@
<Compile Include="Converters\HashSignRemovalConverter.cs" /> <Compile Include="Converters\HashSignRemovalConverter.cs" />
<Compile Include="Converters\ItemRarityConverter.cs" /> <Compile Include="Converters\ItemRarityConverter.cs" />
<Compile Include="Converters\TreeViewMarginConverter.cs" /> <Compile Include="Converters\TreeViewMarginConverter.cs" />
<Compile Include="Enums\UpdateSource.cs" />
<Compile Include="Models\UpdateData.cs" /> <Compile Include="Models\UpdateData.cs" />
<Compile Include="Properties\Annotations.cs" /> <Compile Include="Properties\Annotations.cs" />
<Compile Include="Repositories\ItemFilterScriptRepository.cs" /> <Compile Include="Repositories\ItemFilterScriptRepository.cs" />

View File

@@ -11,7 +11,7 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.0")] [assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0-beta2")] [assembly: AssemblyInformationalVersion("1.0.0-beta3")]
[assembly: InternalsVisibleTo("Filtration.Tests")] [assembly: InternalsVisibleTo("Filtration.Tests")]
[assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")] [assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")]

View File

@@ -39,7 +39,7 @@ namespace Filtration.Services
_mainWindow.Show(); _mainWindow.Show();
await _updateService.CheckForUpdates(); await _updateService.CheckForUpdatesAsync();
} }
private void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e) private void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e)

View File

@@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Filtration.Enums;
using Filtration.Properties; using Filtration.Properties;
using NLog; using NLog;
using Squirrel; using Squirrel;
@@ -52,7 +53,7 @@ namespace Filtration.Services
string LatestReleaseVersion { get; } string LatestReleaseVersion { get; }
Task CheckForUpdates(); Task CheckForUpdatesAsync();
Task DownloadUpdatesAsync(); Task DownloadUpdatesAsync();
@@ -63,13 +64,16 @@ namespace Filtration.Services
internal class UpdateService : IUpdateService internal class UpdateService : IUpdateService
{ {
private readonly ISettingsService _settingsService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private const string _localUpdatePath = @"C:\Repos\Filtration\Releases"; private const string _localUpdatePath = @"C:\Repos\Filtration\Releases";
private readonly ISettingsService _settingsService;
private readonly UpdateSource _updateSource = UpdateSource.GitHub;
private ReleaseEntry _latestRelease; private ReleaseEntry _latestRelease;
private UpdateInfo _updates; private UpdateInfo _updates;
private bool _downloadPrereleaseUpdates;
private UpdateStatus _updateStatus; private UpdateStatus _updateStatus;
public UpdateService(ISettingsService settingsService) public UpdateService(ISettingsService settingsService)
@@ -96,35 +100,42 @@ namespace Filtration.Services
public string LatestReleaseVersion { get; private set; } public string LatestReleaseVersion { get; private set; }
public async Task CheckForUpdates() public async Task CheckForUpdatesAsync()
{ {
if (UpdateStatus != UpdateStatus.NoUpdateAvailable) if (UpdateStatus != UpdateStatus.NoUpdateAvailable)
{ {
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
Logger.Debug("Checking for update..."); Logger.Debug("Checking for update...");
UpdateStatus = UpdateStatus.CheckingForUpdate; UpdateStatus = UpdateStatus.CheckingForUpdate;
try try
{ {
bool downloadPrereleaseUpdates; _downloadPrereleaseUpdates = Settings.Default.DownloadPrereleaseUpdates;
downloadPrereleaseUpdates = Settings.Default.DownloadPrereleaseUpdates;
#if DEBUG #if DEBUG
downloadPrereleaseUpdates = true; _downloadPrereleaseUpdates = true;
#endif #endif
using (var mgr = await UpdateManager.GitHubUpdateManager("https://github.com/ben-wallis/Filtration", prerelease: downloadPrereleaseUpdates))
async Task CheckForUpdatesAsync(IUpdateManager updateManager)
{ {
_updates = await mgr.CheckForUpdate(progress: progress => UpdateProgressChanged?.Invoke(this, new UpdateProgressChangedEventArgs(progress))); _updates = await updateManager.CheckForUpdate(progress: progress => UpdateProgressChanged?.Invoke(this, new UpdateProgressChangedEventArgs(progress)));
} }
// Local file update source for testing if (_updateSource == UpdateSource.GitHub)
//using (var mgr = new UpdateManager(_localUpdatePath)) {
//{ using (var updateManager = await UpdateManager.GitHubUpdateManager("https://github.com/ben-wallis/Filtration", prerelease: _downloadPrereleaseUpdates))
{
// _updates = await mgr.CheckForUpdate(progress: progress => UpdateProgressChanged?.Invoke(this, new UpdateProgressChangedEventArgs(progress))); await CheckForUpdatesAsync(updateManager);
//} }
}
else
{
using (var updateManager = new UpdateManager(_localUpdatePath))
{
await CheckForUpdatesAsync(updateManager);
}
}
} }
catch (Exception e) catch (Exception e)
{ {
@@ -133,26 +144,13 @@ namespace Filtration.Services
return; return;
} }
if (_updates.ReleasesToApply.Any()) if (_updates.ReleasesToApply.Any())
{ {
_latestRelease = _updates.ReleasesToApply.OrderBy(x => x.Version).Last(); _latestRelease = _updates.ReleasesToApply.OrderBy(x => x.Version).Last();
LatestReleaseVersion = _latestRelease.Version.ToString(); LatestReleaseVersion = _latestRelease.Version.ToString();
Logger.Debug($"Update found ({LatestReleaseVersion}), fetching release notes..."); Logger.Debug($"Update found ({LatestReleaseVersion})");
try
{
var releaseNotes = _latestRelease.GetReleaseNotes(_localUpdatePath);
LatestReleaseNotes = ProcessReleaseNotes(releaseNotes);
}
catch (Exception e)
{
Logger.Error(e);
UpdateStatus = UpdateStatus.Error;
return;
}
UpdateStatus = UpdateStatus.UpdateAvailable; UpdateStatus = UpdateStatus.UpdateAvailable;
} }
else else
@@ -162,7 +160,7 @@ namespace Filtration.Services
} }
} }
private string ProcessReleaseNotes(string rawReleaseNotes) private static string ProcessReleaseNotes(string rawReleaseNotes)
{ {
var regex = new Regex(@"<!\[CDATA\[(.*)]]>", RegexOptions.Singleline); var regex = new Regex(@"<!\[CDATA\[(.*)]]>", RegexOptions.Singleline);
var matches = regex.Match(rawReleaseNotes); var matches = regex.Match(rawReleaseNotes);
@@ -184,11 +182,31 @@ namespace Filtration.Services
UpdateStatus = UpdateStatus.Downloading; UpdateStatus = UpdateStatus.Downloading;
async Task DownloadUpdatesAsync(IUpdateManager updateManager)
{
Logger.Debug("Downloading update...");
await updateManager.DownloadReleases(_updates.ReleasesToApply, OnProgressChanged);
Logger.Debug("Fetching release notes...");
var releaseNotes = _updates.FetchReleaseNotes();
LatestReleaseNotes = ProcessReleaseNotes(releaseNotes[_latestRelease]);
}
try try
{ {
using (var updateManager = new UpdateManager(_localUpdatePath)) if (_updateSource == UpdateSource.GitHub)
{ {
await updateManager.DownloadReleases(_updates.ReleasesToApply, OnProgressChanged); using (var updateManager = await UpdateManager.GitHubUpdateManager("https://github.com/ben-wallis/Filtration", prerelease: _downloadPrereleaseUpdates))
{
await DownloadUpdatesAsync(updateManager);
}
}
else
{
using (var updateManager = new UpdateManager(_localUpdatePath))
{
await DownloadUpdatesAsync(updateManager);
}
} }
} }
catch (Exception e) catch (Exception e)
@@ -215,11 +233,22 @@ namespace Filtration.Services
// wipes out user settings due to the application directory changing with each update // wipes out user settings due to the application directory changing with each update
_settingsService.BackupSettings(); _settingsService.BackupSettings();
Logger.Debug("Applying update...");
try try
{ {
using (var updateManager = new UpdateManager(_localUpdatePath)) if (_updateSource == UpdateSource.GitHub)
{ {
await updateManager.ApplyReleases(_updates, OnProgressChanged); using (var mgr = await UpdateManager.GitHubUpdateManager("https://github.com/ben-wallis/Filtration", prerelease: _downloadPrereleaseUpdates))
{
await mgr.ApplyReleases(_updates, OnProgressChanged);
}
}
else
{
using (var updateManager = new UpdateManager(_localUpdatePath))
{
await updateManager.ApplyReleases(_updates, OnProgressChanged);
}
} }
} }
catch (Exception e) catch (Exception e)
@@ -229,6 +258,7 @@ namespace Filtration.Services
return; return;
} }
Logger.Debug("Update complete");
UpdateStatus = UpdateStatus.UpdateComplete; UpdateStatus = UpdateStatus.UpdateComplete;
} }

View File

@@ -15,6 +15,7 @@ using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
using Microsoft.Win32; using Microsoft.Win32;
using Xceed.Wpf.Toolkit; using Xceed.Wpf.Toolkit;
using static System.Int32;
namespace Filtration.ViewModels namespace Filtration.ViewModels
{ {
@@ -59,8 +60,7 @@ namespace Filtration.ViewModels
public override void Initialise(IItemFilterBlockBase itemFilterBlockBase, IItemFilterScriptViewModel parentScriptViewModel) public override void Initialise(IItemFilterBlockBase itemFilterBlockBase, IItemFilterScriptViewModel parentScriptViewModel)
{ {
var itemFilterBlock = itemFilterBlockBase as IItemFilterBlock; if (!(itemFilterBlockBase is IItemFilterBlock itemFilterBlock) || parentScriptViewModel == null)
if (itemFilterBlock == null || parentScriptViewModel == null)
{ {
throw new ArgumentNullException(nameof(itemFilterBlock)); throw new ArgumentNullException(nameof(itemFilterBlock));
} }
@@ -136,7 +136,7 @@ namespace Filtration.ViewModels
public bool AudioVisualBlockItemsGridVisible public bool AudioVisualBlockItemsGridVisible
{ {
get { return _audioVisualBlockItemsGridVisible; } get => _audioVisualBlockItemsGridVisible;
set set
{ {
_audioVisualBlockItemsGridVisible = value; _audioVisualBlockItemsGridVisible = value;
@@ -150,7 +150,7 @@ namespace Filtration.ViewModels
public bool DisplaySettingsPopupOpen public bool DisplaySettingsPopupOpen
{ {
get { return _displaySettingsPopupOpen; } get => _displaySettingsPopupOpen;
set set
{ {
_displaySettingsPopupOpen = value; _displaySettingsPopupOpen = value;
@@ -205,7 +205,7 @@ namespace Filtration.ViewModels
public bool BlockEnabled public bool BlockEnabled
{ {
get { return Block.Enabled; } get => Block.Enabled;
set set
{ {
if (Block.Enabled != value) if (Block.Enabled != value)
@@ -219,10 +219,7 @@ namespace Filtration.ViewModels
public string BlockDescription public string BlockDescription
{ {
get get => Block.Description;
{
return Block.Description;
}
set set
{ {
if (Block.Description != value) if (Block.Description != value)
@@ -269,8 +266,7 @@ namespace Filtration.ViewModels
newBlockItem.PropertyChanged += OnBlockItemChanged; newBlockItem.PropertyChanged += OnBlockItemChanged;
var customSoundBlockItem = newBlockItem as CustomSoundBlockItem; if(newBlockItem is CustomSoundBlockItem customSoundBlockItem && _parentScriptViewModel.CustomSoundsAvailable.Count > 0)
if(customSoundBlockItem != null && _parentScriptViewModel.CustomSoundsAvailable.Count > 0)
{ {
customSoundBlockItem.Value = _parentScriptViewModel.CustomSoundsAvailable[0]; customSoundBlockItem.Value = _parentScriptViewModel.CustomSoundsAvailable[0];
} }
@@ -364,16 +360,14 @@ namespace Filtration.ViewModels
private string ComputeFilePartFromNumber(string identifier) private string ComputeFilePartFromNumber(string identifier)
{ {
if (Int32.TryParse(identifier, out int x)) if (TryParse(identifier, out int x))
{ {
if (x <= 9) if (x <= 9)
{ {
return "AlertSound_0" + x + ".mp3"; return "AlertSound_0" + x + ".mp3";
} }
else
{ return "AlertSound_" + x + ".mp3";
return "AlertSound_" + x + ".mp3";
}
} }
return ""; return "";
@@ -431,11 +425,9 @@ namespace Filtration.ViewModels
{ {
return; return;
} }
else
{ _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative));
_mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); _mediaPlayer.Play();
_mediaPlayer.Play();
}
} }
private void OnPlayPositionalSoundCommand() private void OnPlayPositionalSoundCommand()
@@ -448,11 +440,9 @@ namespace Filtration.ViewModels
{ {
return; return;
} }
else
{ _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative));
_mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); _mediaPlayer.Play();
_mediaPlayer.Play();
}
} }
private void OnBlockEnabledStatusChanged(object sender, EventArgs e) private void OnBlockEnabledStatusChanged(object sender, EventArgs e)
@@ -462,13 +452,12 @@ namespace Filtration.ViewModels
private void OnBlockItemChanged(object sender, EventArgs e) private void OnBlockItemChanged(object sender, EventArgs e)
{ {
var itemFilterBlockItem = sender as IItemFilterBlockItem; if (sender is IItemFilterBlockItem itemFilterBlockItem && itemFilterBlockItem.IsDirty)
if ( itemFilterBlockItem != null && itemFilterBlockItem.IsDirty)
{ {
IsDirty = true; IsDirty = true;
} }
var customSoundBlockItem = sender as CustomSoundBlockItem;
if (customSoundBlockItem != null) if (sender is CustomSoundBlockItem customSoundBlockItem)
{ {
if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && _parentScriptViewModel.CustomSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0) if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && _parentScriptViewModel.CustomSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0)
{ {
@@ -507,12 +496,11 @@ namespace Filtration.ViewModels
private void OnCustomSoundFileDialog() private void OnCustomSoundFileDialog()
{ {
OpenFileDialog fileDialog = new OpenFileDialog(); OpenFileDialog fileDialog = new OpenFileDialog {DefaultExt = ".mp3"};
fileDialog.DefaultExt = ".mp3"; var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\My Games\Path of Exile\";
var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\";
fileDialog.InitialDirectory = poePath; fileDialog.InitialDirectory = poePath;
Nullable<bool> result = fileDialog.ShowDialog(); bool? result = fileDialog.ShowDialog();
if (result == true) if (result == true)
{ {
var fileName = fileDialog.FileName; var fileName = fileDialog.FileName;
@@ -533,7 +521,7 @@ namespace Filtration.ViewModels
private void OnPlayCustomSoundCommand() private void OnPlayCustomSoundCommand()
{ {
var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\"; var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\My Games\Path of Exile\";
var identifier = BlockItems.OfType<CustomSoundBlockItem>().First().Value; var identifier = BlockItems.OfType<CustomSoundBlockItem>().First().Value;
if(!Path.IsPathRooted(identifier)) if(!Path.IsPathRooted(identifier))
@@ -569,9 +557,11 @@ namespace Filtration.ViewModels
var newGroup = new ItemFilterBlockGroup(BlockGroupSearch, null, AdvancedBlockGroup, false); var newGroup = new ItemFilterBlockGroup(BlockGroupSearch, null, AdvancedBlockGroup, false);
if (baseBlock.BlockGroup == null) if (baseBlock.BlockGroup == null)
{ {
baseBlock.BlockGroup = new ItemFilterBlockGroup("", null, false, true); baseBlock.BlockGroup = new ItemFilterBlockGroup("", null, false, true)
baseBlock.BlockGroup.IsShowChecked = baseBlock.Action == BlockAction.Show; {
baseBlock.BlockGroup.IsEnableChecked = BlockEnabled; IsShowChecked = baseBlock.Action == BlockAction.Show,
IsEnableChecked = BlockEnabled
};
} }
newGroup.AddOrJoinBlockGroup(baseBlock.BlockGroup); newGroup.AddOrJoinBlockGroup(baseBlock.BlockGroup);
blockToAdd.AddOrJoinBlockGroup(newGroup); blockToAdd.AddOrJoinBlockGroup(newGroup);
@@ -611,8 +601,7 @@ namespace Filtration.ViewModels
private void UpdateBlockGroups() private void UpdateBlockGroups()
{ {
var baseBlock = Block as ItemFilterBlock; if (!(Block is ItemFilterBlock baseBlock))
if (baseBlock == null)
return; return;
var currentGroup = baseBlock.BlockGroup; var currentGroup = baseBlock.BlockGroup;

View File

@@ -50,7 +50,7 @@ namespace Filtration.ViewModels
updateService.UpdateProgressChanged += UpdateServiceOnUpdateProgressChanged; updateService.UpdateProgressChanged += UpdateServiceOnUpdateProgressChanged;
updateService.UpdateStatusChanged += UpdateServiceOnUpdateStatusChanged; updateService.UpdateStatusChanged += UpdateServiceOnUpdateStatusChanged;
HideUpdateWindowCommand = new RelayCommand(OnHideUpdateWindowCommand, () => UpdateStatus == UpdateStatus.UpdateAvailable || UpdateStatus == UpdateStatus.Error); HideUpdateWindowCommand = new RelayCommand(OnHideUpdateWindowCommand, () => UpdateStatus == UpdateStatus.UpdateAvailable || UpdateStatus == UpdateStatus.Error);
NextStepCommand = new RelayCommand(async () => await OnNextStepCommandAsync(), () => NextStepCommandEnabled); NextStepCommand = new RelayCommand(async () => await OnNextStepCommandAsync(), () => NextStepCommandEnabled);
@@ -100,39 +100,39 @@ namespace Filtration.ViewModels
} }
private bool NextStepCommandEnabled => UpdateStatus == UpdateStatus.UpdateAvailable || UpdateStatus == UpdateStatus.ReadyToApplyUpdate || UpdateStatus == UpdateStatus.UpdateComplete; private bool NextStepCommandEnabled => UpdateStatus == UpdateStatus.UpdateAvailable || UpdateStatus == UpdateStatus.ReadyToApplyUpdate || UpdateStatus == UpdateStatus.UpdateComplete;
private async Task OnNextStepCommandAsync() private async Task OnNextStepCommandAsync()
{ {
switch (UpdateStatus) switch (UpdateStatus)
{ {
case UpdateStatus.UpdateAvailable: case UpdateStatus.UpdateAvailable:
{ {
await _updateService.DownloadUpdatesAsync(); await _updateService.DownloadUpdatesAsync();
break; break;
} }
case UpdateStatus.ReadyToApplyUpdate: case UpdateStatus.ReadyToApplyUpdate:
{
if (!_updateTabShown)
{ {
// When the update has downloaded and is ready to apply, clicking the button if (!_updateTabShown)
// closes the update popup and shows the update tab. {
_avalonDockWorkspaceViewModel.AddDocument(this); // When the update has downloaded and is ready to apply, clicking the button
Visible = false; // closes the update popup and shows the update tab.
_updateTabShown = true; _avalonDockWorkspaceViewModel.AddDocument(this);
NextStepButtonText = "Update"; Visible = false;
} _updateTabShown = true;
else NextStepButtonText = "Update";
{ }
await _updateService.ApplyUpdatesAsync(); else
} {
await _updateService.ApplyUpdatesAsync();
}
break; break;
} }
case UpdateStatus.UpdateComplete: case UpdateStatus.UpdateComplete:
{ {
_updateService.RestartAfterUpdate(); _updateService.RestartAfterUpdate();
break; break;
} }
} }
} }
@@ -144,7 +144,6 @@ namespace Filtration.ViewModels
{ {
Visible = true; Visible = true;
NextStepButtonText = "Download"; NextStepButtonText = "Download";
RaisePropertyChanged(nameof(ReleaseNotes));
RaisePropertyChanged(nameof(Version)); RaisePropertyChanged(nameof(Version));
break; break;
} }
@@ -156,6 +155,7 @@ namespace Filtration.ViewModels
} }
case UpdateStatus.ReadyToApplyUpdate: case UpdateStatus.ReadyToApplyUpdate:
{ {
RaisePropertyChanged(nameof(ReleaseNotes));
NextStepButtonText = "Update Ready"; NextStepButtonText = "Update Ready";
break; break;
} }

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 2018-08-30) ## Current Release (Released 2018-09-01)
<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>Installer</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.20/filtration_0.20_setup.exe">filtration_0.20_setup.exe</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> <b>Zip File</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.20/filtration_0.20.zip">filtration_0.20.zip</a>
## System Requirements ## System Requirements
Filtration requires .NET Framework 4.6.1 installed. Filtration requires .NET Framework 4.6.1 installed.