2016-12-06 09:56:20 +00:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2016-10-26 09:45:48 +00:00
|
|
|
|
using osu.Framework;
|
2016-10-12 14:36:42 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
2016-10-06 18:05:26 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Input;
|
2016-10-26 09:45:48 +00:00
|
|
|
|
using osu.Framework.Threading;
|
2016-10-12 17:45:42 +00:00
|
|
|
|
using OpenTK;
|
2016-11-14 16:22:20 +00:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2016-11-23 11:26:46 +00:00
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Allocation;
|
2016-10-06 18:05:26 +00:00
|
|
|
|
|
2016-10-26 09:45:48 +00:00
|
|
|
|
namespace osu.Game.Graphics.UserInterface.Volume
|
2016-10-06 18:05:26 +00:00
|
|
|
|
{
|
2016-10-26 09:45:48 +00:00
|
|
|
|
internal class VolumeControl : OverlayContainer
|
2016-10-06 18:05:26 +00:00
|
|
|
|
{
|
2016-10-26 09:45:48 +00:00
|
|
|
|
private VolumeMeter volumeMeterMaster;
|
|
|
|
|
|
|
|
|
|
private void volumeChanged(object sender, EventArgs e)
|
2016-10-12 19:17:53 +00:00
|
|
|
|
{
|
2016-10-26 09:45:48 +00:00
|
|
|
|
Show();
|
|
|
|
|
schedulePopOut();
|
2016-10-12 19:17:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-22 08:50:42 +00:00
|
|
|
|
public VolumeControl()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2016-10-26 09:45:48 +00:00
|
|
|
|
Anchor = Anchor.BottomRight;
|
|
|
|
|
Origin = Anchor.BottomRight;
|
2016-11-12 17:34:36 +00:00
|
|
|
|
|
2016-11-23 07:12:21 +00:00
|
|
|
|
Children = new Drawable[]
|
2016-11-12 17:34:36 +00:00
|
|
|
|
{
|
2016-11-23 07:12:21 +00:00
|
|
|
|
new FlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
Margin = new MarginPadding { Left = 10, Right = 10, Top = 30, Bottom = 30 },
|
|
|
|
|
Spacing = new Vector2(15, 0),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
volumeMeterMaster = new VolumeMeter("Master"),
|
|
|
|
|
volumeMeterEffect = new VolumeMeter("Effects"),
|
|
|
|
|
volumeMeterMusic = new VolumeMeter("Music")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-10-22 08:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 17:34:36 +00:00
|
|
|
|
protected override void LoadComplete()
|
2016-10-06 18:05:26 +00:00
|
|
|
|
{
|
2016-11-12 17:34:36 +00:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2016-11-29 09:35:40 +00:00
|
|
|
|
volumeMeterMaster.Bindable.ValueChanged += volumeChanged;
|
|
|
|
|
volumeMeterEffect.Bindable.ValueChanged += volumeChanged;
|
|
|
|
|
volumeMeterMusic.Bindable.ValueChanged += volumeChanged;
|
2016-10-06 18:05:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 14:52:49 +00:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
2016-11-29 09:35:40 +00:00
|
|
|
|
|
|
|
|
|
volumeMeterMaster.Bindable.ValueChanged -= volumeChanged;
|
|
|
|
|
volumeMeterEffect.Bindable.ValueChanged -= volumeChanged;
|
|
|
|
|
volumeMeterMusic.Bindable.ValueChanged -= volumeChanged;
|
2016-10-13 14:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 06:22:14 +00:00
|
|
|
|
public void Adjust(InputState state)
|
2016-10-06 18:05:26 +00:00
|
|
|
|
{
|
2016-10-26 09:45:48 +00:00
|
|
|
|
if (!IsVisible)
|
2016-11-15 06:22:14 +00:00
|
|
|
|
{
|
|
|
|
|
Show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-10-26 09:45:48 +00:00
|
|
|
|
|
2016-11-06 07:25:21 +00:00
|
|
|
|
volumeMeterMaster.TriggerWheel(state);
|
2016-10-06 18:05:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-23 11:26:46 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(AudioManager audio)
|
|
|
|
|
{
|
2016-11-29 09:35:40 +00:00
|
|
|
|
volumeMeterMaster.Bindable.Weld(audio.Volume);
|
|
|
|
|
volumeMeterEffect.Bindable.Weld(audio.VolumeSample);
|
|
|
|
|
volumeMeterMusic.Bindable.Weld(audio.VolumeTrack);
|
2016-11-23 11:26:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-26 09:45:48 +00:00
|
|
|
|
ScheduledDelegate popOutDelegate;
|
|
|
|
|
|
2016-11-23 07:12:21 +00:00
|
|
|
|
private VolumeMeter volumeMeterEffect;
|
|
|
|
|
private VolumeMeter volumeMeterMusic;
|
|
|
|
|
|
2016-10-26 09:45:48 +00:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
ClearTransformations();
|
|
|
|
|
FadeIn(100);
|
|
|
|
|
|
|
|
|
|
schedulePopOut();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
FadeOut(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void schedulePopOut()
|
2016-10-06 18:05:26 +00:00
|
|
|
|
{
|
2016-10-26 09:45:48 +00:00
|
|
|
|
popOutDelegate?.Cancel();
|
|
|
|
|
Delay(1000);
|
|
|
|
|
popOutDelegate = Schedule(Hide);
|
2016-10-06 18:05:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|