1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Merge branch 'master' into fix-taiko-whistle

This commit is contained in:
Dean Herbert 2020-05-19 23:08:11 +09:00 committed by GitHub
commit dabf782a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 24 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

@ -69,6 +69,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
settings.NameField.Current.Value = expected_name; settings.NameField.Current.Value = expected_name;
settings.DurationField.Current.Value = expectedDuration; settings.DurationField.Current.Value = expectedDuration;
Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
roomManager.CreateRequested = r => roomManager.CreateRequested = r =>
{ {
@ -89,6 +90,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("setup", () => AddStep("setup", () =>
{ {
Room.Name.Value = "Test Room";
Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
fail = true; fail = true;
roomManager.CreateRequested = _ => !fail; roomManager.CreateRequested = _ => !fail;
}); });

View File

@ -133,7 +133,6 @@ namespace osu.Game.Screens.Multi.Match.Components
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
TabbableContentContainer = this, TabbableContentContainer = this,
OnCommit = (sender, text) => apply(),
}, },
}, },
new Section("Duration") new Section("Duration")
@ -196,7 +195,6 @@ namespace osu.Game.Screens.Multi.Match.Components
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
TabbableContentContainer = this, TabbableContentContainer = this,
ReadOnly = true, ReadOnly = true,
OnCommit = (sender, text) => apply()
}, },
}, },
new Section("Password (optional)") new Section("Password (optional)")
@ -207,7 +205,6 @@ namespace osu.Game.Screens.Multi.Match.Components
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
TabbableContentContainer = this, TabbableContentContainer = this,
ReadOnly = true, ReadOnly = true,
OnCommit = (sender, text) => apply()
}, },
}, },
}, },
@ -331,6 +328,9 @@ namespace osu.Game.Screens.Multi.Match.Components
private void apply() private void apply()
{ {
if (!ApplyButton.Enabled.Value)
return;
hideError(); hideError();
RoomName.Value = NameField.Text; RoomName.Value = NameField.Text;

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;