1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 16:52:55 +08:00

Better medal sprite loading, fade in particles, visual test update.

This commit is contained in:
DrabWeb 2017-07-13 00:13:18 -03:00
parent 204d2ee43d
commit ca12fd3042
3 changed files with 25 additions and 42 deletions

View File

@ -12,6 +12,8 @@ namespace osu.Desktop.VisualTests.Tests
public override string Description => @"medal get!"; public override string Description => @"medal get!";
public TestCaseMedalOverlay() public TestCaseMedalOverlay()
{
AddStep(@"display", () =>
{ {
Add(new MedalOverlay(new Medal Add(new MedalOverlay(new Medal
{ {
@ -19,6 +21,7 @@ namespace osu.Desktop.VisualTests.Tests
InternalName = @"all-intro-doubletime", InternalName = @"all-intro-doubletime",
Description = @"More complex than you think.", Description = @"More complex than you think.",
})); }));
});
} }
} }
} }

View File

@ -32,17 +32,19 @@ namespace osu.Game.Overlays
private const float border_width = 5; private const float border_width = 5;
private readonly Medal medal;
private readonly Box background; private readonly Box background;
private readonly Container backgroundStrip, particleContainer; private readonly Container backgroundStrip, particleContainer;
private readonly BackgroundStrip leftStrip, rightStrip; private readonly BackgroundStrip leftStrip, rightStrip;
private readonly CircularContainer disc; private readonly CircularContainer disc;
private readonly Sprite innerSpin, outterSpin; private readonly Sprite innerSpin, outterSpin;
private readonly DrawableMedal drawableMedal; private DrawableMedal drawableMedal;
private SampleChannel getSample; private SampleChannel getSample;
public MedalOverlay(Medal medal) public MedalOverlay(Medal medal)
{ {
this.medal = medal;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Alpha = 0f; Alpha = 0f;
AlwaysPresent = true; AlwaysPresent = true;
@ -103,6 +105,7 @@ namespace osu.Game.Overlays
particleContainer = new Container particleContainer = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 0f,
}, },
disc = new CircularContainer disc = new CircularContainer
{ {
@ -137,14 +140,6 @@ namespace osu.Game.Overlays
Size = new Vector2(1.05f), Size = new Vector2(1.05f),
Alpha = 0.25f, 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), Colour = colours.Blue.Opacity(0.5f),
Radius = 50, 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() protected override void Update()
@ -217,6 +219,7 @@ namespace osu.Game.Overlays
outterSpin.Transforms.Add(outerRotate); outterSpin.Transforms.Add(outerRotate);
disc.FadeIn(duration1); disc.FadeIn(duration1);
particleContainer.FadeIn(duration1);
outterSpin.FadeTo(0.1f, duration1 * 2); outterSpin.FadeTo(0.1f, duration1 * 2);
disc.ScaleTo(1f, duration1 * 2, EasingTypes.OutElastic); disc.ScaleTo(1f, duration1 * 2, EasingTypes.OutElastic);

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK; using OpenTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; 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_unlocked = 0.76f;
private const float scale_when_full = 0.6f; private const float scale_when_full = 0.6f;
private readonly Medal medal;
private readonly Container medalContainer; private readonly Container medalContainer;
private readonly Sprite medalGlow; private readonly Sprite medalSprite, medalGlow;
private readonly OsuSpriteText unlocked, name; private readonly OsuSpriteText unlocked, name;
private readonly TextFlowContainer description; private readonly TextFlowContainer description;
private readonly FillFlowContainer infoFlow; private readonly FillFlowContainer infoFlow;
public Action<Drawable> OnSpriteLoadComplete;
public DrawableMedal(Medal medal) public DrawableMedal(Medal medal)
{ {
this.medal = medal;
Position = new Vector2(0f, MedalOverlay.DISC_SIZE / 2); Position = new Vector2(0f, MedalOverlay.DISC_SIZE / 2);
AlwaysPresent = true;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -40,17 +38,12 @@ namespace osu.Game.Overlays.MedalSplash
Origin = Anchor.Centre, Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Alpha = 0f, Alpha = 0f,
AlwaysPresent = true,
Children = new Drawable[] Children = new Drawable[]
{ {
new AsyncLoadWrapper(new MedalSprite(medal) medalSprite = new Sprite
{
OnLoadComplete = drawable => OnSpriteLoadComplete?.Invoke(drawable),
})
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.81f), Scale = new Vector2(0.81f),
}, },
medalGlow = new Sprite medalGlow = new Sprite
@ -115,6 +108,7 @@ namespace osu.Game.Overlays.MedalSplash
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, TextureStore textures) private void load(OsuColour colours, TextureStore textures)
{ {
medalSprite.Texture = textures.Get(medal.ImageUrl);
medalGlow.Texture = textures.Get(@"MedalSplash/medal-glow"); medalGlow.Texture = textures.Get(@"MedalSplash/medal-glow");
description.Colour = colours.BlueLight; description.Colour = colours.BlueLight;
@ -151,22 +145,5 @@ namespace osu.Game.Overlays.MedalSplash
MedalUnlocked, MedalUnlocked,
Full, 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);
}
}
} }
} }