From b1f18481e0b0c008625841abfa07ab73d658e1a7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 13 Mar 2019 12:57:01 +0900 Subject: [PATCH 1/3] Show text to supporters telling them they're cool Also adds better tests for disclaimer screen. --- osu.Game.Tests/Visual/TestCaseDisclaimer.cs | 17 ++++- osu.Game/Screens/Menu/Disclaimer.cs | 85 +++++++++++++++------ 2 files changed, 76 insertions(+), 26 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseDisclaimer.cs b/osu.Game.Tests/Visual/TestCaseDisclaimer.cs index 3ceb3eb4bd..f08a2a54ca 100644 --- a/osu.Game.Tests/Visual/TestCaseDisclaimer.cs +++ b/osu.Game.Tests/Visual/TestCaseDisclaimer.cs @@ -2,16 +2,31 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Game.Online.API; using osu.Game.Screens.Menu; +using osu.Game.Users; namespace osu.Game.Tests.Visual { public class TestCaseDisclaimer : ScreenTestCase { + [Cached(typeof(IAPIProvider))] + private readonly DummyAPIAccess api = new DummyAPIAccess(); + [BackgroundDependencyLoader] private void load() { - LoadScreen(new Disclaimer()); + AddStep("load disclaimer", () => LoadScreen(new Disclaimer())); + + AddStep("toggle support", () => + { + api.LocalUser.Value = new User + { + Username = api.LocalUser.Value.Username, + Id = api.LocalUser.Value.Id, + IsSupporter = !api.LocalUser.Value.IsSupporter, + }; + }); } } } diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 7a80a686b1..af8c127a3c 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -1,12 +1,13 @@ -// 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; -using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Screens; using osu.Game.Graphics; @@ -25,16 +26,17 @@ namespace osu.Game.Screens.Menu private SpriteIcon icon; private Color4 iconColour; private LinkFlowContainer textFlow; + private LinkFlowContainer supportFlow; public override bool HideOverlaysOnEnter => true; public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; public override bool CursorVisible => false; - private readonly List supporterDrawables = new List(); private Drawable heart; private const float icon_y = -85; + private const float icon_size = 30; private readonly Bindable currentUser = new Bindable(); @@ -53,19 +55,38 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.Centre, Origin = Anchor.Centre, Icon = FontAwesome.fa_warning, - Size = new Vector2(30), + Size = new Vector2(icon_size), Y = icon_y, }, - textFlow = new LinkFlowContainer + new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding(50), - TextAnchor = Anchor.TopCentre, - Y = -110, + Direction = FillDirection.Vertical, + Y = icon_y + icon_size, Anchor = Anchor.Centre, Origin = Anchor.TopCentre, - Spacing = new Vector2(0, 2), + Children = new Drawable[] + { + textFlow = new LinkFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + TextAnchor = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Spacing = new Vector2(0, 2), + }, + supportFlow = new LinkFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + TextAnchor = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Spacing = new Vector2(0, 2), + }, + } } }; @@ -88,28 +109,42 @@ namespace osu.Game.Screens.Menu textFlow.NewParagraph(); textFlow.NewParagraph(); - supporterDrawables.AddRange(textFlow.AddText("Consider becoming an ", format)); - supporterDrawables.AddRange(textFlow.AddLink("osu!supporter", "https://osu.ppy.sh/home/support", creationParameters: format)); - supporterDrawables.AddRange(textFlow.AddText(" to help support the game", format)); - - supporterDrawables.Add(heart = textFlow.AddIcon(FontAwesome.fa_heart, t => - { - t.Padding = new MarginPadding { Left = 5 }; - t.Font = t.Font.With(size: 12); - t.Colour = colours.Pink; - t.Origin = Anchor.Centre; - }).First()); - iconColour = colours.Yellow; currentUser.BindTo(api.LocalUser); currentUser.BindValueChanged(e => { + supportFlow.Children.ForEach(d => d.FadeOut(500, Easing.OutQuint).Expire()); + if (e.NewValue.IsSupporter) - supporterDrawables.ForEach(d => d.FadeOut(500, Easing.OutQuint).Expire()); + { + supportFlow.AddText("Thank you for supporting osu!", format); + } + else + { + supportFlow.AddText("Consider becoming an ", format); + supportFlow.AddLink("osu!supporter", "https://osu.ppy.sh/home/support", creationParameters: format); + supportFlow.AddText(" to help support the game", format); + } + + heart = supportFlow.AddIcon(FontAwesome.fa_heart, t => + { + t.Padding = new MarginPadding { Left = 5 }; + t.Font = t.Font.With(size: 12); + t.Origin = Anchor.Centre; + t.Colour = colours.Pink; + }).First(); + + if (IsLoaded) + animateHeart(); }, true); } + private void animateHeart() + { + heart.FlashColour(Color4.White, 750, Easing.OutQuint).Loop(); + } + protected override void LoadComplete() { base.LoadComplete(); @@ -128,7 +163,9 @@ namespace osu.Game.Screens.Menu .MoveToY(icon_y, 160, Easing.InCirc) .RotateTo(0, 160, Easing.InCirc); - supporterDrawables.ForEach(d => d.FadeOut().Delay(2000).FadeIn(500)); + supportFlow.FadeOut().Delay(2000).FadeIn(500); + + animateHeart(); this .FadeInFromZero(500) @@ -136,8 +173,6 @@ namespace osu.Game.Screens.Menu .FadeOut(250) .ScaleTo(0.9f, 250, Easing.InQuint) .Finally(d => this.Push(intro)); - - heart.FlashColour(Color4.White, 750, Easing.OutQuint).Loop(); } } } From d2007cfb3813bcdd836a2cb1e5fac518d5d72bda Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 19 Mar 2019 16:10:28 +0900 Subject: [PATCH 2/3] Fix weird transition --- osu.Game/Screens/Menu/Disclaimer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index af8c127a3c..9f0c75f0ad 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -114,7 +114,7 @@ namespace osu.Game.Screens.Menu currentUser.BindTo(api.LocalUser); currentUser.BindValueChanged(e => { - supportFlow.Children.ForEach(d => d.FadeOut(500, Easing.OutQuint).Expire()); + supportFlow.Children.ForEach(d => d.FadeOut().Expire()); if (e.NewValue.IsSupporter) { @@ -137,6 +137,9 @@ namespace osu.Game.Screens.Menu if (IsLoaded) animateHeart(); + + if (supportFlow.IsPresent) + supportFlow.FadeInFromZero(500); }, true); } From e36ad3eb6b8969279076994e01045cb55383485d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 19 Mar 2019 16:11:22 +0900 Subject: [PATCH 3/3] Add initial alpha in case --- osu.Game/Screens/Menu/Disclaimer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 9f0c75f0ad..e6a90f76c0 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -84,6 +84,7 @@ namespace osu.Game.Screens.Menu TextAnchor = Anchor.TopCentre, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, + Alpha = 0, Spacing = new Vector2(0, 2), }, }