2016-10-26 17:45:48 +08:00
|
|
|
|
using osu.Framework;
|
|
|
|
|
using osu.Framework.Configuration;
|
2016-10-10 22:19:05 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-10 01:45:34 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-10-10 22:19:05 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
|
|
|
|
using osu.Framework.Input;
|
2016-10-10 01:45:34 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
2016-10-26 17:45:48 +08:00
|
|
|
|
namespace osu.Game.Graphics.UserInterface.Volume
|
2016-10-10 01:45:34 +08:00
|
|
|
|
{
|
|
|
|
|
internal class VolumeMeter : Container
|
|
|
|
|
{
|
2016-10-12 22:36:42 +08:00
|
|
|
|
private Box meterFill;
|
|
|
|
|
private BindableDouble volume;
|
2016-10-10 22:19:05 +08:00
|
|
|
|
|
|
|
|
|
public VolumeMeter(string meterName, BindableDouble volume)
|
2016-10-10 01:45:34 +08:00
|
|
|
|
{
|
2016-10-12 22:36:42 +08:00
|
|
|
|
this.volume = volume;
|
2016-10-10 01:45:34 +08:00
|
|
|
|
Size = new Vector2(40, 180);
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black,
|
2016-10-12 22:36:42 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2016-10-10 01:45:34 +08:00
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Size = new Vector2(0.5f, 0.9f),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.DarkGray,
|
2016-10-12 22:36:42 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2016-10-10 01:45:34 +08:00
|
|
|
|
},
|
2016-10-12 22:36:42 +08:00
|
|
|
|
meterFill = new Box
|
2016-10-10 01:45:34 +08:00
|
|
|
|
{
|
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre
|
2016-10-12 22:36:42 +08:00
|
|
|
|
}
|
2016-10-10 01:45:34 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2016-10-14 00:11:51 +08:00
|
|
|
|
new SpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = meterName,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
2016-10-14 14:46:40 +08:00
|
|
|
|
Origin = Anchor.TopCentre
|
2016-10-14 00:11:51 +08:00
|
|
|
|
}
|
2016-10-10 01:45:34 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2016-10-10 22:19:05 +08:00
|
|
|
|
|
2016-11-06 18:13:52 +08:00
|
|
|
|
protected override void LoadComplete()
|
2016-10-22 20:33:43 +08:00
|
|
|
|
{
|
2016-11-06 18:13:52 +08:00
|
|
|
|
base.LoadComplete();
|
2016-10-22 20:33:43 +08:00
|
|
|
|
updateFill();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 03:17:53 +08:00
|
|
|
|
public double Volume
|
2016-10-10 22:19:05 +08:00
|
|
|
|
{
|
2016-10-13 03:17:53 +08:00
|
|
|
|
get { return volume.Value; }
|
|
|
|
|
private set
|
|
|
|
|
{
|
|
|
|
|
volume.Value = value;
|
|
|
|
|
updateFill();
|
|
|
|
|
}
|
2016-10-10 22:19:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 15:25:21 +08:00
|
|
|
|
protected override bool OnWheel(InputState state)
|
2016-10-10 22:19:05 +08:00
|
|
|
|
{
|
2016-11-21 20:35:53 +08:00
|
|
|
|
Volume += 0.05f * state.Mouse.WheelDelta;
|
2016-10-13 01:45:42 +08:00
|
|
|
|
return true;
|
2016-10-10 22:19:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 03:17:53 +08:00
|
|
|
|
private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)Volume), 300, EasingTypes.OutQuint);
|
2016-10-10 01:45:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|