1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00

Use avatar_url from user first instead of a.ppy.sh in DrawableAvatar

This commit is contained in:
ilsubyeega 2021-03-28 03:13:05 +09:00
parent b9b0623c83
commit 34429a02e7

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Online.API;
namespace osu.Game.Users.Drawables
{
@ -13,6 +14,9 @@ namespace osu.Game.Users.Drawables
{
private readonly User user;
[Resolved(CanBeNull=true)]
private IAPIProvider api { get; set; }
/// <summary>
/// A simple, non-interactable avatar sprite for the specified user.
/// </summary>
@ -30,9 +34,11 @@ namespace osu.Game.Users.Drawables
[BackgroundDependencyLoader]
private void load(LargeTextureStore textures)
{
if (user != null && user.Id > 1)
if (api != null && user?.AvatarUrl != null)
Texture = textures.Get(user.AvatarUrl.StartsWith('/') ? $"{api.WebsiteRootUrl}{user.AvatarUrl}" : user.AvatarUrl);
else if (user != null && user.Id > 1)
Texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
Texture ??= textures.Get(@"Online/avatar-guest");
}