2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-12-06 09:56:20 +00:00
|
|
|
|
|
2016-10-26 09:45:48 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
2016-10-10 14:19:05 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-09 17:45:34 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-10-10 14:19:05 +00:00
|
|
|
|
using osu.Framework.Input;
|
2017-01-31 09:53:52 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2016-10-09 17:45:34 +00:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
2016-10-26 09:45:48 +00:00
|
|
|
|
namespace osu.Game.Graphics.UserInterface.Volume
|
2016-10-09 17:45:34 +00:00
|
|
|
|
{
|
|
|
|
|
internal class VolumeMeter : Container
|
|
|
|
|
{
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Box meterFill;
|
2017-03-07 01:59:19 +00:00
|
|
|
|
public BindableDouble Bindable { get; } = new BindableDouble();
|
2016-10-10 14:19:05 +00:00
|
|
|
|
|
2016-11-23 07:12:21 +00:00
|
|
|
|
public VolumeMeter(string meterName)
|
2016-10-09 17:45:34 +00:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(40, 180);
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black,
|
2016-10-12 14:36:42 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2016-10-09 17:45:34 +00: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 14:36:42 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2016-10-09 17:45:34 +00:00
|
|
|
|
},
|
2016-10-12 14:36:42 +00:00
|
|
|
|
meterFill = new Box
|
2016-10-09 17:45:34 +00:00
|
|
|
|
{
|
|
|
|
|
Colour = Color4.White,
|
2016-11-29 09:35:59 +00:00
|
|
|
|
Scale = new Vector2(1, 0),
|
2016-10-09 17:45:34 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre
|
2016-10-12 14:36:42 +00:00
|
|
|
|
}
|
2016-10-09 17:45:34 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2017-01-31 09:53:52 +00:00
|
|
|
|
new OsuSpriteText
|
2016-10-13 16:11:51 +00:00
|
|
|
|
{
|
|
|
|
|
Text = meterName,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
2016-10-14 06:46:40 +00:00
|
|
|
|
Origin = Anchor.TopCentre
|
2016-10-13 16:11:51 +00:00
|
|
|
|
}
|
2016-10-09 17:45:34 +00:00
|
|
|
|
};
|
2016-11-29 09:35:59 +00:00
|
|
|
|
|
|
|
|
|
Bindable.ValueChanged += delegate { updateFill(); };
|
2016-10-09 17:45:34 +00:00
|
|
|
|
}
|
2016-10-10 14:19:05 +00:00
|
|
|
|
|
2016-11-06 10:13:52 +00:00
|
|
|
|
protected override void LoadComplete()
|
2016-10-22 12:33:43 +00:00
|
|
|
|
{
|
2016-11-06 10:13:52 +00:00
|
|
|
|
base.LoadComplete();
|
2016-10-22 12:33:43 +00:00
|
|
|
|
updateFill();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-12 19:17:53 +00:00
|
|
|
|
public double Volume
|
2016-10-10 14:19:05 +00:00
|
|
|
|
{
|
2016-11-23 07:12:21 +00:00
|
|
|
|
get { return Bindable.Value; }
|
2016-10-12 19:17:53 +00:00
|
|
|
|
private set
|
|
|
|
|
{
|
2016-11-23 07:12:21 +00:00
|
|
|
|
Bindable.Value = value;
|
2016-10-12 19:17:53 +00:00
|
|
|
|
}
|
2016-10-10 14:19:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 07:25:21 +00:00
|
|
|
|
protected override bool OnWheel(InputState state)
|
2016-10-10 14:19:05 +00:00
|
|
|
|
{
|
2016-11-21 12:35:53 +00:00
|
|
|
|
Volume += 0.05f * state.Mouse.WheelDelta;
|
2016-10-12 17:45:42 +00:00
|
|
|
|
return true;
|
2016-10-10 14:19:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-12 19:17:53 +00:00
|
|
|
|
private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)Volume), 300, EasingTypes.OutQuint);
|
2016-10-09 17:45:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|