diff --git a/UI/Components/SoundComponent.cs b/UI/Components/SoundComponent.cs index 605a596..7c4e903 100644 --- a/UI/Components/SoundComponent.cs +++ b/UI/Components/SoundComponent.cs @@ -20,6 +20,8 @@ public class SoundComponent : LogicComponent, IDeactivatableComponent private SoundSettings Settings { get; set; } private WaveOut Player { get; set; } + private Random rnd; + public SoundComponent(LiveSplitState state) { Activated = true; @@ -35,6 +37,8 @@ public SoundComponent(LiveSplitState state) State.OnPause += State_OnPause; State.OnResume += State_OnResume; State.OnReset += State_OnReset; + + rnd = new Random(); } public override void Dispose() @@ -160,10 +164,19 @@ private void State_OnReset(object sender, TimerPhase e) PlaySound(Settings.Reset, Settings.ResetVolume); } - private void PlaySound(string location, int volume) + private void PlaySound(string locations, int volume) { Player.Stop(); + int index = 0; + string[] locationsArray = locations.Split(';'); + if (locationsArray.Length > 1) + { + index = rnd.Next(0, locations.Length); + } + + string location = locationsArray[index]; + if (Activated && File.Exists(location)) { Task.Factory.StartNew(() => diff --git a/UI/Components/SoundSettings.cs b/UI/Components/SoundSettings.cs index 9a32bf8..770bbf3 100644 --- a/UI/Components/SoundSettings.cs +++ b/UI/Components/SoundSettings.cs @@ -204,14 +204,15 @@ protected string BrowseForPath(TextBox textBox, Action callback) var path = textBox.Text; var fileDialog = new OpenFileDialog() { - FileName = path, + Multiselect = true, + FileName = path.Split(';')[0], Filter = "Audio Files|*.mp3;*.wav;*.aiff;*.wma|All Files|*.*" }; var result = fileDialog.ShowDialog(); if (result == DialogResult.OK) - path = fileDialog.FileName; + path = String.Join(";", fileDialog.FileNames); textBox.Text = path; callback(path);