1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 10:22:56 +08:00

Merge pull request #622 from peppy/sliderbar-improvements

Add special SliderBar sound behaviour when at extents.
This commit is contained in:
Dean Herbert 2017-04-12 20:24:53 +09:00 committed by GitHub
commit cfacfe8294

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -63,15 +62,6 @@ namespace osu.Game.Graphics.UserInterface
rightBox.Colour = colours.Pink;
}
private void playSample()
{
if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50)
return;
lastSampleTime = Clock.CurrentTime;
sample.Frequency.Value = 1 + NormalizedValue * 0.2f;
sample.Play();
}
protected override bool OnHover(InputState state)
{
nub.Glowing = true;
@ -84,11 +74,25 @@ namespace osu.Game.Graphics.UserInterface
base.OnHoverLost(state);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
protected override void OnUserChange()
{
if (args.Key == Key.Left || args.Key == Key.Right)
playSample();
return base.OnKeyDown(state, args);
base.OnUserChange();
playSample();
}
private void playSample()
{
if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50)
return;
lastSampleTime = Clock.CurrentTime;
sample.Frequency.Value = 1 + NormalizedValue * 0.2f;
if (NormalizedValue == 0)
sample.Frequency.Value -= 0.4f;
else if (NormalizedValue == 1)
sample.Frequency.Value += 0.4f;
sample.Play();
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
@ -103,18 +107,6 @@ namespace osu.Game.Graphics.UserInterface
return base.OnMouseUp(state, args);
}
protected override bool OnClick(InputState state)
{
playSample();
return base.OnClick(state);
}
protected override bool OnDrag(InputState state)
{
playSample();
return base.OnDrag(state);
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();