From ca12fd304220a6e9279e967da63f8109eb10bb6a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 13 Jul 2017 00:13:18 -0300 Subject: [PATCH] Better medal sprite loading, fade in particles, visual test update. --- .../Tests/TestCaseMedalOverlay.cs | 13 +++++--- osu.Game/Overlays/MedalOverlay.cs | 21 +++++++----- .../Overlays/MedalSplash/DrawableMedal.cs | 33 +++---------------- 3 files changed, 25 insertions(+), 42 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs index e00b2beac4..f069f089bf 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs @@ -13,12 +13,15 @@ namespace osu.Desktop.VisualTests.Tests public TestCaseMedalOverlay() { - Add(new MedalOverlay(new Medal + AddStep(@"display", () => { - Name = @"Animations", - InternalName = @"all-intro-doubletime", - Description = @"More complex than you think.", - })); + Add(new MedalOverlay(new Medal + { + Name = @"Animations", + InternalName = @"all-intro-doubletime", + Description = @"More complex than you think.", + })); + }); } } } diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index bb06ec5362..e58dd2aa40 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -32,17 +32,19 @@ namespace osu.Game.Overlays private const float border_width = 5; + private readonly Medal medal; private readonly Box background; private readonly Container backgroundStrip, particleContainer; private readonly BackgroundStrip leftStrip, rightStrip; private readonly CircularContainer disc; private readonly Sprite innerSpin, outterSpin; - private readonly DrawableMedal drawableMedal; + private DrawableMedal drawableMedal; private SampleChannel getSample; public MedalOverlay(Medal medal) { + this.medal = medal; RelativeSizeAxes = Axes.Both; Alpha = 0f; AlwaysPresent = true; @@ -103,6 +105,7 @@ namespace osu.Game.Overlays particleContainer = new Container { RelativeSizeAxes = Axes.Both, + Alpha = 0f, }, disc = new CircularContainer { @@ -137,14 +140,6 @@ namespace osu.Game.Overlays Size = new Vector2(1.05f), Alpha = 0.25f, }, - drawableMedal = new DrawableMedal(medal) - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, - AlwaysPresent = true, - OnSpriteLoadComplete = drawable => Show(), - }, }, }, }; @@ -162,6 +157,13 @@ namespace osu.Game.Overlays Colour = colours.Blue.Opacity(0.5f), Radius = 50, }; + + LoadComponentAsync(drawableMedal = new DrawableMedal(medal) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + }, m => { disc.Add(m); Show(); }); } protected override void Update() @@ -217,6 +219,7 @@ namespace osu.Game.Overlays outterSpin.Transforms.Add(outerRotate); disc.FadeIn(duration1); + particleContainer.FadeIn(duration1); outterSpin.FadeTo(0.1f, duration1 * 2); disc.ScaleTo(1f, duration1 * 2, EasingTypes.OutElastic); diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs index 8d4b567c27..cdc352eff0 100644 --- a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -19,18 +18,17 @@ namespace osu.Game.Overlays.MedalSplash private const float scale_when_unlocked = 0.76f; private const float scale_when_full = 0.6f; + private readonly Medal medal; private readonly Container medalContainer; - private readonly Sprite medalGlow; + private readonly Sprite medalSprite, medalGlow; private readonly OsuSpriteText unlocked, name; private readonly TextFlowContainer description; private readonly FillFlowContainer infoFlow; - public Action OnSpriteLoadComplete; - public DrawableMedal(Medal medal) { + this.medal = medal; Position = new Vector2(0f, MedalOverlay.DISC_SIZE / 2); - AlwaysPresent = true; Children = new Drawable[] { @@ -40,17 +38,12 @@ namespace osu.Game.Overlays.MedalSplash Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, Alpha = 0f, - AlwaysPresent = true, Children = new Drawable[] { - new AsyncLoadWrapper(new MedalSprite(medal) - { - OnLoadComplete = drawable => OnSpriteLoadComplete?.Invoke(drawable), - }) + medalSprite = new Sprite { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, Scale = new Vector2(0.81f), }, medalGlow = new Sprite @@ -115,6 +108,7 @@ namespace osu.Game.Overlays.MedalSplash [BackgroundDependencyLoader] private void load(OsuColour colours, TextureStore textures) { + medalSprite.Texture = textures.Get(medal.ImageUrl); medalGlow.Texture = textures.Get(@"MedalSplash/medal-glow"); description.Colour = colours.BlueLight; @@ -151,22 +145,5 @@ namespace osu.Game.Overlays.MedalSplash MedalUnlocked, Full, } - - private class MedalSprite : Sprite - { - private readonly Medal medal; - - public MedalSprite(Medal medal) - { - this.medal = medal; - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - if (medal?.InternalName != null) - Texture = textures.Get(medal.ImageUrl); - } - } } }