From af1c54d995f10429fff030f1393511a95304fc28 Mon Sep 17 00:00:00 2001 From: jorolf Date: Fri, 8 Mar 2019 23:44:01 +0100 Subject: [PATCH 01/12] add ScreenTitle class --- .../Graphics/UserInterface/ScreenTitle.cs | 73 +++++++++++++++++++ osu.Game/Screens/Multi/Header.cs | 41 ++--------- 2 files changed, 79 insertions(+), 35 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/ScreenTitle.cs diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs new file mode 100644 index 0000000000..d931d2561a --- /dev/null +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -0,0 +1,73 @@ +// 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.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Graphics.UserInterface +{ + public class ScreenTitle : CompositeDrawable, IHasAccentColour + { + private readonly SpriteIcon iconSprite; + private readonly OsuSpriteText titleText, pageText; + + public FontAwesome Icon + { + get => iconSprite.Icon; + set => iconSprite.Icon = value; + } + + public string Title + { + get => titleText.Text; + set => titleText.Text = value; + } + + public string Page + { + get => pageText.Text; + set => pageText.Text = value; + } + + public Color4 AccentColour + { + get => pageText.Colour; + set => pageText.Colour = value; + } + + public ScreenTitle() + { + AutoSizeAxes = Axes.Both; + + InternalChildren = new Drawable[] + { + iconSprite = new SpriteIcon + { + Size = new Vector2(25), + Anchor = Anchor.TopLeft, + Origin = Anchor.TopRight, + Margin = new MarginPadding { Right = 10 }, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + titleText = new OsuSpriteText + { + Font = OsuFont.GetFont(size: 25), + }, + pageText = new OsuSpriteText + { + Font = OsuFont.GetFont(size: 25), + } + } + } + }; + } + } +} diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index 0e958bf523..668b2f5995 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -7,10 +7,8 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Screens; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.SearchableList; -using osuTK; using osuTK.Graphics; namespace osu.Game.Screens.Multi @@ -19,7 +17,7 @@ public class Header : Container { public const float HEIGHT = 121; - private readonly OsuSpriteText screenType; + private readonly ScreenTitle title; private readonly HeaderBreadcrumbControl breadcrumbs; public Header(ScreenStack stack) @@ -40,39 +38,12 @@ public Header(ScreenStack stack) Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING }, Children = new Drawable[] { - new FillFlowContainer + title = new ScreenTitle { Anchor = Anchor.CentreLeft, Origin = Anchor.BottomLeft, - Position = new Vector2(-35f, 5f), - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(10f, 0f), - Children = new Drawable[] - { - new SpriteIcon - { - Size = new Vector2(25), - Icon = FontAwesome.fa_osu_multi, - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - new OsuSpriteText - { - Text = "multiplayer ", - Font = OsuFont.GetFont(size: 25) - }, - screenType = new OsuSpriteText - { - Font = OsuFont.GetFont(weight: FontWeight.Light, size: 25) - }, - }, - }, - }, + Icon = FontAwesome.fa_osu_multi, + Title = "multiplayer ", }, breadcrumbs = new HeaderBreadcrumbControl(stack) { @@ -87,7 +58,7 @@ public Header(ScreenStack stack) breadcrumbs.Current.ValueChanged += scren => { if (scren.NewValue is IMultiplayerSubScreen multiScreen) - screenType.Text = multiScreen.ShortTitle.ToLowerInvariant(); + title.Page = multiScreen.ShortTitle.ToLowerInvariant(); }; breadcrumbs.Current.TriggerChange(); @@ -96,7 +67,7 @@ public Header(ScreenStack stack) [BackgroundDependencyLoader] private void load(OsuColour colours) { - screenType.Colour = colours.Yellow; + title.AccentColour = colours.Yellow; breadcrumbs.StripColour = colours.Green; } From f3ab5070b97e1845c8af1a7270f30058f081c790 Mon Sep 17 00:00:00 2001 From: jorolf Date: Mon, 11 Mar 2019 18:37:36 +0100 Subject: [PATCH 02/12] apply suggestions --- .../Graphics/UserInterface/ScreenTitle.cs | 3 ++- osu.Game/Screens/Multi/Header.cs | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs index d931d2561a..d7cba06d9d 100644 --- a/osu.Game/Graphics/UserInterface/ScreenTitle.cs +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -26,7 +26,7 @@ public string Title set => titleText.Text = value; } - public string Page + public string Section { get => pageText.Text; set => pageText.Text = value; @@ -55,6 +55,7 @@ public ScreenTitle() { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, + Spacing = new Vector2(6, 0), Children = new[] { titleText = new OsuSpriteText diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index 668b2f5995..bb4acc6007 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -17,11 +17,11 @@ public class Header : Container { public const float HEIGHT = 121; - private readonly ScreenTitle title; private readonly HeaderBreadcrumbControl breadcrumbs; public Header(ScreenStack stack) { + ScreenTitle title; RelativeSizeAxes = Axes.X; Height = HEIGHT; @@ -38,12 +38,12 @@ public Header(ScreenStack stack) Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING }, Children = new Drawable[] { - title = new ScreenTitle + title = new MultiHeaderTitle { Anchor = Anchor.CentreLeft, Origin = Anchor.BottomLeft, Icon = FontAwesome.fa_osu_multi, - Title = "multiplayer ", + Title = "multiplayer", }, breadcrumbs = new HeaderBreadcrumbControl(stack) { @@ -55,10 +55,10 @@ public Header(ScreenStack stack) }, }; - breadcrumbs.Current.ValueChanged += scren => + breadcrumbs.Current.ValueChanged += screen => { - if (scren.NewValue is IMultiplayerSubScreen multiScreen) - title.Page = multiScreen.ShortTitle.ToLowerInvariant(); + if (screen.NewValue is IMultiplayerSubScreen multiScreen) + title.Section = multiScreen.ShortTitle.ToLowerInvariant(); }; breadcrumbs.Current.TriggerChange(); @@ -67,10 +67,18 @@ public Header(ScreenStack stack) [BackgroundDependencyLoader] private void load(OsuColour colours) { - title.AccentColour = colours.Yellow; breadcrumbs.StripColour = colours.Green; } + private class MultiHeaderTitle : ScreenTitle + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AccentColour = colours.Yellow; + } + } + private class HeaderBreadcrumbControl : ScreenBreadcrumbControl { public HeaderBreadcrumbControl(ScreenStack stack) From f91e4a1fdd0783976594915228b5f9bc49c48d4e Mon Sep 17 00:00:00 2001 From: jorolf Date: Mon, 11 Mar 2019 19:10:37 +0100 Subject: [PATCH 03/12] make ScreenTitle abstract and properties protected --- osu.Game/Graphics/UserInterface/ScreenTitle.cs | 10 +++++----- osu.Game/Screens/Multi/Header.cs | 13 +++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs index d7cba06d9d..14c87bb59d 100644 --- a/osu.Game/Graphics/UserInterface/ScreenTitle.cs +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -9,24 +9,24 @@ namespace osu.Game.Graphics.UserInterface { - public class ScreenTitle : CompositeDrawable, IHasAccentColour + public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour { private readonly SpriteIcon iconSprite; private readonly OsuSpriteText titleText, pageText; - public FontAwesome Icon + protected FontAwesome Icon { get => iconSprite.Icon; set => iconSprite.Icon = value; } - public string Title + protected string Title { get => titleText.Text; set => titleText.Text = value; } - public string Section + protected string Section { get => pageText.Text; set => pageText.Text = value; @@ -38,7 +38,7 @@ public Color4 AccentColour set => pageText.Colour = value; } - public ScreenTitle() + protected ScreenTitle() { AutoSizeAxes = Axes.Both; diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index bb4acc6007..0f945d107f 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -21,7 +21,7 @@ public class Header : Container public Header(ScreenStack stack) { - ScreenTitle title; + MultiHeaderTitle title; RelativeSizeAxes = Axes.X; Height = HEIGHT; @@ -42,8 +42,6 @@ public Header(ScreenStack stack) { Anchor = Anchor.CentreLeft, Origin = Anchor.BottomLeft, - Icon = FontAwesome.fa_osu_multi, - Title = "multiplayer", }, breadcrumbs = new HeaderBreadcrumbControl(stack) { @@ -58,7 +56,7 @@ public Header(ScreenStack stack) breadcrumbs.Current.ValueChanged += screen => { if (screen.NewValue is IMultiplayerSubScreen multiScreen) - title.Section = multiScreen.ShortTitle.ToLowerInvariant(); + title.Screen = multiScreen; }; breadcrumbs.Current.TriggerChange(); @@ -72,9 +70,16 @@ private void load(OsuColour colours) private class MultiHeaderTitle : ScreenTitle { + public IMultiplayerSubScreen Screen + { + set => Section = value.ShortTitle.ToLowerInvariant(); + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { + Title = "multiplayer"; + Icon = FontAwesome.fa_osu_multi; AccentColour = colours.Yellow; } } From 454c82c49eb77c228f50c60182ae87b24ec819b2 Mon Sep 17 00:00:00 2001 From: jorolf Date: Thu, 21 Mar 2019 22:18:45 +0100 Subject: [PATCH 04/12] Don't go outside of the container bounds --- .../Graphics/UserInterface/ScreenTitle.cs | 35 +++++++++++-------- osu.Game/Screens/Multi/Header.cs | 1 + 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs index 14c87bb59d..dd0b06f969 100644 --- a/osu.Game/Graphics/UserInterface/ScreenTitle.cs +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -44,30 +44,35 @@ protected ScreenTitle() InternalChildren = new Drawable[] { - iconSprite = new SpriteIcon - { - Size = new Vector2(25), - Anchor = Anchor.TopLeft, - Origin = Anchor.TopRight, - Margin = new MarginPadding { Right = 10 }, - }, new FillFlowContainer { AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(6, 0), - Children = new[] + Spacing = new Vector2(10, 0), + Children = new Drawable[] { - titleText = new OsuSpriteText + iconSprite = new SpriteIcon { - Font = OsuFont.GetFont(size: 25), + Size = new Vector2(25), }, - pageText = new OsuSpriteText + new FillFlowContainer { - Font = OsuFont.GetFont(size: 25), + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(6, 0), + Children = new[] + { + titleText = new OsuSpriteText + { + Font = OsuFont.GetFont(size: 25), + }, + pageText = new OsuSpriteText + { + Font = OsuFont.GetFont(size: 25), + } + } } } - } + }, }; } } diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index 0f945d107f..3b9bd7ca4a 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -42,6 +42,7 @@ public Header(ScreenStack stack) { Anchor = Anchor.CentreLeft, Origin = Anchor.BottomLeft, + X = -35, }, breadcrumbs = new HeaderBreadcrumbControl(stack) { From 53f3dacdfbae40f4cb5e17c6bc64ede440ae8d05 Mon Sep 17 00:00:00 2001 From: Joehu Date: Wed, 27 Mar 2019 22:01:06 -0700 Subject: [PATCH 05/12] Fix login overlay behavior --- osu.Game/OsuGame.cs | 11 +++++ osu.Game/Overlays/LoginOverlay.cs | 14 +++++++ osu.Game/Overlays/Toolbar/Toolbar.cs | 6 +-- osu.Game/Overlays/Toolbar/ToolbarUserArea.cs | 42 ------------------- .../Overlays/Toolbar/ToolbarUserButton.cs | 8 ++-- 5 files changed, 33 insertions(+), 48 deletions(-) delete mode 100644 osu.Game/Overlays/Toolbar/ToolbarUserArea.cs diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7ab4494a69..7ea300347b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -62,6 +62,8 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler private NotificationOverlay notifications; + public LoginOverlay loginOverlay; + private DialogOverlay dialogOverlay; private AccountCreationOverlay accountCreation; @@ -446,6 +448,14 @@ protected override void LoadComplete() Origin = Anchor.TopRight, }, floatingOverlayContent.Add); + loadComponentSingleFile(loginOverlay = new LoginOverlay + { + GetToolbarHeight = () => ToolbarOffset, + Position = new Vector2(-ToolbarButton.WIDTH, 0), + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }, floatingOverlayContent.Add); + loadComponentSingleFile(accountCreation = new AccountCreationOverlay(), topMostOverlayContent.Add); loadComponentSingleFile(dialogOverlay = new DialogOverlay(), topMostOverlayContent.Add); @@ -463,6 +473,7 @@ protected override void LoadComplete() dependencies.Cache(musicController); dependencies.Cache(beatmapSetOverlay); dependencies.Cache(notifications); + dependencies.Cache(loginOverlay); dependencies.Cache(dialogOverlay); dependencies.Cache(accountCreation); diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index e7caaa3aca..5890c89f89 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; +using System; namespace osu.Game.Overlays { @@ -19,6 +20,11 @@ public class LoginOverlay : OsuFocusedOverlayContainer private const float transition_time = 400; + /// + /// Provide a source for the toolbar height. + /// + public Func GetToolbarHeight; + public LoginOverlay() { AutoSizeAxes = Axes.Both; @@ -88,5 +94,13 @@ protected override void PopOut() settingsSection.Bounding = false; this.FadeOut(transition_time); } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 }; + } + } } diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index dca0226499..2f435a778d 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -22,7 +22,7 @@ public class Toolbar : OverlayContainer public Action OnHome; - private ToolbarUserArea userArea; + private ToolbarUserButton userButton; protected override bool BlockPositionalInput => false; @@ -77,7 +77,7 @@ private void load(OsuGame osuGame) //{ // Icon = FontAwesome.fa_search //}, - userArea = new ToolbarUserArea(), + userButton = new ToolbarUserButton(), new ToolbarNotificationButton(), } } @@ -143,7 +143,7 @@ protected override void PopIn() protected override void PopOut() { - userArea?.LoginOverlay.Hide(); + userButton?.StateContainer.Hide(); this.MoveToY(-DrawSize.Y, transition_time, Easing.OutQuint); this.FadeOut(transition_time); diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs deleted file mode 100644 index f9cf5d4350..0000000000 --- a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs +++ /dev/null @@ -1,42 +0,0 @@ -// 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.Graphics; -using osu.Framework.Graphics.Containers; -using osuTK; -using RectangleF = osu.Framework.Graphics.Primitives.RectangleF; - -namespace osu.Game.Overlays.Toolbar -{ - public class ToolbarUserArea : Container - { - public LoginOverlay LoginOverlay; - private ToolbarUserButton button; - - public override RectangleF BoundingBox => button.BoundingBox; - - [BackgroundDependencyLoader] - private void load() - { - RelativeSizeAxes = Axes.Y; - AutoSizeAxes = Axes.X; - - Children = new Drawable[] - { - button = new ToolbarUserButton - { - Action = () => LoginOverlay.ToggleVisibility(), - }, - LoginOverlay = new LoginOverlay - { - BypassAutoSizeAxes = Axes.Both, - Position = new Vector2(0, 1), - RelativePositionAxes = Axes.Y, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - } - }; - } - } -} diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index 8d1910fc19..356ffa5180 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar { - public class ToolbarUserButton : ToolbarButton, IOnlineComponent + public class ToolbarUserButton : ToolbarOverlayToggleButton, IOnlineComponent { private readonly UpdateableAvatar avatar; @@ -42,10 +42,12 @@ public ToolbarUserButton() }); } - [BackgroundDependencyLoader] - private void load(IAPIProvider api) + [BackgroundDependencyLoader(true)] + private void load(IAPIProvider api, LoginOverlay login) { api.Register(this); + + StateContainer = login; } public void APIStateChanged(IAPIProvider api, APIState state) From 2254c572c40a2d99aa68de1662109bdccad3f6f7 Mon Sep 17 00:00:00 2001 From: Joehu Date: Wed, 27 Mar 2019 22:21:28 -0700 Subject: [PATCH 06/12] Remove unnecessary newline --- osu.Game/Overlays/LoginOverlay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 5890c89f89..d0411ba9e7 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -101,6 +101,5 @@ protected override void UpdateAfterChildren() Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 }; } - } } From 9a3528ea9d527edfe239706dc7e0478abd395b7c Mon Sep 17 00:00:00 2001 From: Joehu Date: Wed, 27 Mar 2019 22:31:40 -0700 Subject: [PATCH 07/12] Fix field modifier --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7ea300347b..db796a4ca1 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -62,7 +62,7 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler private NotificationOverlay notifications; - public LoginOverlay loginOverlay; + private LoginOverlay loginOverlay; private DialogOverlay dialogOverlay; From 3e28c4ae0acb1777ad0d36c483456fe3c8b4bcdf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2019 14:03:00 +0900 Subject: [PATCH 08/12] Fix remaining IconUsage changes --- osu.Game/Graphics/UserInterface/ScreenTitle.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs index dd0b06f969..1574023068 100644 --- a/osu.Game/Graphics/UserInterface/ScreenTitle.cs +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Sprites; using osuTK; using osuTK.Graphics; @@ -14,7 +15,7 @@ public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour private readonly SpriteIcon iconSprite; private readonly OsuSpriteText titleText, pageText; - protected FontAwesome Icon + protected IconUsage Icon { get => iconSprite.Icon; set => iconSprite.Icon = value; From cabec85544de138ac493dd00bd447e67956cdb59 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 29 Mar 2019 14:15:57 +0900 Subject: [PATCH 09/12] Rework TestCaseLoaderAnimation to avoid timing issues --- .../Visual/Menus/TestCaseLoaderAnimation.cs | 87 +++++++++++-------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs b/osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs index 1686436924..df12e14891 100644 --- a/osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs +++ b/osu.Game.Tests/Visual/Menus/TestCaseLoaderAnimation.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Threading; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -22,55 +23,76 @@ public class TestCaseLoaderAnimation : ScreenTestCase public TestCaseLoaderAnimation() { - Add(logo = new OsuLogo { Depth = float.MinValue }); + Child = logo = new OsuLogo { Depth = float.MinValue }; } - protected override void LoadComplete() + [Test] + public void TestInstantLoad() { - base.LoadComplete(); - bool logoVisible = false; - AddStep("almost instant display", () => LoadScreen(loader = new TestLoader(250))); - AddUntilStep("loaded", () => - { - logoVisible = loader.Logo?.Alpha > 0; - return loader.Logo != null && loader.ScreenLoaded; - }); - AddAssert("logo not visible", () => !logoVisible); - AddStep("short load", () => LoadScreen(loader = new TestLoader(800))); - AddUntilStep("loaded", () => + AddStep("begin loading", () => + { + loader = new TestLoader(); + loader.AllowLoad.Set(); + + LoadScreen(loader); + }); + + AddAssert("loaded", () => { logoVisible = loader.Logo?.Alpha > 0; return loader.Logo != null && loader.ScreenLoaded; }); - AddAssert("logo visible", () => logoVisible); + + AddAssert("logo was not visible", () => !logoVisible); + } + + [Test] + public void TestShortLoad() + { + bool logoVisible = false; + + AddStep("begin loading", () => LoadScreen(loader = new TestLoader())); + AddWaitStep("wait", 2); + AddStep("finish loading", () => + { + logoVisible = loader.Logo?.Alpha > 0; + loader.AllowLoad.Set(); + }); + + AddAssert("loaded", () => loader.Logo != null && loader.ScreenLoaded); + AddAssert("logo was visible", () => logoVisible); AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0); + } - AddStep("longer load", () => LoadScreen(loader = new TestLoader(1400))); - AddUntilStep("loaded", () => + [Test] + public void TestLongLoad() + { + bool logoVisible = false; + + AddStep("begin loading", () => LoadScreen(loader = new TestLoader())); + AddWaitStep("wait", 10); + AddStep("finish loading", () => { logoVisible = loader.Logo?.Alpha > 0; - return loader.Logo != null && loader.ScreenLoaded; + loader.AllowLoad.Set(); }); - AddAssert("logo visible", () => logoVisible); + + AddAssert("loaded", () => loader.Logo != null && loader.ScreenLoaded); + AddAssert("logo was visible", () => logoVisible); AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0); } private class TestLoader : Loader { - private readonly double delay; + public readonly ManualResetEventSlim AllowLoad = new ManualResetEventSlim(); public OsuLogo Logo; private TestScreen screen; public bool ScreenLoaded => screen.IsCurrentScreen(); - public TestLoader(double delay) - { - this.delay = delay; - } - protected override void LogoArriving(OsuLogo logo, bool resuming) { Logo = logo; @@ -78,25 +100,18 @@ protected override void LogoArriving(OsuLogo logo, bool resuming) } protected override OsuScreen CreateLoadableScreen() => screen = new TestScreen(); - protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler(delay); + protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler(AllowLoad); private class TestShaderPrecompiler : ShaderPrecompiler { - private readonly double delay; - private double startTime; + private readonly ManualResetEventSlim allowLoad; - public TestShaderPrecompiler(double delay) + public TestShaderPrecompiler(ManualResetEventSlim allowLoad) { - this.delay = delay; + this.allowLoad = allowLoad; } - protected override void LoadComplete() - { - base.LoadComplete(); - startTime = Time.Current; - } - - protected override bool AllLoaded => Time.Current > startTime + delay; + protected override bool AllLoaded => allowLoad.IsSet; } private class TestScreen : OsuScreen From 5495a0a70fd1c2320c801a0e9ba6c72e6f64f7a0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2019 14:34:58 +0900 Subject: [PATCH 10/12] Add content to ScreenTestCase as protection against overwriting --- osu.Game/Tests/Visual/ScreenTestCase.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game/Tests/Visual/ScreenTestCase.cs b/osu.Game/Tests/Visual/ScreenTestCase.cs index d10779349b..4fd4c7c207 100644 --- a/osu.Game/Tests/Visual/ScreenTestCase.cs +++ b/osu.Game/Tests/Visual/ScreenTestCase.cs @@ -1,8 +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.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Screens; namespace osu.Game.Tests.Visual @@ -12,12 +12,19 @@ namespace osu.Game.Tests.Visual /// public abstract class ScreenTestCase : ManualInputManagerTestCase { - private OsuScreenStack stack; + private readonly OsuScreenStack stack; - [BackgroundDependencyLoader] - private void load() + private readonly Container content; + + protected override Container Content => content; + + protected ScreenTestCase() { - Add(stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }); + base.Content.AddRange(new Drawable[] + { + stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }, + content = new Container { RelativeSizeAxes = Axes.Both } + }); } protected void LoadScreen(OsuScreen screen) From 90a4cb8e0441b37ee7458ff535ce82e46835aac3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2019 14:49:15 +0900 Subject: [PATCH 11/12] Fix unnecessary positioning --- osu.Game/OsuGame.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index bd92ad951d..f099f0946a 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -451,7 +451,6 @@ protected override void LoadComplete() loadComponentSingleFile(loginOverlay = new LoginOverlay { GetToolbarHeight = () => ToolbarOffset, - Position = new Vector2(-ToolbarButton.WIDTH, 0), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, floatingOverlayContent.Add); From ccc0853f75a4212297b724f3a7a120353467bf1b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2019 14:53:40 +0900 Subject: [PATCH 12/12] Change login overlay's depth and load order --- osu.Game/OsuGame.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f099f0946a..e470d554c9 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -424,6 +424,13 @@ protected override void LoadComplete() loadComponentSingleFile(volume = new VolumeOverlay(), floatingOverlayContent.Add); loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add); + loadComponentSingleFile(loginOverlay = new LoginOverlay + { + GetToolbarHeight = () => ToolbarOffset, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }, floatingOverlayContent.Add); + loadComponentSingleFile(screenshotManager, Add); //overlay elements @@ -434,6 +441,7 @@ protected override void LoadComplete() loadComponentSingleFile(settings = new MainSettings { GetToolbarHeight = () => ToolbarOffset }, floatingOverlayContent.Add); loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add); + loadComponentSingleFile(notifications = new NotificationOverlay { GetToolbarHeight = () => ToolbarOffset, @@ -448,13 +456,6 @@ protected override void LoadComplete() Origin = Anchor.TopRight, }, floatingOverlayContent.Add); - loadComponentSingleFile(loginOverlay = new LoginOverlay - { - GetToolbarHeight = () => ToolbarOffset, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - }, floatingOverlayContent.Add); - loadComponentSingleFile(accountCreation = new AccountCreationOverlay(), topMostOverlayContent.Add); loadComponentSingleFile(dialogOverlay = new DialogOverlay(), topMostOverlayContent.Add);