From ae85e2a3ff94a6c43282bf7ea084baff1cc060f9 Mon Sep 17 00:00:00 2001 From: Ethan Date: Fri, 28 Apr 2023 19:51:10 +0800 Subject: [PATCH 01/13] Update LoginForm.cs --- osu.Game/Overlays/Login/LoginForm.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginForm.cs b/osu.Game/Overlays/Login/LoginForm.cs index af145c418c..5f27db90e9 100644 --- a/osu.Game/Overlays/Login/LoginForm.cs +++ b/osu.Game/Overlays/Login/LoginForm.cs @@ -42,10 +42,14 @@ namespace osu.Game.Overlays.Login private void load(OsuConfigManager config, AccountCreationOverlay accountCreation) { Direction = FillDirection.Vertical; - Spacing = new Vector2(0, 5); + Spacing = new Vector2(0, SettingsSection.ITEM_SPACING); AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; - + Padding = new MarginPadding + { + Top = 5, + Bottom = 24, + }; ErrorTextFlowContainer errorText; LinkFlowContainer forgottenPaswordLink; @@ -81,7 +85,11 @@ namespace osu.Game.Overlays.Login }, forgottenPaswordLink = new LinkFlowContainer { - Padding = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS }, + Padding = new MarginPadding + { + Left = SettingsPanel.CONTENT_MARGINS, + Bottom = SettingsSection.ITEM_SPACING + }, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, }, From 25c9bf40614b2c89683b5415f43163baf7760b77 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 11:22:05 -0700 Subject: [PATCH 02/13] Improve and refactor `LoginPanel` test scene to use `LoginOverlay` --- .../Visual/Menus/TestSceneLoginOverlay.cs | 89 +++++++++++++++++++ .../Visual/Menus/TestSceneLoginPanel.cs | 78 ---------------- osu.Game/Online/API/DummyAPIAccess.cs | 8 ++ 3 files changed, 97 insertions(+), 78 deletions(-) create mode 100644 osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs delete mode 100644 osu.Game.Tests/Visual/Menus/TestSceneLoginPanel.cs diff --git a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs new file mode 100644 index 0000000000..5c2edac84d --- /dev/null +++ b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs @@ -0,0 +1,89 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; +using osu.Game.Overlays; +using osu.Game.Users.Drawables; +using osuTK.Input; + +namespace osu.Game.Tests.Visual.Menus +{ + [TestFixture] + public partial class TestSceneLoginOverlay : OsuManualInputManagerTestScene + { + private LoginOverlay loginOverlay = null!; + + [BackgroundDependencyLoader] + private void load() + { + Child = loginOverlay = new LoginOverlay + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; + } + + [SetUpSteps] + public void SetUpSteps() + { + AddStep("show login overlay", () => loginOverlay.Show()); + } + + [Test] + public void TestLoginSuccess() + { + AddStep("logout", () => API.Logout()); + + AddStep("enter password", () => loginOverlay.ChildrenOfType().First().Text = "password"); + AddStep("submit", () => loginOverlay.ChildrenOfType().First(b => b.Text.ToString() == "Sign in").TriggerClick()); + } + + [Test] + public void TestLoginFailure() + { + AddStep("logout", () => + { + API.Logout(); + ((DummyAPIAccess)API).FailNextLogin(); + }); + + AddStep("enter password", () => loginOverlay.ChildrenOfType().First().Text = "password"); + AddStep("submit", () => loginOverlay.ChildrenOfType().First(b => b.Text.ToString() == "Sign in").TriggerClick()); + } + + [Test] + public void TestLoginConnecting() + { + AddStep("logout", () => + { + API.Logout(); + ((DummyAPIAccess)API).StayConnectingNextLogin(); + }); + + AddStep("enter password", () => loginOverlay.ChildrenOfType().First().Text = "password"); + AddStep("submit", () => loginOverlay.ChildrenOfType().First(b => b.Text.ToString() == "Sign in").TriggerClick()); + } + + [Test] + public void TestClickingOnFlagClosesOverlay() + { + AddStep("logout", () => API.Logout()); + AddStep("enter password", () => loginOverlay.ChildrenOfType().First().Text = "password"); + AddStep("submit", () => loginOverlay.ChildrenOfType().First(b => b.Text.ToString() == "Sign in").TriggerClick()); + + AddStep("click on flag", () => + { + InputManager.MoveMouseTo(loginOverlay.ChildrenOfType().First()); + InputManager.Click(MouseButton.Left); + }); + AddAssert("login overlay is hidden", () => loginOverlay.State.Value == Visibility.Hidden); + } + } +} diff --git a/osu.Game.Tests/Visual/Menus/TestSceneLoginPanel.cs b/osu.Game.Tests/Visual/Menus/TestSceneLoginPanel.cs deleted file mode 100644 index 738220f5ce..0000000000 --- a/osu.Game.Tests/Visual/Menus/TestSceneLoginPanel.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -#nullable disable - -using System.Linq; -using NUnit.Framework; -using osu.Framework.Graphics; -using osu.Framework.Testing; -using osu.Game.Graphics.UserInterface; -using osu.Game.Online.API; -using osu.Game.Overlays.Login; -using osu.Game.Users.Drawables; -using osuTK.Input; - -namespace osu.Game.Tests.Visual.Menus -{ - [TestFixture] - public partial class TestSceneLoginPanel : OsuManualInputManagerTestScene - { - private LoginPanel loginPanel; - private int hideCount; - - [SetUpSteps] - public void SetUpSteps() - { - AddStep("create login dialog", () => - { - Add(loginPanel = new LoginPanel - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 0.5f, - RequestHide = () => hideCount++, - }); - }); - } - - [Test] - public void TestLoginSuccess() - { - AddStep("logout", () => API.Logout()); - - AddStep("enter password", () => loginPanel.ChildrenOfType().First().Text = "password"); - AddStep("submit", () => loginPanel.ChildrenOfType().First(b => b.Text.ToString() == "Sign in").TriggerClick()); - } - - [Test] - public void TestLoginFailure() - { - AddStep("logout", () => - { - API.Logout(); - ((DummyAPIAccess)API).FailNextLogin(); - }); - - AddStep("enter password", () => loginPanel.ChildrenOfType().First().Text = "password"); - AddStep("submit", () => loginPanel.ChildrenOfType().First(b => b.Text.ToString() == "Sign in").TriggerClick()); - } - - [Test] - public void TestClickingOnFlagClosesPanel() - { - AddStep("reset hide count", () => hideCount = 0); - - AddStep("logout", () => API.Logout()); - AddStep("enter password", () => loginPanel.ChildrenOfType().First().Text = "password"); - AddStep("submit", () => loginPanel.ChildrenOfType().First(b => b.Text.ToString() == "Sign in").TriggerClick()); - - AddStep("click on flag", () => - { - InputManager.MoveMouseTo(loginPanel.ChildrenOfType().First()); - InputManager.Click(MouseButton.Left); - }); - AddAssert("hide requested", () => hideCount == 1); - } - } -} diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs index bf9baa4414..c2ef0b4e92 100644 --- a/osu.Game/Online/API/DummyAPIAccess.cs +++ b/osu.Game/Online/API/DummyAPIAccess.cs @@ -56,6 +56,7 @@ namespace osu.Game.Online.API private readonly Bindable state = new Bindable(APIState.Online); private bool shouldFailNextLogin; + private bool stayConnectingNextLogin; /// /// The current connectivity state of the API. @@ -94,6 +95,12 @@ namespace osu.Game.Online.API { state.Value = APIState.Connecting; + if (stayConnectingNextLogin) + { + stayConnectingNextLogin = false; + return; + } + if (shouldFailNextLogin) { LastLoginError = new APIException("Not powerful enough to login.", new ArgumentException(nameof(shouldFailNextLogin))); @@ -138,6 +145,7 @@ namespace osu.Game.Online.API IBindable IAPIProvider.Activity => Activity; public void FailNextLogin() => shouldFailNextLogin = true; + public void StayConnectingNextLogin() => stayConnectingNextLogin = true; protected override void Dispose(bool isDisposing) { From 1058f434d75d74f3814c5f90756e14824decda26 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 10:07:30 -0700 Subject: [PATCH 03/13] Update login overlay background to conform to other overlays --- osu.Game/Overlays/LoginOverlay.cs | 41 ++++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 8b60024682..b16cc5bd4b 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -4,9 +4,10 @@ #nullable disable using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; +using osu.Framework.Graphics.Effects; using osuTK.Graphics; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; @@ -21,13 +22,24 @@ namespace osu.Game.Overlays private const float transition_time = 400; + [Cached] + private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); + public LoginOverlay() { AutoSizeAxes = Axes.Both; + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0), + Type = EdgeEffectType.Shadow, + Radius = 10, + Hollow = true, + }; } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load() { Children = new Drawable[] { @@ -40,8 +52,7 @@ namespace osu.Game.Overlays new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.6f, + Colour = colourProvider.Background4, }, new Container { @@ -50,23 +61,11 @@ namespace osu.Game.Overlays Masking = true, AutoSizeDuration = transition_time, AutoSizeEasing = Easing.OutQuint, - Children = new Drawable[] + Child = panel = new LoginPanel { - panel = new LoginPanel - { - Padding = new MarginPadding(10), - RequestHide = Hide, - }, - new Box - { - RelativeSizeAxes = Axes.X, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Height = 3, - Colour = colours.Yellow, - Alpha = 1, - }, - } + Padding = new MarginPadding(10), + RequestHide = Hide, + }, } } } @@ -77,6 +76,7 @@ namespace osu.Game.Overlays { panel.Bounding = true; this.FadeIn(transition_time, Easing.OutQuint); + FadeEdgeEffectTo(WaveContainer.SHADOW_OPACITY, WaveContainer.APPEAR_DURATION, Easing.Out); ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(panel)); } @@ -87,6 +87,7 @@ namespace osu.Game.Overlays panel.Bounding = false; this.FadeOut(transition_time); + FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.In); } } } From 442fda3598699f69853d739634473a60378389e8 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 10:15:16 -0700 Subject: [PATCH 04/13] Remove using aliases --- osu.Game/Overlays/Login/LoginPanel.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginPanel.cs b/osu.Game/Overlays/Login/LoginPanel.cs index 79569ada65..80238f5474 100644 --- a/osu.Game/Overlays/Login/LoginPanel.cs +++ b/osu.Game/Overlays/Login/LoginPanel.cs @@ -9,6 +9,7 @@ using osu.Framework.Bindables; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -18,8 +19,6 @@ using osu.Game.Localisation; using osu.Game.Online.API; using osu.Game.Users; using osuTK; -using RectangleF = osu.Framework.Graphics.Primitives.RectangleF; -using Container = osu.Framework.Graphics.Containers.Container; namespace osu.Game.Overlays.Login { From 4a3b8c405eeb27ab6b7e7e7743f332d0940ab14c Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 11:47:32 -0700 Subject: [PATCH 05/13] Fix login error text adding unnecessary spacing --- osu.Game/Overlays/Login/LoginForm.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Overlays/Login/LoginForm.cs b/osu.Game/Overlays/Login/LoginForm.cs index 47e706fe58..f56753dbe7 100644 --- a/osu.Game/Overlays/Login/LoginForm.cs +++ b/osu.Game/Overlays/Login/LoginForm.cs @@ -73,6 +73,7 @@ namespace osu.Game.Overlays.Login { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Alpha = 0, }, new SettingsCheckbox { @@ -128,7 +129,10 @@ namespace osu.Game.Overlays.Login password.OnCommit += (_, _) => performLogin(); if (api.LastLoginError?.Message is string error) + { + errorText.Alpha = 1; errorText.AddErrors(new[] { error }); + } } public override bool AcceptsFocus => true; From 4582faee7988c4c0b3a49c1c47058edb39217174 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 12:06:02 -0700 Subject: [PATCH 06/13] Refactor login panel to not inherit `FillFlowContainer` --- osu.Game/Overlays/Login/LoginForm.cs | 6 ++ osu.Game/Overlays/Login/LoginPanel.cs | 101 ++++++++++++-------------- 2 files changed, 53 insertions(+), 54 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginForm.cs b/osu.Game/Overlays/Login/LoginForm.cs index f56753dbe7..55490198f8 100644 --- a/osu.Game/Overlays/Login/LoginForm.cs +++ b/osu.Game/Overlays/Login/LoginForm.cs @@ -11,6 +11,7 @@ using osu.Framework.Input.Events; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Overlays.Settings; @@ -56,6 +57,11 @@ namespace osu.Game.Overlays.Login Children = new Drawable[] { + new OsuSpriteText + { + Text = LoginPanelStrings.Account.ToUpper(), + Font = OsuFont.GetFont(weight: FontWeight.Bold), + }, username = new OsuTextBox { PlaceholderText = UsersStrings.LoginUsername.ToLower(), diff --git a/osu.Game/Overlays/Login/LoginPanel.cs b/osu.Game/Overlays/Login/LoginPanel.cs index 80238f5474..6c09b2e6ed 100644 --- a/osu.Game/Overlays/Login/LoginPanel.cs +++ b/osu.Game/Overlays/Login/LoginPanel.cs @@ -22,7 +22,7 @@ using osuTK; namespace osu.Game.Overlays.Login { - public partial class LoginPanel : FillFlowContainer + public partial class LoginPanel : Container { private bool bounding = true; private LoginForm form; @@ -59,8 +59,6 @@ namespace osu.Game.Overlays.Login { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Direction = FillDirection.Vertical; - Spacing = new Vector2(0f, 5f); } [BackgroundDependencyLoader] @@ -77,18 +75,9 @@ namespace osu.Game.Overlays.Login switch (state.NewValue) { case APIState.Offline: - Children = new Drawable[] + Child = form = new LoginForm { - new OsuSpriteText - { - Text = LoginPanelStrings.Account.ToUpper(), - Margin = new MarginPadding { Bottom = 5 }, - Font = OsuFont.GetFont(weight: FontWeight.Bold), - }, - form = new LoginForm - { - RequestHide = RequestHide - } + RequestHide = RequestHide }; break; @@ -96,22 +85,29 @@ namespace osu.Game.Overlays.Login case APIState.Connecting: LinkFlowContainer linkFlow; - Children = new Drawable[] + Child = new FillFlowContainer { - new LoadingSpinner + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 5f), + Children = new Drawable[] { - State = { Value = Visibility.Visible }, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - }, - linkFlow = new LinkFlowContainer - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - TextAnchor = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, - Text = state.NewValue == APIState.Failing ? ToolbarStrings.AttemptingToReconnect : ToolbarStrings.Connecting, - Margin = new MarginPadding { Top = 10, Bottom = 10 }, + new LoadingSpinner + { + State = { Value = Visibility.Visible }, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, + linkFlow = new LinkFlowContainer + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextAnchor = Anchor.TopCentre, + AutoSizeAxes = Axes.Both, + Text = state.NewValue == APIState.Failing ? ToolbarStrings.AttemptingToReconnect : ToolbarStrings.Connecting, + Margin = new MarginPadding { Top = 10, Bottom = 10 }, + }, }, }; @@ -119,40 +115,37 @@ namespace osu.Game.Overlays.Login break; case APIState.Online: - Children = new Drawable[] + Child = new FillFlowContainer { - new FillFlowContainer + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Left = 20, Right = 20 }, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 10f), + Children = new Drawable[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Left = 20, Right = 20 }, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0f, 10f), - Children = new Drawable[] + new Container { - new Container + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new[] + new OsuSpriteText { - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Text = LoginPanelStrings.SignedIn, - Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), - Margin = new MarginPadding { Top = 5, Bottom = 5 }, - }, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = LoginPanelStrings.SignedIn, + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), + Margin = new MarginPadding { Top = 5, Bottom = 5 }, }, }, - panel = new UserGridPanel(api.LocalUser.Value) - { - RelativeSizeAxes = Axes.X, - Action = RequestHide - }, - dropdown = new UserDropdown { RelativeSizeAxes = Axes.X }, }, + panel = new UserGridPanel(api.LocalUser.Value) + { + RelativeSizeAxes = Axes.X, + Action = RequestHide + }, + dropdown = new UserDropdown { RelativeSizeAxes = Axes.X }, }, }; From 671f84e32b26f6a92cdd5a3d82b0215d8b65f708 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 12:15:03 -0700 Subject: [PATCH 07/13] Remove unnecessary container --- osu.Game/Overlays/Login/LoginPanel.cs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginPanel.cs b/osu.Game/Overlays/Login/LoginPanel.cs index 6c09b2e6ed..885f5639a7 100644 --- a/osu.Game/Overlays/Login/LoginPanel.cs +++ b/osu.Game/Overlays/Login/LoginPanel.cs @@ -124,21 +124,13 @@ namespace osu.Game.Overlays.Login Spacing = new Vector2(0f, 10f), Children = new Drawable[] { - new Container + new OsuSpriteText { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new[] - { - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Text = LoginPanelStrings.SignedIn, - Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), - Margin = new MarginPadding { Top = 5, Bottom = 5 }, - }, - }, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = LoginPanelStrings.SignedIn, + Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), + Margin = new MarginPadding { Top = 5, Bottom = 5 }, }, panel = new UserGridPanel(api.LocalUser.Value) { From 6ebc2581c2a207fe45ee1b6cac2adb2a9bfe04cf Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 12:26:01 -0700 Subject: [PATCH 08/13] Normalise login overlay padding/spacing --- osu.Game/Overlays/Login/LoginForm.cs | 67 +++++++++++++------------ osu.Game/Overlays/Login/LoginPanel.cs | 10 ++-- osu.Game/Overlays/Login/UserDropdown.cs | 3 -- osu.Game/Overlays/LoginOverlay.cs | 3 +- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginForm.cs b/osu.Game/Overlays/Login/LoginForm.cs index 55490198f8..0eef55162f 100644 --- a/osu.Game/Overlays/Login/LoginForm.cs +++ b/osu.Game/Overlays/Login/LoginForm.cs @@ -43,43 +43,50 @@ namespace osu.Game.Overlays.Login [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuConfigManager config, AccountCreationOverlay accountCreation) { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; Spacing = new Vector2(0, SettingsSection.ITEM_SPACING); - AutoSizeAxes = Axes.Y; - RelativeSizeAxes = Axes.X; - Padding = new MarginPadding - { - Top = 5, - Bottom = 24, - }; + ErrorTextFlowContainer errorText; LinkFlowContainer forgottenPasswordLink; Children = new Drawable[] { - new OsuSpriteText - { - Text = LoginPanelStrings.Account.ToUpper(), - Font = OsuFont.GetFont(weight: FontWeight.Bold), - }, - username = new OsuTextBox - { - PlaceholderText = UsersStrings.LoginUsername.ToLower(), - RelativeSizeAxes = Axes.X, - Text = api.ProvidedUsername, - TabbableContentContainer = this - }, - password = new OsuPasswordTextBox - { - PlaceholderText = UsersStrings.LoginPassword.ToLower(), - RelativeSizeAxes = Axes.X, - TabbableContentContainer = this, - }, - errorText = new ErrorTextFlowContainer + new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Alpha = 0, + Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS }, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, SettingsSection.ITEM_SPACING), + Children = new Drawable[] + { + new OsuSpriteText + { + Text = LoginPanelStrings.Account.ToUpper(), + Font = OsuFont.GetFont(weight: FontWeight.Bold), + }, + username = new OsuTextBox + { + PlaceholderText = UsersStrings.LoginUsername.ToLower(), + RelativeSizeAxes = Axes.X, + Text = api.ProvidedUsername, + TabbableContentContainer = this + }, + password = new OsuPasswordTextBox + { + PlaceholderText = UsersStrings.LoginPassword.ToLower(), + RelativeSizeAxes = Axes.X, + TabbableContentContainer = this, + }, + errorText = new ErrorTextFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Alpha = 0, + }, + }, }, new SettingsCheckbox { @@ -93,11 +100,7 @@ namespace osu.Game.Overlays.Login }, forgottenPasswordLink = new LinkFlowContainer { - Padding = new MarginPadding - { - Left = SettingsPanel.CONTENT_MARGINS, - Bottom = SettingsSection.ITEM_SPACING - }, + Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS }, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, }, diff --git a/osu.Game/Overlays/Login/LoginPanel.cs b/osu.Game/Overlays/Login/LoginPanel.cs index 885f5639a7..a84a211dfc 100644 --- a/osu.Game/Overlays/Login/LoginPanel.cs +++ b/osu.Game/Overlays/Login/LoginPanel.cs @@ -17,6 +17,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Localisation; using osu.Game.Online.API; +using osu.Game.Overlays.Settings; using osu.Game.Users; using osuTK; @@ -89,8 +90,9 @@ namespace osu.Game.Overlays.Login { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS }, Direction = FillDirection.Vertical, - Spacing = new Vector2(0f, 5f), + Spacing = new Vector2(0f, SettingsSection.ITEM_SPACING), Children = new Drawable[] { new LoadingSpinner @@ -106,7 +108,6 @@ namespace osu.Game.Overlays.Login TextAnchor = Anchor.TopCentre, AutoSizeAxes = Axes.Both, Text = state.NewValue == APIState.Failing ? ToolbarStrings.AttemptingToReconnect : ToolbarStrings.Connecting, - Margin = new MarginPadding { Top = 10, Bottom = 10 }, }, }, }; @@ -119,9 +120,9 @@ namespace osu.Game.Overlays.Login { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Left = 20, Right = 20 }, + Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS }, Direction = FillDirection.Vertical, - Spacing = new Vector2(0f, 10f), + Spacing = new Vector2(0f, SettingsSection.ITEM_SPACING), Children = new Drawable[] { new OsuSpriteText @@ -130,7 +131,6 @@ namespace osu.Game.Overlays.Login Origin = Anchor.TopCentre, Text = LoginPanelStrings.SignedIn, Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), - Margin = new MarginPadding { Top = 5, Bottom = 5 }, }, panel = new UserGridPanel(api.LocalUser.Value) { diff --git a/osu.Game/Overlays/Login/UserDropdown.cs b/osu.Game/Overlays/Login/UserDropdown.cs index 78b5271ca0..9ffaaff8bf 100644 --- a/osu.Game/Overlays/Login/UserDropdown.cs +++ b/osu.Game/Overlays/Login/UserDropdown.cs @@ -36,8 +36,6 @@ namespace osu.Game.Overlays.Login Masking = true; CornerRadius = 5; - Margin = new MarginPadding { Bottom = 5 }; - EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, @@ -86,7 +84,6 @@ namespace osu.Game.Overlays.Login public UserDropdownHeader() { Foreground.Padding = new MarginPadding { Left = 10, Right = 10 }; - Margin = new MarginPadding { Bottom = 5 }; Masking = true; CornerRadius = 5; EdgeEffect = new EdgeEffectParameters diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index b16cc5bd4b..ecf2e7a634 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -13,6 +13,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; using osu.Game.Overlays.Login; +using osu.Game.Overlays.Settings; namespace osu.Game.Overlays { @@ -63,7 +64,7 @@ namespace osu.Game.Overlays AutoSizeEasing = Easing.OutQuint, Child = panel = new LoginPanel { - Padding = new MarginPadding(10), + Padding = new MarginPadding { Vertical = SettingsSection.ITEM_SPACING }, RequestHide = Hide, }, } From ccc4d1609617e20fed35c212fd0782b7a6e43230 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 12:46:00 -0700 Subject: [PATCH 09/13] Remove most custom styling of user dropdown --- osu.Game/Overlays/Login/UserDropdown.cs | 51 +------------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/osu.Game/Overlays/Login/UserDropdown.cs b/osu.Game/Overlays/Login/UserDropdown.cs index 9ffaaff8bf..f0449d50b5 100644 --- a/osu.Game/Overlays/Login/UserDropdown.cs +++ b/osu.Game/Overlays/Login/UserDropdown.cs @@ -31,27 +31,6 @@ namespace osu.Game.Overlays.Login protected partial class UserDropdownMenu : OsuDropdownMenu { - public UserDropdownMenu() - { - Masking = true; - CornerRadius = 5; - - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.25f), - Radius = 4, - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BackgroundColour = colours.Gray3; - SelectionColour = colours.Gray4; - HoverColour = colours.Gray5; - } - protected override DrawableDropdownMenuItem CreateDrawableDropdownMenuItem(MenuItem item) => new DrawableUserDropdownMenuItem(item); private partial class DrawableUserDropdownMenuItem : DrawableOsuDropdownMenuItem @@ -60,20 +39,12 @@ namespace osu.Game.Overlays.Login : base(item) { Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 }; - CornerRadius = 5; } - - protected override Drawable CreateContent() => new Content - { - Label = { Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 } } - }; } } private partial class UserDropdownHeader : OsuDropdownHeader { - public const float LABEL_LEFT_MARGIN = 20; - private readonly StatusIcon statusIcon; public Color4 StatusColour @@ -83,19 +54,6 @@ namespace osu.Game.Overlays.Login public UserDropdownHeader() { - Foreground.Padding = new MarginPadding { Left = 10, Right = 10 }; - Masking = true; - CornerRadius = 5; - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.25f), - Radius = 4, - }; - - Icon.Size = new Vector2(14); - Icon.Margin = new MarginPadding(0); - Foreground.Add(statusIcon = new StatusIcon { Anchor = Anchor.CentreLeft, @@ -103,14 +61,7 @@ namespace osu.Game.Overlays.Login Size = new Vector2(14), }); - Text.Margin = new MarginPadding { Left = LABEL_LEFT_MARGIN }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BackgroundColour = colours.Gray3; - BackgroundColourHover = colours.Gray5; + Text.Margin = new MarginPadding { Left = 20 }; } } } From 5477ef6bfb7a253ed1bc93356c48de7ceb218bcb Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Jun 2023 12:58:51 -0700 Subject: [PATCH 10/13] Remove unused usings --- osu.Game/Overlays/Login/UserDropdown.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Overlays/Login/UserDropdown.cs b/osu.Game/Overlays/Login/UserDropdown.cs index f0449d50b5..f2a12f9a1e 100644 --- a/osu.Game/Overlays/Login/UserDropdown.cs +++ b/osu.Game/Overlays/Login/UserDropdown.cs @@ -1,12 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Users.Drawables; using osuTK; From 8d2dccbda56eb768f0255a6746fccdd56de73eec Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Jun 2023 13:19:07 +0900 Subject: [PATCH 11/13] Remove pointless zero opacity specification --- osu.Game/Overlays/LoginOverlay.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index ecf2e7a634..de37aaa291 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -4,7 +4,6 @@ #nullable disable using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; @@ -32,7 +31,7 @@ namespace osu.Game.Overlays Masking = true; EdgeEffect = new EdgeEffectParameters { - Colour = Color4.Black.Opacity(0), + Colour = Color4.Black, Type = EdgeEffectType.Shadow, Radius = 10, Hollow = true, From ac0c988d4932f4e5efe826963188b0e17a705247 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Jun 2023 13:21:29 +0900 Subject: [PATCH 12/13] Fix weirdly named test method and add xmldoc --- osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs | 2 +- osu.Game/Online/API/DummyAPIAccess.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs index 5c2edac84d..0bc71924ce 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs @@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Menus AddStep("logout", () => { API.Logout(); - ((DummyAPIAccess)API).StayConnectingNextLogin(); + ((DummyAPIAccess)API).PauseOnConnectingNextLogin(); }); AddStep("enter password", () => loginOverlay.ChildrenOfType().First().Text = "password"); diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs index c2ef0b4e92..45a4737c21 100644 --- a/osu.Game/Online/API/DummyAPIAccess.cs +++ b/osu.Game/Online/API/DummyAPIAccess.cs @@ -144,8 +144,15 @@ namespace osu.Game.Online.API IBindableList IAPIProvider.Friends => Friends; IBindable IAPIProvider.Activity => Activity; + /// + /// During the next simulated login, the process will fail immediately. + /// public void FailNextLogin() => shouldFailNextLogin = true; - public void StayConnectingNextLogin() => stayConnectingNextLogin = true; + + /// + /// During the next simulated login, the process will pause indefinitely at "connecting". + /// + public void PauseOnConnectingNextLogin() => stayConnectingNextLogin = true; protected override void Dispose(bool isDisposing) { From 1abce098b4876946690ae69c69002127a0f0b070 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Jun 2023 13:26:07 +0900 Subject: [PATCH 13/13] Apply nullability to login form related classes --- osu.Game/Online/API/DummyAPIAccess.cs | 10 ++++------ osu.Game/Overlays/Login/LoginPanel.cs | 15 +++++++-------- osu.Game/Overlays/LoginOverlay.cs | 4 +--- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs index 45a4737c21..01169828b0 100644 --- a/osu.Game/Online/API/DummyAPIAccess.cs +++ b/osu.Game/Online/API/DummyAPIAccess.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Threading; using System.Threading.Tasks; @@ -45,13 +43,13 @@ namespace osu.Game.Online.API public int APIVersion => int.Parse(DateTime.Now.ToString("yyyyMMdd")); - public Exception LastLoginError { get; private set; } + public Exception? LastLoginError { get; private set; } /// /// Provide handling logic for an arbitrary API request. /// Should return true is a request was handled. If null or false return, the request will be failed with a . /// - public Func HandleRequest; + public Func? HandleRequest; private readonly Bindable state = new Bindable(APIState.Online); @@ -128,11 +126,11 @@ namespace osu.Game.Online.API LocalUser.Value = new GuestUser(); } - public IHubClientConnector GetHubConnector(string clientName, string endpoint, bool preferMessagePack) => null; + public IHubClientConnector? GetHubConnector(string clientName, string endpoint, bool preferMessagePack) => null; public NotificationsClientConnector GetNotificationsConnector() => new PollingNotificationsClientConnector(this); - public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password) + public RegistrationRequest.RegistrationRequestErrors? CreateAccount(string email, string username, string password) { Thread.Sleep(200); return null; diff --git a/osu.Game/Overlays/Login/LoginPanel.cs b/osu.Game/Overlays/Login/LoginPanel.cs index a84a211dfc..71ecf2e75a 100644 --- a/osu.Game/Overlays/Login/LoginPanel.cs +++ b/osu.Game/Overlays/Login/LoginPanel.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -26,23 +24,24 @@ namespace osu.Game.Overlays.Login public partial class LoginPanel : Container { private bool bounding = true; - private LoginForm form; + + private LoginForm? form; [Resolved] - private OsuColour colours { get; set; } + private OsuColour colours { get; set; } = null!; - private UserGridPanel panel; - private UserDropdown dropdown; + private UserGridPanel panel = null!; + private UserDropdown dropdown = null!; /// /// Called to request a hide of a parent displaying this container. /// - public Action RequestHide; + public Action? RequestHide; private readonly IBindable apiState = new Bindable(); [Resolved] - private IAPIProvider api { get; set; } + private IAPIProvider api { get; set; } = null!; public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty; diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index de37aaa291..a575253e71 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -18,7 +16,7 @@ namespace osu.Game.Overlays { public partial class LoginOverlay : OsuFocusedOverlayContainer { - private LoginPanel panel; + private LoginPanel panel = null!; private const float transition_time = 400;