mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Async medal sprite loading.
This commit is contained in:
@ -56,6 +56,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Alpha = 0f;
|
Alpha = 0f;
|
||||||
|
AlwaysPresent = true;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -120,6 +121,7 @@ namespace osu.Game.Overlays
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Alpha = 0f,
|
Alpha = 0f,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
|
AlwaysPresent = true,
|
||||||
BorderColour = Color4.White,
|
BorderColour = Color4.White,
|
||||||
BorderThickness = border_width,
|
BorderThickness = border_width,
|
||||||
Size = new Vector2(DISC_SIZE),
|
Size = new Vector2(DISC_SIZE),
|
||||||
@ -151,6 +153,8 @@ namespace osu.Game.Overlays
|
|||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AlwaysPresent = true,
|
||||||
|
OnSpriteLoadComplete = drawable => Show(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -171,12 +175,6 @@ namespace osu.Game.Overlays
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -247,6 +245,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
if (drawableMedal.Transforms.Count != 0) return;
|
if (drawableMedal.Transforms.Count != 0) return;
|
||||||
Hide();
|
Hide();
|
||||||
|
Expire();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BackgroundStrip : Container
|
private class BackgroundStrip : Container
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// 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 System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -21,16 +22,19 @@ namespace osu.Game.Overlays.MedalSplash
|
|||||||
|
|
||||||
private readonly Medal medal;
|
private readonly Medal medal;
|
||||||
private readonly Container medalContainer;
|
private readonly Container medalContainer;
|
||||||
private readonly Sprite medalGlow, medalSprite;
|
private readonly Sprite 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;
|
||||||
private readonly IEnumerable<SpriteText> descriptionSprites;
|
private readonly IEnumerable<SpriteText> descriptionSprites;
|
||||||
|
|
||||||
|
public Action<Drawable> OnSpriteLoadComplete;
|
||||||
|
|
||||||
public DrawableMedal(Medal medal)
|
public DrawableMedal(Medal medal)
|
||||||
{
|
{
|
||||||
this.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,12 +44,17 @@ namespace osu.Game.Overlays.MedalSplash
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Alpha = 0f,
|
Alpha = 0f,
|
||||||
Children = new[]
|
AlwaysPresent = true,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
medalSprite = new Sprite
|
new AsyncLoadWrapper(new MedalSprite(medal)
|
||||||
|
{
|
||||||
|
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
|
||||||
@ -110,7 +119,6 @@ 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");
|
||||||
|
|
||||||
foreach (var s in descriptionSprites)
|
foreach (var s in descriptionSprites)
|
||||||
@ -149,5 +157,22 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user