2017-03-14 13:58:28 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Users
|
|
|
|
|
{
|
|
|
|
|
public class Avatar : Container
|
|
|
|
|
{
|
2017-03-27 15:04:51 +00:00
|
|
|
|
private readonly User user;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An avatar for specified user.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="user">The user. A null value will get a placeholder avatar.</param>
|
2017-03-28 05:24:21 +00:00
|
|
|
|
public Avatar(User user = null)
|
2017-03-14 13:58:28 +00:00
|
|
|
|
{
|
2017-03-27 15:04:51 +00:00
|
|
|
|
this.user = user;
|
2017-03-15 08:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 05:24:21 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-03-27 15:04:51 +00:00
|
|
|
|
private void load(TextureStore textures)
|
2017-03-15 08:04:50 +00:00
|
|
|
|
{
|
2017-03-28 05:24:21 +00:00
|
|
|
|
Texture texture = null;
|
|
|
|
|
if (user?.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
|
|
|
|
|
if (texture == null) texture = textures.Get(@"Online/avatar-guest");
|
2017-03-15 08:04:50 +00:00
|
|
|
|
|
2017-03-28 05:24:21 +00:00
|
|
|
|
Add(new Sprite
|
2017-03-15 10:07:26 +00:00
|
|
|
|
{
|
2017-03-28 05:24:21 +00:00
|
|
|
|
Texture = texture,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
});
|
2017-03-14 13:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|