1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 07:38:21 +08:00
osu-lazer/osu.Game/VolumeControl.cs

89 lines
2.8 KiB
C#
Raw Normal View History

using osu.Framework;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using OpenTK;
using osu.Framework.Graphics.Primitives;
namespace osu.Game
{
2016-10-22 16:50:42 +08:00
internal class VolumeControl : Container
{
private FlowContainer volumeMetersContainer;
private VolumeMeter volumeMeterMaster;
public BindableDouble VolumeGlobal { get; set; }
public BindableDouble VolumeSample { get; set; }
public BindableDouble VolumeTrack { get; set; }
public override bool Contains(Vector2 screenSpacePos) => true;
2016-10-13 03:17:53 +08:00
private void volumeChanged(object sender, System.EventArgs e)
{
appear();
Anchor = Anchor.BottomRight;
Origin = Anchor.BottomRight;
2016-10-13 03:17:53 +08:00
}
2016-10-22 16:50:42 +08:00
public VolumeControl()
{
AutoSizeAxes = Axes.Both;
}
2016-10-10 16:17:26 +08:00
public override void Load(BaseGame game)
{
2016-10-10 16:17:26 +08:00
base.Load(game);
2016-10-13 03:17:53 +08:00
VolumeGlobal.ValueChanged += volumeChanged;
VolumeSample.ValueChanged += volumeChanged;
VolumeTrack.ValueChanged += volumeChanged;
Children = new Drawable[]
{
2016-10-10 22:19:05 +08:00
volumeMetersContainer = new FlowContainer
{
2016-10-22 17:05:46 +08:00
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = new Vector2(10, 30),
Spacing = new Vector2(15,0),
Alpha = 0,
Children = new Drawable[]
{
volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal),
2016-10-10 22:19:05 +08:00
new VolumeMeter("Effects", VolumeSample),
new VolumeMeter("Music", VolumeTrack)
}
}
};
}
2016-10-13 22:52:49 +08:00
protected override void Dispose(bool isDisposing)
{
VolumeGlobal.ValueChanged -= volumeChanged;
VolumeSample.ValueChanged -= volumeChanged;
VolumeTrack.ValueChanged -= volumeChanged;
base.Dispose(isDisposing);
}
protected override bool OnWheelDown(InputState state)
{
volumeMeterMaster.TriggerWheelDown(state);
return true;
}
protected override bool OnWheelUp(InputState state)
{
volumeMeterMaster.TriggerWheelUp(state);
return true;
}
private void appear()
{
volumeMetersContainer.ClearTransformations();
volumeMetersContainer.FadeIn(100);
volumeMetersContainer.Delay(1000);
volumeMetersContainer.FadeOut(100);
}
}
}