2016-10-26 17:45:48 +08:00
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework;
|
2016-10-12 22:36:42 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2016-10-07 02:05:26 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Input;
|
2016-10-26 17:45:48 +08:00
|
|
|
|
using osu.Framework.Threading;
|
2016-10-13 01:45:42 +08:00
|
|
|
|
using OpenTK;
|
2016-10-07 02:05:26 +08:00
|
|
|
|
|
2016-10-26 17:45:48 +08:00
|
|
|
|
namespace osu.Game.Graphics.UserInterface.Volume
|
2016-10-07 02:05:26 +08:00
|
|
|
|
{
|
2016-10-26 17:45:48 +08:00
|
|
|
|
internal class VolumeControl : OverlayContainer
|
2016-10-07 02:05:26 +08:00
|
|
|
|
{
|
|
|
|
|
public BindableDouble VolumeGlobal { get; set; }
|
|
|
|
|
public BindableDouble VolumeSample { get; set; }
|
|
|
|
|
public BindableDouble VolumeTrack { get; set; }
|
|
|
|
|
|
2016-10-26 17:45:48 +08:00
|
|
|
|
private VolumeMeter volumeMeterMaster;
|
|
|
|
|
|
2016-10-16 17:39:10 +08:00
|
|
|
|
public override bool Contains(Vector2 screenSpacePos) => true;
|
2016-10-07 02:05:26 +08:00
|
|
|
|
|
2016-10-26 17:45:48 +08:00
|
|
|
|
private void volumeChanged(object sender, EventArgs e)
|
2016-10-13 03:17:53 +08:00
|
|
|
|
{
|
2016-10-26 17:45:48 +08:00
|
|
|
|
Show();
|
|
|
|
|
schedulePopOut();
|
2016-10-13 03:17:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-22 16:50:42 +08:00
|
|
|
|
public VolumeControl()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2016-10-26 17:45:48 +08:00
|
|
|
|
Anchor = Anchor.BottomRight;
|
|
|
|
|
Origin = Anchor.BottomRight;
|
2016-10-22 16:50:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 16:17:26 +08:00
|
|
|
|
public override void Load(BaseGame game)
|
2016-10-07 02:05:26 +08:00
|
|
|
|
{
|
2016-10-13 03:17:53 +08:00
|
|
|
|
VolumeGlobal.ValueChanged += volumeChanged;
|
|
|
|
|
VolumeSample.ValueChanged += volumeChanged;
|
|
|
|
|
VolumeTrack.ValueChanged += volumeChanged;
|
|
|
|
|
|
2016-10-07 02:05:26 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-10-26 17:45:48 +08:00
|
|
|
|
new FlowContainer
|
2016-10-10 22:19:05 +08:00
|
|
|
|
{
|
2016-10-22 17:05:46 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-10-07 02:05:26 +08:00
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
2016-10-10 01:45:34 +08:00
|
|
|
|
Position = new Vector2(10, 30),
|
2016-10-13 01:45:42 +08:00
|
|
|
|
Spacing = new Vector2(15,0),
|
2016-10-07 02:05:26 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-10-12 22:36:42 +08:00
|
|
|
|
volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal),
|
2016-10-10 22:19:05 +08:00
|
|
|
|
new VolumeMeter("Effects", VolumeSample),
|
|
|
|
|
new VolumeMeter("Music", VolumeTrack)
|
2016-10-07 02:05:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-10-26 17:45:48 +08:00
|
|
|
|
|
|
|
|
|
base.Load(game);
|
2016-10-07 02:05:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-07 02:05:26 +08:00
|
|
|
|
protected override bool OnWheelDown(InputState state)
|
|
|
|
|
{
|
2016-10-26 17:45:48 +08:00
|
|
|
|
if (!IsVisible)
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-10-13 01:45:42 +08:00
|
|
|
|
volumeMeterMaster.TriggerWheelDown(state);
|
|
|
|
|
return true;
|
2016-10-07 02:05:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnWheelUp(InputState state)
|
|
|
|
|
{
|
2016-10-26 17:45:48 +08:00
|
|
|
|
if (!IsVisible)
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-10-13 01:45:42 +08:00
|
|
|
|
volumeMeterMaster.TriggerWheelUp(state);
|
|
|
|
|
return true;
|
2016-10-07 02:05:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-26 17:45:48 +08:00
|
|
|
|
ScheduledDelegate popOutDelegate;
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
ClearTransformations();
|
|
|
|
|
FadeIn(100);
|
|
|
|
|
|
|
|
|
|
schedulePopOut();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
FadeOut(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void schedulePopOut()
|
2016-10-07 02:05:26 +08:00
|
|
|
|
{
|
2016-10-26 17:45:48 +08:00
|
|
|
|
popOutDelegate?.Cancel();
|
|
|
|
|
Delay(1000);
|
|
|
|
|
popOutDelegate = Schedule(Hide);
|
2016-10-07 02:05:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|