mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Properly fix dialog overlay playing double samples on show/hide
This commit is contained in:
parent
f9c6a8c5b7
commit
e0bf579b18
@ -21,8 +21,6 @@ namespace osu.Game.Graphics.Containers
|
||||
private SampleChannel samplePopIn;
|
||||
private SampleChannel samplePopOut;
|
||||
|
||||
protected virtual bool PlaySamplesOnStateChange => true;
|
||||
|
||||
protected override bool BlockNonPositionalInput => true;
|
||||
|
||||
/// <summary>
|
||||
@ -126,12 +124,12 @@ namespace osu.Game.Graphics.Containers
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlaySamplesOnStateChange) samplePopIn?.Play();
|
||||
samplePopIn?.Play();
|
||||
if (BlockScreenWideMouse && DimMainContent) game?.AddBlockingOverlay(this);
|
||||
break;
|
||||
|
||||
case Visibility.Hidden:
|
||||
if (PlaySamplesOnStateChange) samplePopOut?.Play();
|
||||
samplePopOut?.Play();
|
||||
if (BlockScreenWideMouse) game?.RemoveBlockingOverlay(this);
|
||||
break;
|
||||
}
|
||||
|
@ -13,20 +13,17 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Dialog
|
||||
{
|
||||
public class PopupDialog : OsuFocusedOverlayContainer
|
||||
public class PopupDialog : VisibilityContainer
|
||||
{
|
||||
public static readonly float ENTER_DURATION = 500;
|
||||
public static readonly float EXIT_DURATION = 200;
|
||||
|
||||
protected override bool BlockPositionalInput => false;
|
||||
|
||||
private readonly Vector2 ringSize = new Vector2(100f);
|
||||
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
|
||||
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
|
||||
@ -202,18 +199,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
};
|
||||
}
|
||||
|
||||
public override bool OnPressed(GlobalAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case GlobalAction.Select:
|
||||
Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.Click();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnPressed(action);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Repeat) return false;
|
||||
@ -238,8 +223,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
actionInvoked = false;
|
||||
|
||||
// Reset various animations but only if the dialog animation fully completed
|
||||
@ -263,7 +246,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
// This is presumed to always be a sane default "cancel" action.
|
||||
buttonsContainer.Last().Click();
|
||||
|
||||
base.PopOut();
|
||||
content.FadeOut(EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input.Bindings;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -41,8 +43,6 @@ namespace osu.Game.Overlays
|
||||
Show();
|
||||
}
|
||||
|
||||
protected override bool PlaySamplesOnStateChange => false;
|
||||
|
||||
protected override bool BlockNonPositionalInput => true;
|
||||
|
||||
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
||||
@ -74,5 +74,17 @@ namespace osu.Game.Overlays
|
||||
|
||||
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
public override bool OnPressed(GlobalAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case GlobalAction.Select:
|
||||
currentDialog.Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.Click();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnPressed(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user