Fix dialog overlay playing double samples on show/hide

This commit is contained in:
Dean Herbert 2018-06-21 16:47:05 +09:00
parent 4c14f547dd
commit a2fa55c426
2 changed files with 10 additions and 4 deletions

View File

@ -17,6 +17,8 @@ namespace osu.Game.Graphics.Containers
private SampleChannel samplePopIn;
private SampleChannel samplePopOut;
protected virtual bool PlaySamplesOnStateChange => true;
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
[BackgroundDependencyLoader(true)]
@ -28,7 +30,7 @@ namespace osu.Game.Graphics.Containers
samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in");
samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out");
StateChanged += onStateChanged;
StateChanged += OnStateChanged;
}
/// <summary>
@ -51,18 +53,20 @@ namespace osu.Game.Graphics.Containers
return base.OnClick(state);
}
private void onStateChanged(Visibility visibility)
protected virtual void OnStateChanged(Visibility visibility)
{
switch (visibility)
{
case Visibility.Visible:
if (OverlayActivationMode != OverlayActivation.Disabled)
samplePopIn?.Play();
{
if (PlaySamplesOnStateChange) samplePopIn?.Play();
}
else
State = Visibility.Hidden;
break;
case Visibility.Hidden:
samplePopOut?.Play();
if (PlaySamplesOnStateChange) samplePopOut?.Play();
break;
}
}

View File

@ -30,6 +30,8 @@ namespace osu.Game.Overlays
State = Visibility.Visible;
}
protected override bool PlaySamplesOnStateChange => false;
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
{
if (v != Visibility.Hidden) return;