mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 14:42:56 +08:00
Prevent nullrefs
This commit is contained in:
parent
4d4e846296
commit
6c878cb167
@ -32,7 +32,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private readonly BindableDouble muteAdjustment = new BindableDouble();
|
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]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, OsuColour colours)
|
private void load(AudioManager audio, OsuColour colours)
|
||||||
@ -66,7 +67,8 @@ namespace osu.Game.Overlays
|
|||||||
volumeMeterMusic = new VolumeMeter("MUSIC", 125, colours.BlueDarker),
|
volumeMeterMusic = new VolumeMeter("MUSIC", 125, colours.BlueDarker),
|
||||||
muteButton = new MuteButton
|
muteButton = new MuteButton
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Top = 100 }
|
Margin = new MarginPadding { Top = 100 },
|
||||||
|
Current = { BindTarget = isMuted }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -76,13 +78,13 @@ namespace osu.Game.Overlays
|
|||||||
volumeMeterEffect.Bindable.BindTo(audio.VolumeSample);
|
volumeMeterEffect.Bindable.BindTo(audio.VolumeSample);
|
||||||
volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack);
|
volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack);
|
||||||
|
|
||||||
muteButton.Current.ValueChanged += muted =>
|
isMuted.BindValueChanged(muted =>
|
||||||
{
|
{
|
||||||
if (muted.NewValue)
|
if (muted.NewValue)
|
||||||
audio.AddAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
audio.AddAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
||||||
else
|
else
|
||||||
audio.RemoveAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
audio.RemoveAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
Loading…
Reference in New Issue
Block a user