mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Fix a similar case with online play sub-screens
This commit is contained in:
parent
860f1aebb3
commit
ab9290772b
@ -9,16 +9,19 @@ using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Options;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osu.Game.Tests.Visual.Multiplayer;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -306,6 +309,18 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddAssert("Toolbar is hidden", () => Game.Toolbar.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPushMatchSubScreenAndPressBackButtonImmediately()
|
||||
{
|
||||
TestMultiplayer multiplayer = null;
|
||||
|
||||
PushAndConfirm(() => multiplayer = new TestMultiplayer());
|
||||
|
||||
AddStep("open room", () => multiplayer.OpenNewRoom());
|
||||
AddStep("press back button", () => Game.ChildrenOfType<BackButton>().First().Action());
|
||||
AddWaitStep("wait two frames", 2);
|
||||
}
|
||||
|
||||
private void pushEscape() =>
|
||||
AddStep("Press escape", () => InputManager.Key(Key.Escape));
|
||||
|
||||
@ -330,5 +345,18 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
protected override bool DisplayStableImportPrompt => false;
|
||||
}
|
||||
|
||||
private class TestMultiplayer : Screens.OnlinePlay.Multiplayer.Multiplayer
|
||||
{
|
||||
[Cached(typeof(MultiplayerClient))]
|
||||
public readonly TestMultiplayerClient Client;
|
||||
|
||||
public TestMultiplayer()
|
||||
{
|
||||
Client = new TestMultiplayerClient((TestMultiplayerRoomManager)RoomManager);
|
||||
}
|
||||
|
||||
protected override RoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,10 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
public override bool OnBackButton()
|
||||
{
|
||||
if ((screenStack.CurrentScreen as IOnlinePlaySubScreen)?.OnBackButton() == true)
|
||||
if (!(screenStack.CurrentScreen is IOnlinePlaySubScreen onlineSubScreen))
|
||||
return false;
|
||||
|
||||
if (((Drawable)onlineSubScreen).IsLoaded && onlineSubScreen.AllowBackButton && onlineSubScreen.OnBackButton())
|
||||
return true;
|
||||
|
||||
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
|
||||
|
Loading…
Reference in New Issue
Block a user