From 880418fd0d83c5005145b68e3c7d8ca5e4aaa2db Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 26 Nov 2017 03:27:16 +0900 Subject: [PATCH] Split out click and hover sound layers --- .../UserInterface/HoverClickSounds.cs | 30 +---------- .../Graphics/UserInterface/HoverSounds.cs | 54 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 3 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/HoverSounds.cs diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index eace307610..0fac1c8092 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -1,13 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.ComponentModel; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Input; namespace osu.Game.Graphics.UserInterface @@ -16,18 +13,12 @@ namespace osu.Game.Graphics.UserInterface /// Adds hover and click sounds to a drawable. /// Does not draw anything. /// - public class HoverClickSounds : CompositeDrawable + public class HoverClickSounds : HoverSounds { private SampleChannel sampleClick; - private SampleChannel sampleHover; - protected readonly HoverSampleSet SampleSet; - - public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) + public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) : base(sampleSet) { - SampleSet = sampleSet; - RelativeSizeAxes = Axes.Both; - AlwaysPresent = true; } protected override bool OnClick(InputState state) @@ -36,27 +27,10 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } - protected override bool OnHover(InputState state) - { - sampleHover?.Play(); - return base.OnHover(state); - } - [BackgroundDependencyLoader] private void load(AudioManager audio) { sampleClick = audio.Sample.Get($@"UI/generic-select{SampleSet.GetDescription()}"); - sampleHover = audio.Sample.Get($@"UI/generic-hover{SampleSet.GetDescription()}"); } } - - public enum HoverSampleSet - { - [Description("")] - Loud, - [Description("-soft")] - Normal, - [Description("-softer")] - Soft - } } diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs new file mode 100644 index 0000000000..d26ad35c49 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -0,0 +1,54 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.ComponentModel; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Input; + +namespace osu.Game.Graphics.UserInterface +{ + /// + /// Adds hover sounds to a drawable. + /// Does not draw anything. + /// + public class HoverSounds : CompositeDrawable + { + private SampleChannel sampleHover; + + protected readonly HoverSampleSet SampleSet; + + public HoverSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) + { + SampleSet = sampleSet; + RelativeSizeAxes = Axes.Both; + AlwaysPresent = true; + } + + protected override bool OnHover(InputState state) + { + sampleHover?.Play(); + return base.OnHover(state); + } + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + sampleHover = audio.Sample.Get($@"UI/generic-hover{SampleSet.GetDescription()}"); + } + } + + public enum HoverSampleSet + { + [Description("")] + Loud, + [Description("-soft")] + Normal, + [Description("-softer")] + Soft + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 415286f9a8..ce9e8eff9c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -272,6 +272,7 @@ +