diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs
index 3d3f879..162916d 100644
--- a/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs
+++ b/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs
@@ -15,7 +15,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
Value = value;
}
- public override string OutputText => PrefixText + " " + Value;
+ public override string OutputText => PrefixText + " \"" + Value + "\"";
public override string SummaryText => string.Empty;
public override Color SummaryBackgroundColor => Colors.Transparent;
diff --git a/Filtration.ObjectModel/BlockItemTypes/CustomSoundBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/CustomSoundBlockItem.cs
new file mode 100644
index 0000000..9aafd01
--- /dev/null
+++ b/Filtration.ObjectModel/BlockItemTypes/CustomSoundBlockItem.cs
@@ -0,0 +1,21 @@
+using Filtration.ObjectModel.BlockItemBaseTypes;
+
+namespace Filtration.ObjectModel.BlockItemTypes
+{
+ public class CustomSoundBlockItem : StringBlockItem
+ {
+ public CustomSoundBlockItem()
+ {
+ Value = "";
+ }
+
+ public CustomSoundBlockItem(string value) : base(value)
+ {
+ }
+
+ public override string PrefixText => "CustomAlertSound";
+ public override int MaximumAllowed => 1;
+ public override string DisplayHeading => "Custom Alert Sound";
+ public override int SortOrder => 30;
+ }
+}
diff --git a/Filtration.ObjectModel/Filtration.ObjectModel.csproj b/Filtration.ObjectModel/Filtration.ObjectModel.csproj
index b7f55d5..04edeca 100644
--- a/Filtration.ObjectModel/Filtration.ObjectModel.csproj
+++ b/Filtration.ObjectModel/Filtration.ObjectModel.csproj
@@ -64,6 +64,7 @@
+
diff --git a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs
index ee1ff18..8e53093 100644
--- a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs
+++ b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs
@@ -235,6 +235,7 @@ namespace Filtration.Parser.Services
// Only ever use the last PlayAlertSound item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType(block);
RemoveExistingBlockItemsOfType(block);
+ RemoveExistingBlockItemsOfType(block);
var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?\s*([#]?)(.*)");
@@ -314,7 +315,7 @@ namespace Filtration.Parser.Services
// Only ever use the last Icon item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType(block);
- var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)");
+ var match = Regex.Match(trimmedLine, @"\S+\s+""(\S+)""");
if (match.Success)
{
@@ -341,6 +342,25 @@ namespace Filtration.Parser.Services
block.BlockItems.Add(beamBlockItem);
break;
}
+ case "CustomAlertSound":
+ {
+ // Only ever use the last CustomSoundBlockItem item encountered as multiples aren't valid.
+ RemoveExistingBlockItemsOfType(block);
+ RemoveExistingBlockItemsOfType(block);
+ RemoveExistingBlockItemsOfType(block);
+
+ var match = Regex.Match(trimmedLine, @"\S+\s+""(\S+)""");
+
+ if (match.Success)
+ {
+ var blockItemValue = new CustomSoundBlockItem
+ {
+ Value = match.Groups[1].Value
+ };
+ block.BlockItems.Add(blockItemValue);
+ }
+ break;
+ }
}
}
diff --git a/Filtration/UserControls/BlockItemControl.xaml b/Filtration/UserControls/BlockItemControl.xaml
index 606e780..7a401b8 100644
--- a/Filtration/UserControls/BlockItemControl.xaml
+++ b/Filtration/UserControls/BlockItemControl.xaml
@@ -177,6 +177,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs
index 8396902..fc74038 100644
--- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs
+++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
+using System.IO;
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel;
@@ -10,6 +11,7 @@ using Filtration.ObjectModel.BlockItemTypes;
using Filtration.Services;
using Filtration.Views;
using GalaSoft.MvvmLight.CommandWpf;
+using Microsoft.Win32;
using Xceed.Wpf.Toolkit;
namespace Filtration.ViewModels
@@ -28,6 +30,7 @@ namespace Filtration.ViewModels
private readonly IStaticDataService _staticDataService;
private readonly IReplaceColorsViewModel _replaceColorsViewModel;
private readonly MediaPlayer _mediaPlayer = new MediaPlayer();
+ public static ObservableCollection _customSoundsAvailable;
private bool _displaySettingsPopupOpen;
private bool _isExpanded;
@@ -47,6 +50,16 @@ namespace Filtration.ViewModels
SwitchBlockItemsViewCommand = new RelayCommand(OnSwitchBlockItemsViewCommand);
PlaySoundCommand = new RelayCommand(OnPlaySoundCommand, () => HasSound);
PlayPositionalSoundCommand = new RelayCommand(OnPlayPositionalSoundCommand, () => HasPositionalSound);
+ PlayCustomSoundCommand = new RelayCommand(OnPlayCustomSoundCommand, () => HasCustomSound);
+ CustomSoundFileDialogCommand = new RelayCommand(OnCustomSoundFileDialog);
+
+ if(_customSoundsAvailable == null || _customSoundsAvailable.Count < 1)
+ {
+ _customSoundsAvailable = new ObservableCollection {
+ "1maybevaluable.mp3", "2currency.mp3", "3uniques.mp3", "4maps.mp3", "5highmaps.mp3",
+ "6veryvaluable.mp3", "7chancing.mp3", "12leveling.mp3", "placeholder.mp3"
+ };
+ }
}
public override void Initialise(IItemFilterBlockBase itemFilterBlockBase, IItemFilterScriptViewModel parentScriptViewModel)
@@ -66,9 +79,16 @@ namespace Filtration.ViewModels
foreach (var blockItem in itemFilterBlock.BlockItems)
{
blockItem.PropertyChanged += OnBlockItemChanged;
+
+ var customSoundBlockItem = blockItem as CustomSoundBlockItem;
+ if (customSoundBlockItem != null)
+ {
+ if (_customSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0)
+ {
+ _customSoundsAvailable.Add(customSoundBlockItem.Value);
+ }
+ }
}
-
-
base.Initialise(itemFilterBlock, parentScriptViewModel);
}
@@ -81,6 +101,8 @@ namespace Filtration.ViewModels
public RelayCommand PlaySoundCommand { get; }
public RelayCommand PlayPositionalSoundCommand { get; }
public RelayCommand SwitchBlockItemsViewCommand { get; }
+ public RelayCommand CustomSoundFileDialogCommand { get; }
+ public RelayCommand PlayCustomSoundCommand { get; }
public IItemFilterBlock Block { get; private set; }
@@ -176,7 +198,8 @@ namespace Filtration.ViewModels
typeof (PositionalSoundBlockItem),
typeof (DisableDropSoundBlockItem),
typeof (IconBlockItem),
- typeof (BeamBlockItem)
+ typeof (BeamBlockItem),
+ typeof (CustomSoundBlockItem)
};
public bool BlockEnabled
@@ -212,6 +235,8 @@ namespace Filtration.ViewModels
public ObservableCollection AvailableColors => PathOfExileColors.DefaultColors;
+ public ObservableCollection CustomSoundsAvailable => _customSoundsAvailable;
+
public Color DisplayTextColor => Block.DisplayTextColor;
public Color DisplayBackgroundColor => Block.DisplayBackgroundColor;
public Color DisplayBorderColor => Block.DisplayBorderColor;
@@ -221,6 +246,7 @@ namespace Filtration.ViewModels
public bool HasSound => Block.HasBlockItemOfType();
public bool HasPositionalSound => Block.HasBlockItemOfType();
+ public bool HasCustomSound => Block.HasBlockItemOfType();
public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any();
@@ -444,6 +470,8 @@ namespace Filtration.ViewModels
RaisePropertyChanged(nameof(DisplayIcon));
RaisePropertyChanged(nameof(DisplayBeamColor));
RaisePropertyChanged(nameof(HasSound));
+ RaisePropertyChanged(nameof(HasPositionalSound));
+ RaisePropertyChanged(nameof(HasCustomSound));
}
private void OnBlockItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
@@ -453,5 +481,53 @@ namespace Filtration.ViewModels
RaisePropertyChanged(nameof(AudioVisualBlockItems));
RaisePropertyChanged(nameof(HasAudioVisualBlockItems));
}
+
+ private void OnCustomSoundFileDialog()
+ {
+ OpenFileDialog fileDialog = new OpenFileDialog();
+ fileDialog.DefaultExt = ".mp3";
+ var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\";
+ fileDialog.InitialDirectory = poePath;
+
+ Nullable result = fileDialog.ShowDialog();
+ if (result == true)
+ {
+ var fileName = fileDialog.FileName;
+ if(fileName.StartsWith(poePath))
+ {
+ fileName = fileName.Replace(poePath, "");
+ }
+
+ var customSoundBlockItem = BlockItems.First(b => b.GetType() == typeof(CustomSoundBlockItem)) as CustomSoundBlockItem;
+
+ if (CustomSoundsAvailable.IndexOf(fileName) < 0)
+ {
+ CustomSoundsAvailable.Add(fileName);
+ RaisePropertyChanged(nameof(CustomSoundsAvailable));
+ }
+ customSoundBlockItem.Value = fileName;
+ }
+ }
+
+ private void OnPlayCustomSoundCommand()
+ {
+ var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\";
+ var identifier = BlockItems.OfType().First().Value;
+
+ if(!Path.IsPathRooted(identifier))
+ {
+ identifier = poePath + identifier;
+ }
+
+ try
+ {
+ _mediaPlayer.Open(new Uri(identifier, UriKind.Absolute));
+ _mediaPlayer.Play();
+ }
+ catch
+ {
+ MessageBox.Show("Couldn't play the file. Please be sure it is a valid audio file.");
+ }
+ }
}
}
diff --git a/Filtration/Views/ItemFilterBlockView.xaml b/Filtration/Views/ItemFilterBlockView.xaml
index f4bbeac..8716b2c 100644
--- a/Filtration/Views/ItemFilterBlockView.xaml
+++ b/Filtration/Views/ItemFilterBlockView.xaml
@@ -161,6 +161,18 @@
ToolTip="Click to preview drop sound">
+