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

Make avatar fallback work on failed load.

This commit is contained in:
Dean Herbert 2017-03-22 09:20:37 +09:00
parent f3486b7288
commit bee7b43a37
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49

View File

@ -52,7 +52,7 @@ namespace osu.Game.Users
{
if (loadTask != null || Sprite != null) return;
var newSprite = userId > 1 ? new OnlineSprite($@"https://a.ppy.sh/{userId}") : new Sprite { Texture = guestTexture };
var newSprite = userId > 1 ? new OnlineSprite($@"https://a.ppy.sh/{userId}", guestTexture) : new Sprite { Texture = guestTexture };
newSprite.FillMode = FillMode.Fill;
@ -95,17 +95,19 @@ namespace osu.Game.Users
public class OnlineSprite : Sprite
{
private readonly string url;
private readonly Texture fallbackTexture;
public OnlineSprite(string url)
public OnlineSprite(string url, Texture fallbackTexture = null)
{
Debug.Assert(url != null);
this.url = url;
this.fallbackTexture = fallbackTexture;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(url);
Texture = textures.Get(url) ?? fallbackTexture;
}
}
}