From a677aa6cfc5212223175d40f34279cb3573c78ae Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 13 Feb 2020 13:39:33 +0300 Subject: [PATCH 01/18] Add rankings overlay to the game --- osu.Game/OsuGame.cs | 5 ++++- osu.Game/Overlays/Toolbar/Toolbar.cs | 1 + .../Overlays/Toolbar/ToolbarRankingsButton.cs | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Overlays/Toolbar/ToolbarRankingsButton.cs diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index e7fffd49b4..e034fcc3ac 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -65,6 +65,8 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler private DirectOverlay direct; + private RankingsOverlay rankings; + private SocialOverlay social; private UserProfileOverlay userProfile; @@ -600,6 +602,7 @@ protected override void LoadComplete() //overlay elements loadComponentSingleFile(direct = new DirectOverlay(), overlayContent.Add, true); loadComponentSingleFile(social = new SocialOverlay(), overlayContent.Add, true); + loadComponentSingleFile(rankings = new RankingsOverlay(), overlayContent.Add, true); loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true); loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true); loadComponentSingleFile(Settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true); @@ -643,7 +646,7 @@ protected override void LoadComplete() } // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. - var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; + var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile, rankings }; foreach (var overlay in informationalOverlays) { diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index b044bc4de0..897587d198 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -70,6 +70,7 @@ private void load(OsuGame osuGame, Bindable parentRuleset) Children = new Drawable[] { new ToolbarChangelogButton(), + new ToolbarRankingsButton(), new ToolbarDirectButton(), new ToolbarChatButton(), new ToolbarSocialButton(), diff --git a/osu.Game/Overlays/Toolbar/ToolbarRankingsButton.cs b/osu.Game/Overlays/Toolbar/ToolbarRankingsButton.cs new file mode 100644 index 0000000000..cbd097696d --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarRankingsButton.cs @@ -0,0 +1,22 @@ +// 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.Sprites; + +namespace osu.Game.Overlays.Toolbar +{ + public class ToolbarRankingsButton : ToolbarOverlayToggleButton + { + public ToolbarRankingsButton() + { + SetIcon(FontAwesome.Regular.ChartBar); + } + + [BackgroundDependencyLoader(true)] + private void load(RankingsOverlay rankings) + { + StateContainer = rankings; + } + } +} From f05c1de4c10a68c910ae7435f2a04a288cebf250 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 13 Feb 2020 14:11:53 +0300 Subject: [PATCH 02/18] Fix possible nullref --- osu.Game/Overlays/RankingsOverlay.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index f3215d07fa..69ca687871 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -135,6 +135,9 @@ public void ShowCountry(Country requested) private void loadNewContent() { + if (ruleset.Value == null) + return; + loading.Show(); cancellationToken?.Cancel(); From 11c59a141f24aebf68f21fb7d79f88980b1233f1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 13 Feb 2020 14:12:10 +0300 Subject: [PATCH 03/18] Add background to rankings header --- osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs index 2674b3a81e..72d5b6462d 100644 --- a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs +++ b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs @@ -29,6 +29,8 @@ public class RankingsOverlayHeader : TabControlOverlayHeader Current = Country }; + protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/rankings"); + private class RankingsTitle : ScreenTitle { public readonly Bindable Scope = new Bindable(); From 382cc1a91ba24fa00e89e641e5f86ff517d2e34e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 13 Feb 2020 14:26:35 +0300 Subject: [PATCH 04/18] Fix incorrect overlays overlapping --- osu.Game/OsuGame.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index e034fcc3ac..c31f15716b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -65,8 +65,6 @@ public class OsuGame : OsuGameBase, IKeyBindingHandler private DirectOverlay direct; - private RankingsOverlay rankings; - private SocialOverlay social; private UserProfileOverlay userProfile; @@ -602,7 +600,7 @@ protected override void LoadComplete() //overlay elements loadComponentSingleFile(direct = new DirectOverlay(), overlayContent.Add, true); loadComponentSingleFile(social = new SocialOverlay(), overlayContent.Add, true); - loadComponentSingleFile(rankings = new RankingsOverlay(), overlayContent.Add, true); + var rankingsOverlay = loadComponentSingleFile(new RankingsOverlay(), overlayContent.Add, true); loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true); loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true); loadComponentSingleFile(Settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true); @@ -646,7 +644,7 @@ protected override void LoadComplete() } // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. - var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile, rankings }; + var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; foreach (var overlay in informationalOverlays) { @@ -659,7 +657,7 @@ protected override void LoadComplete() } // ensure only one of these overlays are open at once. - var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct, changelogOverlay }; + var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct, changelogOverlay, rankingsOverlay }; foreach (var overlay in singleDisplayOverlays) { From ab84f4085a83d8f8d597ddaa3e3aca8955d8c76a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 13 Feb 2020 23:20:45 +0300 Subject: [PATCH 05/18] Fix possible error on SpotlightsLayout disposal --- osu.Game/Overlays/Rankings/SpotlightsLayout.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs index 33811cc982..cb409a2135 100644 --- a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs +++ b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs @@ -151,11 +151,11 @@ private void onSuccess(GetSpotlightRankingsResponse response) protected override void Dispose(bool isDisposing) { - base.Dispose(isDisposing); - spotlightsRequest?.Cancel(); getRankingsRequest?.Cancel(); cancellationToken?.Cancel(); + + base.Dispose(isDisposing); } } } From 146758862a479ec189261b810a4d3942c5bf6de6 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 19 Feb 2020 16:25:06 +0300 Subject: [PATCH 06/18] Remove no longer needed null check --- osu.Game/Overlays/RankingsOverlay.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 81cafef2c1..2c5ea61315 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -135,9 +135,6 @@ public void ShowCountry(Country requested) private void loadNewContent() { - if (ruleset.Value == null) - return; - loading.Show(); cancellationToken?.Cancel(); From 378aaf82c1a50d10a439424805dc5b61496d4c45 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 19 Feb 2020 16:32:54 +0300 Subject: [PATCH 07/18] Fix error when first Show call has been triggered by ShowCountry --- osu.Game/Overlays/RankingsOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 2c5ea61315..404f896cad 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -130,7 +130,7 @@ public void ShowCountry(Country requested) Show(); - Country.Value = requested; + Schedule(() => Country.Value = requested); } private void loadNewContent() From 623b78d67533f915dfc520b50ab2cc8a871fd74a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 15:31:40 +0900 Subject: [PATCH 08/18] Combine all loading animation implementations --- .../Visual/Online/TestSceneRankingsTables.cs | 6 +- .../Visual/Online/TestSceneUserRequest.cs | 9 +- ...ingOverlay.cs => TestSceneLoadingLayer.cs} | 10 +- .../UserInterface/DimmedLoadingLayer.cs | 58 ------------ .../UserInterface/LoadingAnimation.cs | 92 ++++++++++++++----- .../Graphics/UserInterface/LoadingLayer.cs | 74 +++++++++++++++ .../UserInterface/ProcessingOverlay.cs | 88 ------------------ .../Overlays/AccountCreation/ScreenEntry.cs | 10 +- .../BeatmapSet/Buttons/FavouriteButton.cs | 8 +- .../BeatmapSet/Scores/ScoresContainer.cs | 15 +-- .../Overlays/Rankings/SpotlightsLayout.cs | 4 +- osu.Game/Overlays/RankingsOverlay.cs | 6 +- .../Screens/Multi/Lounge/LoungeSubScreen.cs | 10 +- .../Match/Components/MatchSettingsOverlay.cs | 10 +- osu.Game/Screens/Select/BeatmapDetails.cs | 10 +- 15 files changed, 185 insertions(+), 225 deletions(-) rename osu.Game.Tests/Visual/UserInterface/{TestSceneProcessingOverlay.cs => TestSceneLoadingLayer.cs} (90%) delete mode 100644 osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs create mode 100644 osu.Game/Graphics/UserInterface/LoadingLayer.cs delete mode 100644 osu.Game/Graphics/UserInterface/ProcessingOverlay.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs index 656402e713..8542a5e46e 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics; using osu.Game.Online.API.Requests; using osu.Game.Rulesets; -using osu.Game.Graphics.UserInterface; using System.Threading; using osu.Game.Online.API; using osu.Game.Rulesets.Osu; @@ -16,6 +15,7 @@ using osu.Game.Rulesets.Taiko; using osu.Game.Rulesets.Catch; using osu.Framework.Allocation; +using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; namespace osu.Game.Tests.Visual.Online @@ -41,7 +41,7 @@ public class TestSceneRankingsTables : OsuTestScene private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green); private readonly BasicScrollContainer scrollFlow; - private readonly DimmedLoadingLayer loading; + private readonly LoadingLayer loading; private CancellationTokenSource cancellationToken; private APIRequest request; @@ -56,7 +56,7 @@ public TestSceneRankingsTables() RelativeSizeAxes = Axes.Both, Width = 0.8f, }, - loading = new DimmedLoadingLayer(), + loading = new LoadingLayer(), }; } diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs b/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs index 0f41247571..15cfd3ee54 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs @@ -12,8 +12,8 @@ using osu.Game.Users; using osu.Framework.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Rulesets.Taiko; using osu.Game.Graphics.UserInterface; +using osu.Game.Rulesets.Taiko; namespace osu.Game.Tests.Visual.Online { @@ -25,7 +25,7 @@ public class TestSceneUserRequest : OsuTestScene private readonly Bindable user = new Bindable(); private GetUserRequest request; - private readonly DimmedLoadingLayer loading; + private readonly LoadingLayer loading; public TestSceneUserRequest() { @@ -40,10 +40,7 @@ public TestSceneUserRequest() { User = { BindTarget = user } }, - loading = new DimmedLoadingLayer - { - Alpha = 0 - } + loading = new LoadingLayer() } }); } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneProcessingOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs similarity index 90% rename from osu.Game.Tests/Visual/UserInterface/TestSceneProcessingOverlay.cs rename to osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs index 2424078e5a..0f49835742 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneProcessingOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs @@ -1,6 +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 System; +using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -12,10 +14,12 @@ namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneProcessingOverlay : OsuTestScene + public class TestSceneLoadingLayer : OsuTestScene { private Drawable dimContent; - private ProcessingOverlay overlay; + private LoadingLayer overlay; + + public override IReadOnlyList RequiredTypes => new[] { typeof(LoadingAnimation) }; [SetUp] public void SetUp() => Schedule(() => @@ -49,7 +53,7 @@ public void SetUp() => Schedule(() => new TriangleButton { Text = "puush me", Width = 200, Action = () => { } }, } }, - overlay = new ProcessingOverlay(dimContent), + overlay = new LoadingLayer(dimContent), } }, }; diff --git a/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs b/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs deleted file mode 100644 index bdc3cd4c49..0000000000 --- a/osu.Game/Graphics/UserInterface/DimmedLoadingLayer.cs +++ /dev/null @@ -1,58 +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 osuTK.Graphics; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Extensions.Color4Extensions; -using osuTK; -using osu.Framework.Input.Events; - -namespace osu.Game.Graphics.UserInterface -{ - public class DimmedLoadingLayer : OverlayContainer - { - private const float transition_duration = 250; - - private readonly LoadingAnimation loading; - - public DimmedLoadingLayer(float dimAmount = 0.5f, float iconScale = 1f) - { - RelativeSizeAxes = Axes.Both; - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(dimAmount), - }, - loading = new LoadingAnimation { Scale = new Vector2(iconScale) }, - }; - } - - protected override void PopIn() - { - this.FadeIn(transition_duration, Easing.OutQuint); - loading.Show(); - } - - protected override void PopOut() - { - this.FadeOut(transition_duration, Easing.OutQuint); - loading.Hide(); - } - - protected override bool Handle(UIEvent e) - { - switch (e) - { - // blocking scroll can cause weird behaviour when this layer is used within a ScrollContainer. - case ScrollEvent _: - return false; - } - - return base.Handle(e); - } - } -} diff --git a/osu.Game/Graphics/UserInterface/LoadingAnimation.cs b/osu.Game/Graphics/UserInterface/LoadingAnimation.cs index 5a8a0da135..265c93bce3 100644 --- a/osu.Game/Graphics/UserInterface/LoadingAnimation.cs +++ b/osu.Game/Graphics/UserInterface/LoadingAnimation.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osuTK; using osuTK.Graphics; @@ -15,36 +16,47 @@ namespace osu.Game.Graphics.UserInterface public class LoadingAnimation : VisibilityContainer { private readonly SpriteIcon spinner; - private readonly SpriteIcon spinnerShadow; - private const float spin_duration = 600; - private const float transition_duration = 200; + protected Container MainContents; - public LoadingAnimation() + protected const float TRANSITION_DURATION = 500; + + private const float spin_duration = 900; + + /// + /// Constuct a new loading spinner. + /// + /// + public LoadingAnimation(bool withBox = false) { - Size = new Vector2(20); + Size = new Vector2(60); Anchor = Anchor.Centre; Origin = Anchor.Centre; - Children = new Drawable[] + Child = MainContents = new Container { - spinnerShadow = new SpriteIcon + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = 20, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Position = new Vector2(1, 1), - Colour = Color4.Black, - Alpha = 0.4f, - Icon = FontAwesome.Solid.CircleNotch - }, - spinner = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Icon = FontAwesome.Solid.CircleNotch + new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + Alpha = withBox ? 0.7f : 0 + }, + spinner = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(withBox ? 0.6f : 1), + RelativeSizeAxes = Axes.Both, + Icon = FontAwesome.Solid.CircleNotch + } } }; } @@ -53,12 +65,42 @@ protected override void LoadComplete() { base.LoadComplete(); - spinner.Spin(spin_duration, RotationDirection.Clockwise); - spinnerShadow.Spin(spin_duration, RotationDirection.Clockwise); + rotate(); } - protected override void PopIn() => this.FadeIn(transition_duration * 2, Easing.OutQuint); + protected override void Update() + { + base.Update(); - protected override void PopOut() => this.FadeOut(transition_duration, Easing.OutQuint); + MainContents.CornerRadius = MainContents.DrawWidth / 4; + } + + protected override void PopIn() + { + if (Alpha < 0.5f) + // reset animation if the user can't see us. + rotate(); + + MainContents.ScaleTo(1, TRANSITION_DURATION, Easing.OutQuint); + this.FadeIn(TRANSITION_DURATION * 2, Easing.OutQuint); + } + + protected override void PopOut() + { + MainContents.ScaleTo(0.8f, TRANSITION_DURATION / 2, Easing.In); + this.FadeOut(TRANSITION_DURATION, Easing.OutQuint); + } + + private void rotate() + { + spinner.Spin(spin_duration * 4, RotationDirection.Clockwise); + + MainContents.RotateTo(0).Then() + .RotateTo(90, spin_duration, Easing.InOutQuart).Then() + .RotateTo(180, spin_duration, Easing.InOutQuart).Then() + .RotateTo(270, spin_duration, Easing.InOutQuart).Then() + .RotateTo(360, spin_duration, Easing.InOutQuart).Then() + .Loop(); + } } } diff --git a/osu.Game/Graphics/UserInterface/LoadingLayer.cs b/osu.Game/Graphics/UserInterface/LoadingLayer.cs new file mode 100644 index 0000000000..a7b39c77fa --- /dev/null +++ b/osu.Game/Graphics/UserInterface/LoadingLayer.cs @@ -0,0 +1,74 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Input.Events; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Graphics.UserInterface +{ + /// + /// An overlay that will show a loading overlay and completely block input to an area. + /// Also optionally dims target elements. + /// Useful for disabling all elements in a form and showing we are waiting on a response, for instance. + /// + public class LoadingLayer : LoadingAnimation + { + private readonly Drawable dimTarget; + + public LoadingLayer(Drawable dimTarget = null, bool withBox = true) + : base(withBox) + { + RelativeSizeAxes = Axes.Both; + Size = new Vector2(1); + + this.dimTarget = dimTarget; + + MainContents.RelativeSizeAxes = Axes.None; + } + + protected override bool Handle(UIEvent e) + { + switch (e) + { + // blocking scroll can cause weird behaviour when this layer is used within a ScrollContainer. + case ScrollEvent _: + return false; + } + + return true; + } + + protected override void PopIn() + { + dimTarget?.FadeColour(OsuColour.Gray(0.5f), TRANSITION_DURATION, Easing.OutQuint); + base.PopIn(); + } + + protected override void PopOut() + { + dimTarget?.FadeColour(Color4.White, TRANSITION_DURATION, Easing.OutQuint); + base.PopOut(); + } + + protected override void Update() + { + base.Update(); + MainContents.Size = new Vector2(Math.Min(DrawWidth, DrawHeight) * 0.25f); + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (State.Value == Visibility.Visible) + { + // ensure we don't leave the target in a bad state. + dimTarget?.FadeColour(Color4.White, TRANSITION_DURATION, Easing.OutQuint); + } + } + } +} diff --git a/osu.Game/Graphics/UserInterface/ProcessingOverlay.cs b/osu.Game/Graphics/UserInterface/ProcessingOverlay.cs deleted file mode 100644 index c65801a82e..0000000000 --- a/osu.Game/Graphics/UserInterface/ProcessingOverlay.cs +++ /dev/null @@ -1,88 +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 osu.Framework.Graphics.Shapes; -using osu.Framework.Input.Events; -using osuTK; -using osuTK.Graphics; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// An overlay that will show a loading overlay and completely block input to an area. - /// Also optionally dims target elements. - /// Useful for disabling all elements in a form and showing we are waiting on a response, for instance. - /// - public class ProcessingOverlay : VisibilityContainer - { - private readonly Drawable dimTarget; - - private Container loadingBox; - - private const float transition_duration = 600; - - public ProcessingOverlay(Drawable dimTarget = null) - { - this.dimTarget = dimTarget; - RelativeSizeAxes = Axes.Both; - } - - [BackgroundDependencyLoader] - private void load() - { - InternalChildren = new Drawable[] - { - loadingBox = new Container - { - Size = new Vector2(80), - Scale = new Vector2(0.8f), - Masking = true, - CornerRadius = 15, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new Drawable[] - { - new Box - { - Colour = Color4.Black, - RelativeSizeAxes = Axes.Both, - }, - new LoadingAnimation { State = { Value = Visibility.Visible } } - } - }, - }; - } - - protected override bool Handle(UIEvent e) => true; - - protected override void PopIn() - { - this.FadeIn(transition_duration, Easing.OutQuint); - loadingBox.ScaleTo(1, transition_duration, Easing.OutElastic); - - dimTarget?.FadeColour(OsuColour.Gray(0.5f), transition_duration, Easing.OutQuint); - } - - protected override void PopOut() - { - this.FadeOut(transition_duration, Easing.OutQuint); - loadingBox.ScaleTo(0.8f, transition_duration / 2, Easing.In); - - dimTarget?.FadeColour(Color4.White, transition_duration, Easing.OutQuint); - } - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - - if (State.Value == Visibility.Visible) - { - // ensure we don't leave the target in a bad state. - dimTarget?.FadeColour(Color4.White, transition_duration, Easing.OutQuint); - } - } - } -} diff --git a/osu.Game/Overlays/AccountCreation/ScreenEntry.cs b/osu.Game/Overlays/AccountCreation/ScreenEntry.cs index 454fce0261..2576900db8 100644 --- a/osu.Game/Overlays/AccountCreation/ScreenEntry.cs +++ b/osu.Game/Overlays/AccountCreation/ScreenEntry.cs @@ -40,7 +40,7 @@ public class ScreenEntry : AccountCreationScreen private IEnumerable characterCheckText; private OsuTextBox[] textboxes; - private ProcessingOverlay processingOverlay; + private LoadingLayer loadingLayer; [Resolved] private GameHost host { get; set; } @@ -124,7 +124,7 @@ private void load(OsuColour colours) }, }, }, - processingOverlay = new ProcessingOverlay(mainContent) + loadingLayer = new LoadingLayer(mainContent) }; textboxes = new[] { usernameTextBox, emailTextBox, passwordTextBox }; @@ -144,7 +144,7 @@ private void load(OsuColour colours) public override void OnEntering(IScreen last) { base.OnEntering(last); - processingOverlay.Hide(); + loadingLayer.Hide(); if (host?.OnScreenKeyboardOverlapsGameWindow != true) focusNextTextbox(); @@ -162,7 +162,7 @@ private void performRegistration() emailAddressDescription.ClearErrors(); passwordDescription.ClearErrors(); - processingOverlay.Show(); + loadingLayer.Show(); Task.Run(() => { @@ -195,7 +195,7 @@ private void performRegistration() } registerShake.Shake(); - processingOverlay.Hide(); + loadingLayer.Hide(); return; } diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs index af0987d183..742b1055b2 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; @@ -25,7 +24,7 @@ public class FavouriteButton : HeaderButton, IHasTooltip private readonly BindableBool favourited = new BindableBool(); private PostBeatmapFavouriteRequest request; - private DimmedLoadingLayer loading; + private LoadingLayer loading; private readonly Bindable localUser = new Bindable(); @@ -54,14 +53,11 @@ private void load(IAPIProvider api, NotificationOverlay notifications) Size = new Vector2(18), Shadow = false, }, - loading = new DimmedLoadingLayer(0.8f, 0.5f), + loading = new LoadingLayer(icon, false), }); Action = () => { - if (loading.State.Value == Visibility.Visible) - return; - // guaranteed by disabled state above. Debug.Assert(BeatmapSet.Value.OnlineBeatmapSetID != null); diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 92ff3c3125..e831c8ce42 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics.UserInterface; using osuTK; using System.Linq; using osu.Game.Online.API.Requests.Responses; @@ -13,6 +12,7 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Framework.Bindables; +using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osu.Game.Screens.Select.Leaderboards; using osu.Game.Users; @@ -31,7 +31,7 @@ public class ScoresContainer : CompositeDrawable private readonly Box background; private readonly ScoreTable scoreTable; private readonly FillFlowContainer topScoresContainer; - private readonly DimmedLoadingLayer loading; + private readonly LoadingLayer loading; private readonly LeaderboardModSelector modSelector; private readonly NoScoresPlaceholder noScoresPlaceholder; private readonly FillFlowContainer content; @@ -160,16 +160,7 @@ public ScoresContainer() } } }, - new Container - { - RelativeSizeAxes = Axes.Both, - Masking = true, - CornerRadius = 5, - Child = loading = new DimmedLoadingLayer(iconScale: 0.8f) - { - Alpha = 0, - }, - } + loading = new LoadingLayer() } } } diff --git a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs index e609fa1487..6f06eecd6e 100644 --- a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs +++ b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs @@ -37,7 +37,7 @@ public class SpotlightsLayout : CompositeDrawable private SpotlightSelector selector; private Container content; - private DimmedLoadingLayer loading; + private LoadingLayer loading; [BackgroundDependencyLoader] private void load() @@ -67,7 +67,7 @@ private void load() AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Vertical = 10 } }, - loading = new DimmedLoadingLayer() + loading = new LoadingLayer(content) } } } diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 2c5ea61315..b372511bd2 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -9,9 +9,9 @@ using osu.Game.Overlays.Rankings; using osu.Game.Users; using osu.Game.Rulesets; -using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using System.Threading; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Rankings.Tables; @@ -27,7 +27,7 @@ public class RankingsOverlay : FullscreenOverlay private readonly BasicScrollContainer scrollFlow; private readonly Container contentContainer; - private readonly DimmedLoadingLayer loading; + private readonly LoadingLayer loading; private readonly Box background; private readonly RankingsOverlayHeader header; @@ -77,7 +77,7 @@ public RankingsOverlay() RelativeSizeAxes = Axes.X, Margin = new MarginPadding { Bottom = 10 } }, - loading = new DimmedLoadingLayer(), + loading = new LoadingLayer(contentContainer), } } } diff --git a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs index 58e4548ee2..e2e5b1b549 100644 --- a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs +++ b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs @@ -23,7 +23,7 @@ public class LoungeSubScreen : MultiplayerSubScreen protected readonly FilterControl Filter; private readonly Container content; - private readonly ProcessingOverlay processingOverlay; + private readonly LoadingLayer loadingLayer; [Resolved] private Bindable currentRoom { get; set; } @@ -58,7 +58,7 @@ public LoungeSubScreen() Child = new RoomsContainer { JoinRequested = joinRequested } }, }, - processingOverlay = new ProcessingOverlay(searchContainer), + loadingLayer = new LoadingLayer(searchContainer), } }, new RoomInspector @@ -126,12 +126,12 @@ public override void OnSuspending(IScreen next) private void joinRequested(Room room) { - processingOverlay.Show(); + loadingLayer.Show(); RoomManager?.JoinRoom(room, r => { Open(room); - processingOverlay.Hide(); - }, _ => processingOverlay.Hide()); + loadingLayer.Hide(); + }, _ => loadingLayer.Hide()); } /// diff --git a/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs b/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs index 8c005a2647..115ac5037a 100644 --- a/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs +++ b/osu.Game/Screens/Multi/Match/Components/MatchSettingsOverlay.cs @@ -67,7 +67,7 @@ protected class MatchSettings : MultiplayerComposite public OsuSpriteText ErrorText; private OsuSpriteText typeLabel; - private ProcessingOverlay processingOverlay; + private LoadingLayer loadingLayer; private DrawableRoomPlaylist playlist; [Resolved(CanBeNull = true)] @@ -307,7 +307,7 @@ private void load(OsuColour colours) }, } }, - processingOverlay = new ProcessingOverlay(dimContent) + loadingLayer = new LoadingLayer(dimContent) }; TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true); @@ -346,19 +346,19 @@ private void apply() manager?.CreateRoom(currentRoom.Value, onSuccess, onError); - processingOverlay.Show(); + loadingLayer.Show(); } private void hideError() => ErrorText.FadeOut(50); - private void onSuccess(Room room) => processingOverlay.Hide(); + private void onSuccess(Room room) => loadingLayer.Hide(); private void onError(string text) { ErrorText.Text = text; ErrorText.FadeIn(50); - processingOverlay.Hide(); + loadingLayer.Hide(); } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 85b892336a..aebb8e9d87 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using System.Linq; using osu.Game.Online.API; using osu.Framework.Threading; @@ -17,6 +16,7 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests; using osu.Game.Rulesets; @@ -35,7 +35,7 @@ public class BeatmapDetails : Container private readonly MetadataSection description, source, tags; private readonly Container failRetryContainer; private readonly FailRetryGraph failRetryGraph; - private readonly DimmedLoadingLayer loading; + private readonly LoadingLayer loading; [Resolved] private IAPIProvider api { get; set; } @@ -63,6 +63,8 @@ public BeatmapInfo Beatmap public BeatmapDetails() { + Container content; + Children = new Drawable[] { new Box @@ -70,7 +72,7 @@ public BeatmapDetails() RelativeSizeAxes = Axes.Both, Colour = Color4.Black.Opacity(0.5f), }, - new Container + content = new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = spacing }, @@ -157,7 +159,7 @@ public BeatmapDetails() }, }, }, - loading = new DimmedLoadingLayer(), + loading = new LoadingLayer(content), }; } From 92f6f0207cf3310efdd91242a26fa6e2cbf2205f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 15:33:31 +0900 Subject: [PATCH 09/18] Rename LoadingAnimation to LoadingSpinner --- .../Visual/Online/TestSceneOnlineViewContainer.cs | 10 +++++----- .../Visual/UserInterface/TestSceneLoadingAnimation.cs | 10 +++++----- .../Visual/UserInterface/TestSceneLoadingLayer.cs | 2 +- osu.Game/Graphics/UserInterface/LoadingButton.cs | 4 ++-- osu.Game/Graphics/UserInterface/LoadingLayer.cs | 2 +- .../{LoadingAnimation.cs => LoadingSpinner.cs} | 4 ++-- osu.Game/Online/Leaderboards/Leaderboard.cs | 4 ++-- osu.Game/Online/OnlineViewContainer.cs | 10 +++++----- osu.Game/Overlays/BeatmapSet/Header.cs | 6 +++--- osu.Game/Overlays/ChatOverlay.cs | 4 ++-- osu.Game/Overlays/Direct/PlayButton.cs | 8 ++++---- .../Settings/Sections/General/LoginSettings.cs | 2 +- osu.Game/Overlays/SocialOverlay.cs | 4 ++-- osu.Game/Screens/Play/BeatmapMetadataDisplay.cs | 4 ++-- 14 files changed, 37 insertions(+), 37 deletions(-) rename osu.Game/Graphics/UserInterface/{LoadingAnimation.cs => LoadingSpinner.cs} (96%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneOnlineViewContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneOnlineViewContainer.cs index 3c2735ca56..9591d53b24 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneOnlineViewContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneOnlineViewContainer.cs @@ -35,7 +35,7 @@ public void TestOnlineStateVisibility() AddStep("set status to online", () => ((DummyAPIAccess)API).State = APIState.Online); AddUntilStep("children are visible", () => onlineView.ViewTarget.IsPresent); - AddUntilStep("loading animation is not visible", () => !onlineView.LoadingAnimation.IsPresent); + AddUntilStep("loading animation is not visible", () => !onlineView.LoadingSpinner.IsPresent); } [Test] @@ -44,7 +44,7 @@ public void TestOfflineStateVisibility() AddStep("set status to offline", () => ((DummyAPIAccess)API).State = APIState.Offline); AddUntilStep("children are not visible", () => !onlineView.ViewTarget.IsPresent); - AddUntilStep("loading animation is not visible", () => !onlineView.LoadingAnimation.IsPresent); + AddUntilStep("loading animation is not visible", () => !onlineView.LoadingSpinner.IsPresent); } [Test] @@ -53,7 +53,7 @@ public void TestConnectingStateVisibility() AddStep("set status to connecting", () => ((DummyAPIAccess)API).State = APIState.Connecting); AddUntilStep("children are not visible", () => !onlineView.ViewTarget.IsPresent); - AddUntilStep("loading animation is visible", () => onlineView.LoadingAnimation.IsPresent); + AddUntilStep("loading animation is visible", () => onlineView.LoadingSpinner.IsPresent); } [Test] @@ -62,12 +62,12 @@ public void TestFailingStateVisibility() AddStep("set status to failing", () => ((DummyAPIAccess)API).State = APIState.Failing); AddUntilStep("children are not visible", () => !onlineView.ViewTarget.IsPresent); - AddUntilStep("loading animation is visible", () => onlineView.LoadingAnimation.IsPresent); + AddUntilStep("loading animation is visible", () => onlineView.LoadingSpinner.IsPresent); } private class TestOnlineViewContainer : OnlineViewContainer { - public new LoadingAnimation LoadingAnimation => base.LoadingAnimation; + public new LoadingSpinner LoadingSpinner => base.LoadingSpinner; public CompositeDrawable ViewTarget => base.Content; diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs index b0233d35f9..cdb20b9935 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs @@ -13,7 +13,7 @@ public class TestSceneLoadingAnimation : OsuGridTestScene public TestSceneLoadingAnimation() : base(2, 2) { - LoadingAnimation loading; + LoadingSpinner loading; Cell(0).AddRange(new Drawable[] { @@ -22,7 +22,7 @@ public TestSceneLoadingAnimation() Colour = Color4.Black, RelativeSizeAxes = Axes.Both }, - loading = new LoadingAnimation() + loading = new LoadingSpinner() }); loading.Show(); @@ -34,7 +34,7 @@ public TestSceneLoadingAnimation() Colour = Color4.White, RelativeSizeAxes = Axes.Both }, - loading = new LoadingAnimation() + loading = new LoadingSpinner() }); loading.Show(); @@ -46,14 +46,14 @@ public TestSceneLoadingAnimation() Colour = Color4.Gray, RelativeSizeAxes = Axes.Both }, - loading = new LoadingAnimation() + loading = new LoadingSpinner() }); loading.Show(); Cell(3).AddRange(new Drawable[] { - loading = new LoadingAnimation() + loading = new LoadingSpinner() }); Scheduler.AddDelayed(() => loading.ToggleVisibility(), 200, true); diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs index 0f49835742..4636c74ca9 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs @@ -19,7 +19,7 @@ public class TestSceneLoadingLayer : OsuTestScene private Drawable dimContent; private LoadingLayer overlay; - public override IReadOnlyList RequiredTypes => new[] { typeof(LoadingAnimation) }; + public override IReadOnlyList RequiredTypes => new[] { typeof(LoadingSpinner) }; [SetUp] public void SetUp() => Schedule(() => diff --git a/osu.Game/Graphics/UserInterface/LoadingButton.cs b/osu.Game/Graphics/UserInterface/LoadingButton.cs index 49ec18ce8e..81dc023d7e 100644 --- a/osu.Game/Graphics/UserInterface/LoadingButton.cs +++ b/osu.Game/Graphics/UserInterface/LoadingButton.cs @@ -40,14 +40,14 @@ public Vector2 LoadingAnimationSize set => loading.Size = value; } - private readonly LoadingAnimation loading; + private readonly LoadingSpinner loading; protected LoadingButton() { AddRange(new[] { CreateContent(), - loading = new LoadingAnimation + loading = new LoadingSpinner { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Graphics/UserInterface/LoadingLayer.cs b/osu.Game/Graphics/UserInterface/LoadingLayer.cs index a7b39c77fa..23906e76b9 100644 --- a/osu.Game/Graphics/UserInterface/LoadingLayer.cs +++ b/osu.Game/Graphics/UserInterface/LoadingLayer.cs @@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface /// Also optionally dims target elements. /// Useful for disabling all elements in a form and showing we are waiting on a response, for instance. /// - public class LoadingLayer : LoadingAnimation + public class LoadingLayer : LoadingSpinner { private readonly Drawable dimTarget; diff --git a/osu.Game/Graphics/UserInterface/LoadingAnimation.cs b/osu.Game/Graphics/UserInterface/LoadingSpinner.cs similarity index 96% rename from osu.Game/Graphics/UserInterface/LoadingAnimation.cs rename to osu.Game/Graphics/UserInterface/LoadingSpinner.cs index 265c93bce3..4f42d1d8c8 100644 --- a/osu.Game/Graphics/UserInterface/LoadingAnimation.cs +++ b/osu.Game/Graphics/UserInterface/LoadingSpinner.cs @@ -13,7 +13,7 @@ namespace osu.Game.Graphics.UserInterface /// /// A loading spinner. /// - public class LoadingAnimation : VisibilityContainer + public class LoadingSpinner : VisibilityContainer { private readonly SpriteIcon spinner; @@ -27,7 +27,7 @@ public class LoadingAnimation : VisibilityContainer /// Constuct a new loading spinner. /// /// - public LoadingAnimation(bool withBox = false) + public LoadingSpinner(bool withBox = false) { Size = new Vector2(60); diff --git a/osu.Game/Online/Leaderboards/Leaderboard.cs b/osu.Game/Online/Leaderboards/Leaderboard.cs index 71859d3aeb..e2a817aaff 100644 --- a/osu.Game/Online/Leaderboards/Leaderboard.cs +++ b/osu.Game/Online/Leaderboards/Leaderboard.cs @@ -30,7 +30,7 @@ public abstract class Leaderboard : Container, IOnlineCompon private FillFlowContainer scrollFlow; - private readonly LoadingAnimation loading; + private readonly LoadingSpinner loading; private ScheduledDelegate showScoresDelegate; private CancellationTokenSource showScoresCancellationSource; @@ -202,7 +202,7 @@ protected Leaderboard() } }, }, - loading = new LoadingAnimation(), + loading = new LoadingSpinner(), placeholderContainer = new Container { RelativeSizeAxes = Axes.Both diff --git a/osu.Game/Online/OnlineViewContainer.cs b/osu.Game/Online/OnlineViewContainer.cs index 689c1c0afb..b52e3d9e3c 100644 --- a/osu.Game/Online/OnlineViewContainer.cs +++ b/osu.Game/Online/OnlineViewContainer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Online /// public abstract class OnlineViewContainer : Container, IOnlineComponent { - protected LoadingAnimation LoadingAnimation { get; private set; } + protected LoadingSpinner LoadingSpinner { get; private set; } protected override Container Content { get; } = new Container { RelativeSizeAxes = Axes.Both }; @@ -41,7 +41,7 @@ private void load() { Content, placeholder = new LoginPlaceholder(placeholderMessage), - LoadingAnimation = new LoadingAnimation + LoadingSpinner = new LoadingSpinner { Alpha = 0, } @@ -63,19 +63,19 @@ public virtual void APIStateChanged(IAPIProvider api, APIState state) PopContentOut(Content); placeholder.ScaleTo(0.8f).Then().ScaleTo(1, 3 * transform_duration, Easing.OutQuint); placeholder.FadeInFromZero(2 * transform_duration, Easing.OutQuint); - LoadingAnimation.Hide(); + LoadingSpinner.Hide(); break; case APIState.Online: PopContentIn(Content); placeholder.FadeOut(transform_duration / 2, Easing.OutQuint); - LoadingAnimation.Hide(); + LoadingSpinner.Hide(); break; case APIState.Failing: case APIState.Connecting: PopContentOut(Content); - LoadingAnimation.Show(); + LoadingSpinner.Show(); placeholder.FadeOut(transform_duration / 2, Easing.OutQuint); break; } diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index c1e9ce2008..29c259b7f8 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// 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; @@ -45,7 +45,7 @@ public class Header : BeatmapDownloadTrackingComposite private readonly FavouriteButton favouriteButton; private readonly FillFlowContainer fadeContent; - private readonly LoadingAnimation loading; + private readonly LoadingSpinner loading; private readonly BeatmapSetHeader beatmapSetHeader; [Cached(typeof(IBindable))] @@ -179,7 +179,7 @@ public Header() }, } }, - loading = new LoadingAnimation + loading = new LoadingSpinner { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index bdc241a437..34afc3c431 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -37,7 +37,7 @@ public class ChatOverlay : OsuFocusedOverlayContainer private readonly List loadedChannels = new List(); - private LoadingAnimation loading; + private LoadingSpinner loading; private FocusedTextBox textbox; @@ -146,7 +146,7 @@ private void load(OsuConfigManager config, OsuColour colours) } } }, - loading = new LoadingAnimation(), + loading = new LoadingSpinner(), } }, tabsArea = new TabsArea diff --git a/osu.Game/Overlays/Direct/PlayButton.cs b/osu.Game/Overlays/Direct/PlayButton.cs index 10abe15177..d9f335b6a7 100644 --- a/osu.Game/Overlays/Direct/PlayButton.cs +++ b/osu.Game/Overlays/Direct/PlayButton.cs @@ -42,7 +42,7 @@ public BeatmapSetInfo BeatmapSet private Color4 hoverColour; private readonly SpriteIcon icon; - private readonly LoadingAnimation loadingAnimation; + private readonly LoadingSpinner loadingSpinner; private const float transition_duration = 500; @@ -53,12 +53,12 @@ private bool loading if (value) { icon.FadeTo(0.5f, transition_duration, Easing.OutQuint); - loadingAnimation.Show(); + loadingSpinner.Show(); } else { icon.FadeTo(1, transition_duration, Easing.OutQuint); - loadingAnimation.Hide(); + loadingSpinner.Hide(); } } } @@ -76,7 +76,7 @@ public PlayButton(BeatmapSetInfo setInfo = null) RelativeSizeAxes = Axes.Both, Icon = FontAwesome.Solid.Play, }, - loadingAnimation = new LoadingAnimation + loadingSpinner = new LoadingSpinner { Size = new Vector2(15), }, diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index c55183772b..bf0e073350 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -95,7 +95,7 @@ public void APIStateChanged(IAPIProvider api, APIState state) => Schedule(() => Children = new Drawable[] { - new LoadingAnimation + new LoadingSpinner { State = { Value = Visibility.Visible }, Anchor = Anchor.TopCentre, diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index 9a523bc1bc..54c978738d 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays { public class SocialOverlay : SearchableListOverlay { - private readonly LoadingAnimation loading; + private readonly LoadingSpinner loading; private FillFlowContainer panels; protected override Color4 BackgroundColour => OsuColour.FromHex(@"60284b"); @@ -54,7 +54,7 @@ public User[] Users public SocialOverlay() : base(OverlayColourScheme.Pink) { - Add(loading = new LoadingAnimation()); + Add(loading = new LoadingSpinner()); Filter.Search.Current.ValueChanged += text => { diff --git a/osu.Game/Screens/Play/BeatmapMetadataDisplay.cs b/osu.Game/Screens/Play/BeatmapMetadataDisplay.cs index 074341226e..77ee52f23e 100644 --- a/osu.Game/Screens/Play/BeatmapMetadataDisplay.cs +++ b/osu.Game/Screens/Play/BeatmapMetadataDisplay.cs @@ -53,7 +53,7 @@ public MetadataLine(string left, string right) private readonly WorkingBeatmap beatmap; private readonly Bindable> mods; private readonly Drawable facade; - private LoadingAnimation loading; + private LoadingSpinner loading; private Sprite backgroundSprite; public IBindable> Mods => mods; @@ -138,7 +138,7 @@ private void load() Anchor = Anchor.Centre, FillMode = FillMode.Fill, }, - loading = new LoadingAnimation { Scale = new Vector2(1.3f) } + loading = new LoadingSpinner { Scale = new Vector2(1.3f) } } }, new OsuSpriteText From b94f937f7e122bc6a962b591a642dc53af757130 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 15:35:40 +0900 Subject: [PATCH 10/18] Fill in missing xmldoc --- osu.Game/Graphics/UserInterface/LoadingLayer.cs | 7 ++++++- osu.Game/Graphics/UserInterface/LoadingSpinner.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LoadingLayer.cs b/osu.Game/Graphics/UserInterface/LoadingLayer.cs index 23906e76b9..f1d347138f 100644 --- a/osu.Game/Graphics/UserInterface/LoadingLayer.cs +++ b/osu.Game/Graphics/UserInterface/LoadingLayer.cs @@ -11,7 +11,7 @@ namespace osu.Game.Graphics.UserInterface { /// - /// An overlay that will show a loading overlay and completely block input to an area. + /// A layer that will show a loading spinner and completely block input to an area. /// Also optionally dims target elements. /// Useful for disabling all elements in a form and showing we are waiting on a response, for instance. /// @@ -19,6 +19,11 @@ public class LoadingLayer : LoadingSpinner { private readonly Drawable dimTarget; + /// + /// Constuct a new loading spinner. + /// + /// An optional target to dim when displayed. + /// Whether the spinner should have a surrounding black box for visibility. public LoadingLayer(Drawable dimTarget = null, bool withBox = true) : base(withBox) { diff --git a/osu.Game/Graphics/UserInterface/LoadingSpinner.cs b/osu.Game/Graphics/UserInterface/LoadingSpinner.cs index 4f42d1d8c8..b5a235f9d8 100644 --- a/osu.Game/Graphics/UserInterface/LoadingSpinner.cs +++ b/osu.Game/Graphics/UserInterface/LoadingSpinner.cs @@ -26,7 +26,7 @@ public class LoadingSpinner : VisibilityContainer /// /// Constuct a new loading spinner. /// - /// + /// Whether the spinner should have a surrounding black box for visibility. public LoadingSpinner(bool withBox = false) { Size = new Vector2(60); From dacbbb5eeefff51ea7915cf60ef5b93ec3c589cd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 16:11:09 +0900 Subject: [PATCH 11/18] Add a maximum size to ensure things don't get out of hand --- osu.Game/Graphics/UserInterface/LoadingLayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/LoadingLayer.cs b/osu.Game/Graphics/UserInterface/LoadingLayer.cs index f1d347138f..4fdc95f483 100644 --- a/osu.Game/Graphics/UserInterface/LoadingLayer.cs +++ b/osu.Game/Graphics/UserInterface/LoadingLayer.cs @@ -62,7 +62,7 @@ protected override void PopOut() protected override void Update() { base.Update(); - MainContents.Size = new Vector2(Math.Min(DrawWidth, DrawHeight) * 0.25f); + MainContents.Size = new Vector2(Math.Min(100, Math.Min(DrawWidth, DrawHeight) * 0.25f)); } protected override void Dispose(bool isDisposing) From 38d9a46ffb854f1540177d636a1c1a2e8a824166 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 16:20:17 +0900 Subject: [PATCH 12/18] Add test for relative sizing scenarios --- .../UserInterface/TestSceneLoadingLayer.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs index 4636c74ca9..7e9654715b 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingLayer.cs @@ -21,12 +21,14 @@ public class TestSceneLoadingLayer : OsuTestScene public override IReadOnlyList RequiredTypes => new[] { typeof(LoadingSpinner) }; + private Container content; + [SetUp] public void SetUp() => Schedule(() => { Children = new[] { - new Container + content = new Container { Size = new Vector2(300), Anchor = Anchor.Centre, @@ -60,7 +62,7 @@ public void SetUp() => Schedule(() => }); [Test] - public void ShowHide() + public void TestShowHide() { AddAssert("not visible", () => !overlay.IsPresent); @@ -74,7 +76,7 @@ public void ShowHide() } [Test] - public void ContentRestoreOnDispose() + public void TestContentRestoreOnDispose() { AddAssert("not visible", () => !overlay.IsPresent); @@ -82,9 +84,23 @@ public void ContentRestoreOnDispose() AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White); - AddStep("hide", () => overlay.Expire()); + AddStep("expire", () => overlay.Expire()); AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White); } + + [Test] + public void TestLargeArea() + { + AddStep("show", () => + { + content.RelativeSizeAxes = Axes.Both; + content.Size = new Vector2(1); + + overlay.Show(); + }); + + AddStep("hide", () => overlay.Hide()); + } } } From bbac95958cc26ff36f6772cc3cb02bc79a066eec Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 16:20:55 +0900 Subject: [PATCH 13/18] Fix incorrect test scene name --- ...estSceneLoadingAnimation.cs => TestSceneLoadingSpinner.cs} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename osu.Game.Tests/Visual/UserInterface/{TestSceneLoadingAnimation.cs => TestSceneLoadingSpinner.cs} (93%) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingSpinner.cs similarity index 93% rename from osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs rename to osu.Game.Tests/Visual/UserInterface/TestSceneLoadingSpinner.cs index cdb20b9935..45d846a825 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingAnimation.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingSpinner.cs @@ -8,9 +8,9 @@ namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneLoadingAnimation : OsuGridTestScene + public class TestSceneLoadingSpinner : OsuGridTestScene { - public TestSceneLoadingAnimation() + public TestSceneLoadingSpinner() : base(2, 2) { LoadingSpinner loading; From 7d145a74704d61a1a44360cac41cd20be0180495 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 16:21:44 +0900 Subject: [PATCH 14/18] Add test for loading spinner with box --- osu.Game.Tests/Visual/UserInterface/TestSceneLoadingSpinner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingSpinner.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingSpinner.cs index 45d846a825..47f5bdfe17 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingSpinner.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLoadingSpinner.cs @@ -34,7 +34,7 @@ public TestSceneLoadingSpinner() Colour = Color4.White, RelativeSizeAxes = Axes.Both }, - loading = new LoadingSpinner() + loading = new LoadingSpinner(true) }); loading.Show(); From e7ac37715f0d1ca9f16f271558811ccd2ee187f8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 16:31:16 +0900 Subject: [PATCH 15/18] Don't handle non-positional input --- osu.Game/Graphics/UserInterface/LoadingLayer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/LoadingLayer.cs b/osu.Game/Graphics/UserInterface/LoadingLayer.cs index 4fdc95f483..25a62acaba 100644 --- a/osu.Game/Graphics/UserInterface/LoadingLayer.cs +++ b/osu.Game/Graphics/UserInterface/LoadingLayer.cs @@ -35,6 +35,8 @@ public LoadingLayer(Drawable dimTarget = null, bool withBox = true) MainContents.RelativeSizeAxes = Axes.None; } + public override bool HandleNonPositionalInput => false; + protected override bool Handle(UIEvent e) { switch (e) From 514160e4bb48e5f9d4d06822ab15d18b139bb0c8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 18:38:25 +0900 Subject: [PATCH 16/18] Update framework --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 1774ea0bb4..939d179b1d 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -54,6 +54,6 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c034fb6567..24ee25c4de 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -23,7 +23,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 7f99338c6e..3743138c1a 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -74,7 +74,7 @@ - + @@ -82,7 +82,7 @@ - + From 81f9103f9cfdc0a67adfc3f2635519d5b6c5a6ac Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 18:54:48 +0900 Subject: [PATCH 17/18] Bind with global ruleset for now --- osu.Game/Overlays/RankingsOverlay.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 404f896cad..4e0b644d16 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -23,8 +23,6 @@ public class RankingsOverlay : FullscreenOverlay protected Bindable Scope => header.Current; - private Bindable ruleset => header.Ruleset; - private readonly BasicScrollContainer scrollFlow; private readonly Container contentContainer; private readonly DimmedLoadingLayer loading; @@ -92,10 +90,15 @@ private void load() background.Colour = ColourProvider.Background5; } + [Resolved] + private Bindable ruleset { get; set; } + protected override void LoadComplete() { base.LoadComplete(); + header.Ruleset.BindTo(ruleset); + Country.BindValueChanged(_ => { // if a country is requested, force performance scope. @@ -121,6 +124,8 @@ protected override void LoadComplete() Scheduler.AddOnce(loadNewContent); }); + + Scheduler.AddOnce(loadNewContent); } public void ShowCountry(Country requested) @@ -130,7 +135,7 @@ public void ShowCountry(Country requested) Show(); - Schedule(() => Country.Value = requested); + Country.Value = requested; } private void loadNewContent() From f9d7e7c6b89dc1335f2a260d4004ae890e218ef8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Feb 2020 19:16:08 +0900 Subject: [PATCH 18/18] Add simple updater support for linux AppImages --- osu.Game/Updater/SimpleUpdateManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index e490ac14e9..1e8a96444f 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -78,6 +78,10 @@ private string getBestUrl(GitHubRelease release) bestAsset = release.Assets?.Find(f => f.Name.EndsWith(".app.zip")); break; + case RuntimeInfo.Platform.Linux: + bestAsset = release.Assets?.Find(f => f.Name.EndsWith(".AppImage")); + break; + case RuntimeInfo.Platform.Android: // on our testing device this causes the download to magically disappear. //bestAsset = release.Assets?.Find(f => f.Name.EndsWith(".apk"));