mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Bring back DrawableAvatar as a simple sprite
This commit is contained in:
39
osu.Game/Users/Drawables/DrawableAvatar.cs
Normal file
39
osu.Game/Users/Drawables/DrawableAvatar.cs
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
|
||||
namespace osu.Game.Users.Drawables
|
||||
{
|
||||
[LongRunningLoad]
|
||||
public class DrawableAvatar : Sprite
|
||||
{
|
||||
private readonly User user;
|
||||
|
||||
/// <summary>
|
||||
/// A simple, non-interactable avatar sprite for the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The user. A null value will get a placeholder avatar.</param>
|
||||
public DrawableAvatar(User user = null)
|
||||
{
|
||||
this.user = user;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
FillMode = FillMode.Fit;
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LargeTextureStore textures)
|
||||
{
|
||||
if (user != null && user.Id > 1)
|
||||
Texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
|
||||
|
||||
Texture ??= textures.Get(@"Online/avatar-guest");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user