Add custom sound theme support
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel.ThemeEditor
|
||||
|
||||
82
Filtration.ObjectModel/ThemeEditor/StringThemeComponent.cs
Normal file
82
Filtration.ObjectModel/ThemeEditor/StringThemeComponent.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Filtration.ObjectModel.ThemeEditor
|
||||
{
|
||||
[Serializable]
|
||||
public class StringThemeComponent : ThemeComponent
|
||||
{
|
||||
private string _value;
|
||||
public static ObservableCollection<string> _customSoundsAvailable;
|
||||
|
||||
public StringThemeComponent(ThemeComponentType componentType, string componentName, string componentValue)
|
||||
{
|
||||
if (componentName == null || componentValue == null)
|
||||
{
|
||||
throw new ArgumentException("Null parameters not allowed in StringThemeComponent constructor");
|
||||
}
|
||||
|
||||
ComponentType = componentType;
|
||||
Value = componentValue;
|
||||
ComponentName = componentName;
|
||||
|
||||
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"
|
||||
};
|
||||
}
|
||||
|
||||
if (_customSoundsAvailable.IndexOf(Value) < 0)
|
||||
{
|
||||
_customSoundsAvailable.Add(Value);
|
||||
}
|
||||
|
||||
CustomSoundFileDialogCommand = new RelayCommand(OnCustomSoundFileDialog);
|
||||
}
|
||||
|
||||
public RelayCommand CustomSoundFileDialogCommand { get; set; }
|
||||
|
||||
public ObservableCollection<string> CustomSoundsAvailable => _customSoundsAvailable;
|
||||
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
_value = value;
|
||||
OnPropertyChanged();
|
||||
_themeComponentUpdatedEventHandler?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
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<bool> result = fileDialog.ShowDialog();
|
||||
if (result == true)
|
||||
{
|
||||
var fileName = fileDialog.FileName;
|
||||
if (fileName.StartsWith(poePath))
|
||||
{
|
||||
fileName = fileName.Replace(poePath, "");
|
||||
}
|
||||
|
||||
if (CustomSoundsAvailable.IndexOf(fileName) < 0)
|
||||
{
|
||||
CustomSoundsAvailable.Add(fileName);
|
||||
OnPropertyChanged(nameof(CustomSoundsAvailable));
|
||||
}
|
||||
Value = fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,19 @@ namespace Filtration.ObjectModel.ThemeEditor
|
||||
return component;
|
||||
}
|
||||
|
||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, string componentValue)
|
||||
{
|
||||
if (ComponentExists(componentType, componentName))
|
||||
{
|
||||
return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
||||
}
|
||||
|
||||
var component = new StringThemeComponent(componentType, componentName, componentValue);
|
||||
Items.Add(component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
private bool ComponentExists(ThemeComponentType componentType, string componentName)
|
||||
{
|
||||
var componentCount =
|
||||
|
||||
Reference in New Issue
Block a user