mirror of https://github.com/ppy/osu
Prevent nullrefs
This commit is contained in:
parent
4d4e846296
commit
6c878cb167
|
@ -32,7 +32,8 @@ public class VolumeOverlay : OverlayContainer
|
|||
|
||||
private readonly BindableDouble muteAdjustment = new BindableDouble();
|
||||
|
||||
public Bindable<bool> IsMuted => muteButton.Current;
|
||||
private readonly Bindable<bool> isMuted = new Bindable<bool>();
|
||||
public Bindable<bool> IsMuted => isMuted;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, OsuColour colours)
|
||||
|
@ -66,7 +67,8 @@ private void load(AudioManager audio, OsuColour colours)
|
|||
volumeMeterMusic = new VolumeMeter("MUSIC", 125, colours.BlueDarker),
|
||||
muteButton = new MuteButton
|
||||
{
|
||||
Margin = new MarginPadding { Top = 100 }
|
||||
Margin = new MarginPadding { Top = 100 },
|
||||
Current = { BindTarget = isMuted }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -76,13 +78,13 @@ private void load(AudioManager audio, OsuColour colours)
|
|||
volumeMeterEffect.Bindable.BindTo(audio.VolumeSample);
|
||||
volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack);
|
||||
|
||||
muteButton.Current.ValueChanged += muted =>
|
||||
isMuted.BindValueChanged(muted =>
|
||||
{
|
||||
if (muted.NewValue)
|
||||
audio.AddAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
||||
else
|
||||
audio.RemoveAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
|
Loading…
Reference in New Issue