Prevent nullrefs

This commit is contained in:
smoogipoo 2019-10-03 19:11:50 +09:00
parent 4d4e846296
commit 6c878cb167
1 changed files with 6 additions and 4 deletions

View File

@ -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()