mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 09:32:55 +08:00
Move screen pushes into function, rename receptor
This commit is contained in:
parent
e8c039bb8a
commit
6d1203a599
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
@ -43,7 +44,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddUntilStep("wait for load", () => osuGame.IsLoaded);
|
||||
AddUntilStep("wait for main menu", () =>
|
||||
AddUntilStep("exit to main menu", () =>
|
||||
{
|
||||
var current = osuGame.ScreenStack.CurrentScreen;
|
||||
|
||||
@ -69,8 +70,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
TestSongSelect songSelect = null;
|
||||
|
||||
AddStep("Push song select", () => osuGame.ScreenStack.Push(songSelect = new TestSongSelect()));
|
||||
AddUntilStep("Wait for song select", () => songSelect.IsCurrentScreen());
|
||||
pushAndConfirm(() => songSelect = new TestSongSelect(), "song select");
|
||||
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
|
||||
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
|
||||
AddStep("Press escape", () => pressAndRelease(Key.Escape));
|
||||
@ -83,8 +83,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
TestSongSelect songSelect = null;
|
||||
|
||||
AddStep("Push song select", () => osuGame.ScreenStack.Push(songSelect = new TestSongSelect()));
|
||||
AddUntilStep("Wait for song select", () => songSelect.IsCurrentScreen());
|
||||
pushAndConfirm(() => songSelect = new TestSongSelect(), "song select");
|
||||
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
|
||||
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
|
||||
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(osuGame.BackButton));
|
||||
@ -100,24 +99,24 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[Test]
|
||||
public void TestExitMultiWithEscape()
|
||||
{
|
||||
Screens.Multi.Multiplayer multiplayer = null;
|
||||
|
||||
AddStep("Push multiplayer", () => osuGame.ScreenStack.Push(multiplayer = new Screens.Multi.Multiplayer()));
|
||||
AddUntilStep("Wait for multiplayer", () => multiplayer.IsCurrentScreen());
|
||||
pushAndConfirm(() => new Screens.Multi.Multiplayer(), "multiplayer");
|
||||
exitViaEscapeAndConfirm();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExitMultiWithBackButton()
|
||||
{
|
||||
Screens.Multi.Multiplayer multiplayer = null;
|
||||
|
||||
AddStep("Push multiplayer", () => osuGame.ScreenStack.Push(multiplayer = new Screens.Multi.Multiplayer()));
|
||||
AddUntilStep("Wait for multiplayer", () => multiplayer.IsCurrentScreen());
|
||||
|
||||
pushAndConfirm(() => new Screens.Multi.Multiplayer(), "multiplayer");
|
||||
exitViaBackButtonAndConfirm();
|
||||
}
|
||||
|
||||
private void pushAndConfirm(Func<Screen> newScreen, string screenName)
|
||||
{
|
||||
Screen screen = null;
|
||||
AddStep($"Push new {screenName}", () => osuGame.ScreenStack.Push(screen = newScreen()));
|
||||
AddUntilStep($"Wait for new {screenName}", () => screen.IsCurrentScreen());
|
||||
}
|
||||
|
||||
private void exitViaEscapeAndConfirm()
|
||||
{
|
||||
AddStep("Press escape", () => pressAndRelease(Key.Escape));
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
public TestSceneBackButton()
|
||||
{
|
||||
BackButton button;
|
||||
BackButton.BackButtonReceptor receptor = new BackButton.BackButtonReceptor();
|
||||
BackButton.Receptor receptor = new BackButton.Receptor();
|
||||
|
||||
Child = new Container
|
||||
{
|
||||
|
@ -16,9 +16,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private readonly TwoLayerButton button;
|
||||
|
||||
public BackButton(BackButtonReceptor receptor)
|
||||
public BackButton(Receptor receptor)
|
||||
{
|
||||
receptor.OnBackPressed += () => Action.Invoke();
|
||||
receptor.OnBackPressed = () => Action.Invoke();
|
||||
|
||||
Size = TwoLayerButton.SIZE_EXTENDED;
|
||||
|
||||
@ -51,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
button.FadeOut(400, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public class BackButtonReceptor : Drawable, IKeyBindingHandler<GlobalAction>
|
||||
public class Receptor : Drawable, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public Action OnBackPressed;
|
||||
|
||||
|
@ -84,8 +84,6 @@ namespace osu.Game
|
||||
protected OsuScreenStack ScreenStack;
|
||||
protected BackButton BackButton;
|
||||
|
||||
private BackButton.BackButtonReceptor backButtonReceptor;
|
||||
|
||||
private VolumeOverlay volume;
|
||||
private OsuLogo osuLogo;
|
||||
|
||||
@ -393,6 +391,7 @@ namespace osu.Game
|
||||
ScoreManager.PresentImport = items => PresentScore(items.First());
|
||||
|
||||
Container logoContainer;
|
||||
BackButton.Receptor receptor;
|
||||
|
||||
dependencies.CacheAs(idleTracker = new GameIdleTracker(6000));
|
||||
|
||||
@ -409,9 +408,9 @@ namespace osu.Game
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
backButtonReceptor = new BackButton.BackButtonReceptor(),
|
||||
receptor = new BackButton.Receptor(),
|
||||
ScreenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both },
|
||||
BackButton = new BackButton(backButtonReceptor)
|
||||
BackButton = new BackButton(receptor)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
|
Loading…
Reference in New Issue
Block a user