mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 03:22:54 +08:00
Merge pull request #11307 from bdach/fix-account-creation-overlay-after-logout
Fix account creation overlay not showing up the first time after a log-out
This commit is contained in:
commit
69fab7de77
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -13,13 +14,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
public class TestSceneAccountCreationOverlay : OsuTestScene
|
public class TestSceneAccountCreationOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
private readonly Container userPanelArea;
|
private readonly Container userPanelArea;
|
||||||
|
private readonly AccountCreationOverlay accountCreation;
|
||||||
|
|
||||||
private IBindable<User> localUser;
|
private IBindable<User> localUser;
|
||||||
|
|
||||||
public TestSceneAccountCreationOverlay()
|
public TestSceneAccountCreationOverlay()
|
||||||
{
|
{
|
||||||
AccountCreationOverlay accountCreation;
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
accountCreation = new AccountCreationOverlay(),
|
accountCreation = new AccountCreationOverlay(),
|
||||||
@ -31,8 +31,6 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
AddStep("show", () => accountCreation.Show());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -42,8 +40,19 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
localUser = API.LocalUser.GetBoundCopy();
|
localUser = API.LocalUser.GetBoundCopy();
|
||||||
localUser.BindValueChanged(user => { userPanelArea.Child = new UserGridPanel(user.NewValue) { Width = 200 }; }, true);
|
localUser.BindValueChanged(user => { userPanelArea.Child = new UserGridPanel(user.NewValue) { Width = 200 }; }, true);
|
||||||
|
}
|
||||||
|
|
||||||
AddStep("logout", API.Logout);
|
[Test]
|
||||||
|
public void TestOverlayVisibility()
|
||||||
|
{
|
||||||
|
AddStep("start hidden", () => accountCreation.Hide());
|
||||||
|
AddStep("log out", API.Logout);
|
||||||
|
|
||||||
|
AddStep("show manually", () => accountCreation.Show());
|
||||||
|
AddUntilStep("overlay is visible", () => accountCreation.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
AddStep("log back in", () => API.Login("dummy", "password"));
|
||||||
|
AddUntilStep("overlay is hidden", () => accountCreation.State.Value == Visibility.Hidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -93,6 +94,11 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
if (welcomeScreen.GetChildScreen() != null)
|
if (welcomeScreen.GetChildScreen() != null)
|
||||||
welcomeScreen.MakeCurrent();
|
welcomeScreen.MakeCurrent();
|
||||||
|
|
||||||
|
// there might be a stale scheduled hide from a previous API state change.
|
||||||
|
// cancel it here so that the overlay is not hidden again after one frame.
|
||||||
|
scheduledHide?.Cancel();
|
||||||
|
scheduledHide = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
@ -101,7 +107,9 @@ namespace osu.Game.Overlays
|
|||||||
this.FadeOut(100);
|
this.FadeOut(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void apiStateChanged(ValueChangedEvent<APIState> state) => Schedule(() =>
|
private ScheduledDelegate scheduledHide;
|
||||||
|
|
||||||
|
private void apiStateChanged(ValueChangedEvent<APIState> state)
|
||||||
{
|
{
|
||||||
switch (state.NewValue)
|
switch (state.NewValue)
|
||||||
{
|
{
|
||||||
@ -113,9 +121,10 @@ namespace osu.Game.Overlays
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case APIState.Online:
|
case APIState.Online:
|
||||||
Hide();
|
scheduledHide?.Cancel();
|
||||||
|
scheduledHide = Schedule(Hide);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user