1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:47:46 +08:00

Merge pull request #9018 from Game4all/allowgameplayoverlays-hide-skip

Allow disabling SkipOverlay through AllowGameplayOverlays.
This commit is contained in:
Dean Herbert 2020-05-19 19:22:51 +09:00 committed by GitHub
commit eee8af28f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 21 deletions

View File

@ -2,9 +2,9 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[TestFixture] [TestFixture]
public class TestSceneSkipOverlay : OsuManualInputManagerTestScene public class TestSceneSkipOverlay : OsuManualInputManagerTestScene
{ {
private SkipOverlay skip; private TestSkipOverlay skip;
private int requestCount; private int requestCount;
private double increment; private double increment;
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Gameplay
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
skip = new SkipOverlay(skip_time) skip = new TestSkipOverlay(skip_time)
{ {
RequestSkip = () => RequestSkip = () =>
{ {
@ -56,19 +56,19 @@ namespace osu.Game.Tests.Visual.Gameplay
public void TestFadeOnIdle() public void TestFadeOnIdle()
{ {
AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero)); AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero));
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1); AddUntilStep("fully visible", () => skip.FadingContent.Alpha == 1);
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1); AddUntilStep("wait for fade", () => skip.FadingContent.Alpha < 1);
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1); AddUntilStep("fully visible", () => skip.FadingContent.Alpha == 1);
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1); AddUntilStep("wait for fade", () => skip.FadingContent.Alpha < 1);
} }
[Test] [Test]
public void TestClickableAfterFade() public void TestClickableAfterFade()
{ {
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for fade", () => skip.Children.First().Alpha == 0); AddUntilStep("wait for fade", () => skip.FadingContent.Alpha == 0);
AddStep("click", () => InputManager.Click(MouseButton.Left)); AddStep("click", () => InputManager.Click(MouseButton.Left));
checkRequestCount(1); checkRequestCount(1);
} }
@ -105,13 +105,25 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre)); AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
AddStep("button down", () => InputManager.PressButton(MouseButton.Left)); AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
AddUntilStep("wait for overlay disappear", () => !skip.IsPresent); AddUntilStep("wait for overlay disappear", () => !skip.OverlayContent.IsPresent);
AddAssert("ensure button didn't disappear", () => skip.Children.First().Alpha > 0); AddAssert("ensure button didn't disappear", () => skip.FadingContent.Alpha > 0);
AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left)); AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left));
checkRequestCount(0); checkRequestCount(0);
} }
private void checkRequestCount(int expected) => private void checkRequestCount(int expected) =>
AddAssert($"request count is {expected}", () => requestCount == expected); AddAssert($"request count is {expected}", () => requestCount == expected);
private class TestSkipOverlay : SkipOverlay
{
public TestSkipOverlay(double startTime)
: base(startTime)
{
}
public Drawable OverlayContent => InternalChild;
public Drawable FadingContent => (OverlayContent as Container)?.Child;
}
} }
} }

View File

@ -83,6 +83,8 @@ namespace osu.Game.Screens.Play
private BreakTracker breakTracker; private BreakTracker breakTracker;
private SkipOverlay skipOverlay;
protected ScoreProcessor ScoreProcessor { get; private set; } protected ScoreProcessor ScoreProcessor { get; private set; }
protected HealthProcessor HealthProcessor { get; private set; } protected HealthProcessor HealthProcessor { get; private set; }
@ -189,6 +191,7 @@ namespace osu.Game.Screens.Play
HUDOverlay.ShowHud.Value = false; HUDOverlay.ShowHud.Value = false;
HUDOverlay.ShowHud.Disabled = true; HUDOverlay.ShowHud.Disabled = true;
BreakOverlay.Hide(); BreakOverlay.Hide();
skipOverlay.Hide();
} }
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true); DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
@ -290,7 +293,7 @@ namespace osu.Game.Screens.Play
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre
}, },
new SkipOverlay(DrawableRuleset.GameplayStartTime) skipOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime)
{ {
RequestSkip = GameplayClockContainer.Skip RequestSkip = GameplayClockContainer.Skip
}, },

View File

@ -24,13 +24,14 @@ using osu.Game.Input.Bindings;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
public class SkipOverlay : VisibilityContainer, IKeyBindingHandler<GlobalAction> public class SkipOverlay : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{ {
private readonly double startTime; private readonly double startTime;
public Action RequestSkip; public Action RequestSkip;
private Button button; private Button button;
private ButtonContainer buttonContainer;
private Box remainingTimeBox; private Box remainingTimeBox;
private FadeContainer fadeContainer; private FadeContainer fadeContainer;
@ -61,9 +62,10 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Children = new Drawable[] InternalChild = buttonContainer = new ButtonContainer
{ {
fadeContainer = new FadeContainer RelativeSizeAxes = Axes.Both,
Child = fadeContainer = new FadeContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
@ -104,14 +106,8 @@ namespace osu.Game.Screens.Play
button.Action = () => RequestSkip?.Invoke(); button.Action = () => RequestSkip?.Invoke();
displayTime = gameplayClock.CurrentTime; displayTime = gameplayClock.CurrentTime;
Show();
} }
protected override void PopIn() => this.FadeIn(fade_time);
protected override void PopOut() => this.FadeOut(fade_time);
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -121,13 +117,14 @@ namespace osu.Game.Screens.Play
remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1)); remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
button.Enabled.Value = progress > 0; button.Enabled.Value = progress > 0;
State.Value = progress > 0 ? Visibility.Visible : Visibility.Hidden; buttonContainer.State.Value = progress > 0 ? Visibility.Visible : Visibility.Hidden;
} }
protected override bool OnMouseMove(MouseMoveEvent e) protected override bool OnMouseMove(MouseMoveEvent e)
{ {
if (!e.HasAnyButtonPressed) if (!e.HasAnyButtonPressed)
fadeContainer.Show(); fadeContainer.Show();
return base.OnMouseMove(e); return base.OnMouseMove(e);
} }
@ -214,6 +211,13 @@ namespace osu.Game.Screens.Play
public override void Show() => State = Visibility.Visible; public override void Show() => State = Visibility.Visible;
} }
private class ButtonContainer : VisibilityContainer
{
protected override void PopIn() => this.FadeIn(fade_time);
protected override void PopOut() => this.FadeOut(fade_time);
}
private class Button : OsuClickableContainer private class Button : OsuClickableContainer
{ {
private Color4 colourNormal; private Color4 colourNormal;