1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

CoverBackgroundSprite for actually async cover loading

This commit is contained in:
DrabWeb 2017-05-22 12:41:59 -03:00
parent 35814e47e4
commit 261ea4c176

View File

@ -159,22 +159,21 @@ namespace osu.Game.Users
},
};
cover.Add(new AsyncLoadWrapper(new CoverBackgroundSprite(user)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(200),
}) { RelativeSizeAxes = Axes.Both });
Status.ValueChanged += displayStatus;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, TextureStore textures)
private void load(OsuColour colours)
{
this.colours = colours;
cover.Add(new AsyncLoadWrapper(new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = textures.Get(user.CoverUrl),
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(200),
}) { RelativeSizeAxes = Axes.Both });
}
private void displayStatus(UserStatus status)
@ -182,5 +181,22 @@ namespace osu.Game.Users
statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint);
statusMessage.Text = status.Message;
}
private class CoverBackgroundSprite : Sprite
{
private readonly User user;
public CoverBackgroundSprite(User user)
{
this.user = user;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
if (!string.IsNullOrEmpty(user.CoverUrl))
Texture = textures.Get(user.CoverUrl);
}
}
}
}