diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index 364ef1c7aa..c94eb40c17 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -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; diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs index f4083c55b3..230066cf9b 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs @@ -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) { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4f40899500..7bf7e4cd2a 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -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. {