1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Play slider sample as the value changes in 1/10ths

This commit is contained in:
Drew DeVault 2016-12-07 15:56:00 -05:00
parent c642f6c34f
commit 22c2a4757c

View File

@ -1,6 +1,9 @@
using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -53,6 +56,8 @@ namespace osu.Game.Overlays.Options
IComparable, IFormattable, IConvertible, IComparable<U>, IEquatable<U>
{
private Container nub;
private AudioSample sample;
private float prevAmount = -1;
public OsuSliderBar()
{
@ -83,8 +88,17 @@ namespace osu.Game.Overlays.Options
Box.Colour = new Color4(255, 102, 170, 100);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sample = audio.Sample.Get(@"Sliderbar/sliderbar");
}
protected override void UpdateAmount(float amt)
{
if (prevAmount != -1 && (int)(prevAmount * 10) != (int)(amt * 10))
sample?.Play();
prevAmount = amt;
nub.MoveToX(amt, 300, EasingTypes.OutQuint);
SelectionBox.ScaleTo(
new Vector2(DrawWidth * amt - Height / 2 + 1, 1),