diff --git a/Filtration.ObjectModel/ThemeEditor/StringThemeComponent.cs b/Filtration.ObjectModel/ThemeEditor/StringThemeComponent.cs index 98b98e4..1667226 100644 --- a/Filtration.ObjectModel/ThemeEditor/StringThemeComponent.cs +++ b/Filtration.ObjectModel/ThemeEditor/StringThemeComponent.cs @@ -1,5 +1,6 @@ using System; using System.Collections.ObjectModel; +using System.Linq; using Filtration.ObjectModel.Enums; using GalaSoft.MvvmLight.Command; using Microsoft.Win32; @@ -25,13 +26,31 @@ namespace Filtration.ObjectModel.ThemeEditor 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" - }; + + _customSoundsAvailable = new ObservableCollection(); + + var poeFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\"; + 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); } diff --git a/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs b/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs index c18a8c9..14f0442 100644 --- a/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs +++ b/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs @@ -209,7 +209,7 @@ namespace Filtration.ThemeEditor.ViewModels Components.Add(new StrIntThemeComponent(themeComponentType, "Untitled Component", "1", 100)); break; case ThemeComponentType.CustomSound: - Components.Add(new StringThemeComponent(themeComponentType, "Untitled Component", "placeholder.mp3")); + Components.Add(new StringThemeComponent(themeComponentType, "Untitled Component", "")); break; case ThemeComponentType.Icon: Components.Add(new IconThemeComponent(themeComponentType, "Untitled Component", IconSize.Largest, IconColor.Red, IconShape.Circle)); diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index edcf88d..4fa9893 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -251,6 +251,13 @@ namespace Filtration.ViewModels var newBlockItem = (IItemFilterBlockItem) Activator.CreateInstance(blockItemType); newBlockItem.PropertyChanged += OnBlockItemChanged; + + var customSoundBlockItem = newBlockItem as CustomSoundBlockItem; + if(customSoundBlockItem != null && _parentScriptViewModel.CustomSoundsAvailable.Count > 0) + { + customSoundBlockItem.Value = _parentScriptViewModel.CustomSoundsAvailable[0]; + } + BlockItems.Add(newBlockItem); OnBlockItemChanged(this, EventArgs.Empty); IsDirty = true; diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index e915c76..2548467 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -166,10 +166,23 @@ namespace Filtration.ViewModels _viewItemFilterBlockViewModels = new ObservableCollection(); - _customSoundsAvailable = new ObservableCollection { - "1maybevaluable.mp3", "2currency.mp3", "3uniques.mp3", "4maps.mp3", "5highmaps.mp3", - "6veryvaluable.mp3", "7chancing.mp3", "12leveling.mp3", "placeholder.mp3" - }; + _customSoundsAvailable = new ObservableCollection(); + + var poeFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\"; + var poeFolderFiles = 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, "")); + } } public void Initialise(IItemFilterScript itemFilterScript, bool newScript)