Merge pull request #10097 from peppy/fix-overlay-sound-on-disabled

Fix overlay sound effects playing when open requested while disabled
This commit is contained in:
Dan Balasescu 2020-09-09 22:46:55 +09:00 committed by GitHub
commit 989d44412e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,6 +103,8 @@ namespace osu.Game.Graphics.Containers
{ {
} }
private bool playedPopInSound;
protected override void UpdateState(ValueChangedEvent<Visibility> state) protected override void UpdateState(ValueChangedEvent<Visibility> state)
{ {
switch (state.NewValue) switch (state.NewValue)
@ -110,16 +112,24 @@ namespace osu.Game.Graphics.Containers
case Visibility.Visible: case Visibility.Visible:
if (OverlayActivationMode.Value == OverlayActivation.Disabled) if (OverlayActivationMode.Value == OverlayActivation.Disabled)
{ {
// todo: visual/audible feedback that this operation could not complete.
State.Value = Visibility.Hidden; State.Value = Visibility.Hidden;
return; return;
} }
samplePopIn?.Play(); samplePopIn?.Play();
playedPopInSound = true;
if (BlockScreenWideMouse && DimMainContent) game?.AddBlockingOverlay(this); if (BlockScreenWideMouse && DimMainContent) game?.AddBlockingOverlay(this);
break; break;
case Visibility.Hidden: case Visibility.Hidden:
if (playedPopInSound)
{
samplePopOut?.Play(); samplePopOut?.Play();
playedPopInSound = false;
}
if (BlockScreenWideMouse) game?.RemoveBlockingOverlay(this); if (BlockScreenWideMouse) game?.RemoveBlockingOverlay(this);
break; break;
} }