Fix up volume encapsulation

This commit is contained in:
Drew DeVault 2016-11-23 06:26:46 -05:00
parent a3db259071
commit 69cb9cf4de
3 changed files with 24 additions and 20 deletions

View File

@ -6,16 +6,17 @@
using osu.Framework.Input;
using osu.Framework.Threading;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Audio;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.UserInterface.Volume
{
internal class VolumeControl : OverlayContainer
{
public BindableDouble VolumeGlobal { get; set; }
public BindableDouble VolumeSample { get; set; }
public BindableDouble VolumeTrack { get; set; }
private BindableDouble volumeGlobal = new BindableDouble();
private BindableDouble volumeSample = new BindableDouble();
private BindableDouble volumeTrack = new BindableDouble();
private VolumeMeter volumeMeterMaster;
@ -54,20 +55,20 @@ protected override void LoadComplete()
{
base.LoadComplete();
VolumeGlobal.ValueChanged += volumeChanged;
VolumeSample.ValueChanged += volumeChanged;
VolumeTrack.ValueChanged += volumeChanged;
volumeGlobal.ValueChanged += volumeChanged;
volumeSample.ValueChanged += volumeChanged;
volumeTrack.ValueChanged += volumeChanged;
volumeMeterMaster.Bindable = VolumeGlobal;
volumeMeterEffect.Bindable = VolumeSample;
volumeMeterMusic.Bindable = VolumeTrack;
volumeMeterMaster.Bindable.Weld(volumeGlobal);
volumeMeterEffect.Bindable.Weld(volumeSample);
volumeMeterMusic.Bindable.Weld(volumeTrack);
}
protected override void Dispose(bool isDisposing)
{
VolumeGlobal.ValueChanged -= volumeChanged;
VolumeSample.ValueChanged -= volumeChanged;
VolumeTrack.ValueChanged -= volumeChanged;
volumeGlobal.ValueChanged -= volumeChanged;
volumeSample.ValueChanged -= volumeChanged;
volumeTrack.ValueChanged -= volumeChanged;
base.Dispose(isDisposing);
}
@ -82,6 +83,14 @@ public void Adjust(InputState state)
volumeMeterMaster.TriggerWheel(state);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
volumeGlobal.Weld(audio.Volume);
volumeSample.Weld(audio.VolumeSample);
volumeTrack.Weld(audio.VolumeTrack);
}
ScheduledDelegate popOutDelegate;
private VolumeMeter volumeMeterEffect;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
internal class VolumeMeter : Container
{
private Box meterFill;
public BindableDouble Bindable { get; private set; }
public BindableDouble Bindable { get; private set; } = new BindableDouble();
public VolumeMeter(string meterName)
{

View File

@ -97,12 +97,7 @@ protected override void LoadComplete()
{
RelativeSizeAxes = Axes.Both,
},
volume = new VolumeControl
{
VolumeGlobal = Audio.Volume,
VolumeSample = Audio.VolumeSample,
VolumeTrack = Audio.VolumeTrack
},
volume = new VolumeControl(),
overlayContent = new Container{ RelativeSizeAxes = Axes.Both },
new GlobalHotkeys //exists because UserInputManager is at a level below us.
{