Use available sounds as combobox source
This commit is contained in:
parent
41722e8a57
commit
a86ab3ec8d
|
@ -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<string> {
|
||||
"1maybevaluable.mp3", "2currency.mp3", "3uniques.mp3", "4maps.mp3", "5highmaps.mp3",
|
||||
"6veryvaluable.mp3", "7chancing.mp3", "12leveling.mp3", "placeholder.mp3"
|
||||
};
|
||||
|
||||
_customSoundsAvailable = new ObservableCollection<string>();
|
||||
|
||||
var poeFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\";
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -166,10 +166,23 @@ namespace Filtration.ViewModels
|
|||
|
||||
_viewItemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
|
||||
|
||||
_customSoundsAvailable = new ObservableCollection<string> {
|
||||
"1maybevaluable.mp3", "2currency.mp3", "3uniques.mp3", "4maps.mp3", "5highmaps.mp3",
|
||||
"6veryvaluable.mp3", "7chancing.mp3", "12leveling.mp3", "placeholder.mp3"
|
||||
};
|
||||
_customSoundsAvailable = new ObservableCollection<string>();
|
||||
|
||||
var 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)
|
||||
|
|
Loading…
Reference in New Issue