2017-03-27 23:13:38 +08: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.Graphics;
|
2017-03-27 23:04:51 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Users
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An avatar which can update to a new user when needed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UpdateableAvatar : Container
|
|
|
|
|
{
|
2017-11-23 19:23:47 +08:00
|
|
|
|
private Drawable displayedAvatar;
|
2017-03-27 23:04:51 +08:00
|
|
|
|
|
|
|
|
|
private User user;
|
|
|
|
|
|
|
|
|
|
public User User
|
|
|
|
|
{
|
|
|
|
|
get { return user; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (user?.Id == value?.Id)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
user = value;
|
|
|
|
|
|
|
|
|
|
if (IsLoaded)
|
|
|
|
|
updateAvatar();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
updateAvatar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateAvatar()
|
|
|
|
|
{
|
|
|
|
|
displayedAvatar?.FadeOut(300);
|
|
|
|
|
displayedAvatar?.Expire();
|
2017-11-22 22:46:04 +08:00
|
|
|
|
Add(displayedAvatar = new DelayedLoadWrapper(
|
2017-11-22 02:16:44 +08:00
|
|
|
|
new Avatar(user)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
OnLoadComplete = d => d.FadeInFromZero(200),
|
2017-11-23 19:23:47 +08:00
|
|
|
|
})
|
2017-11-22 02:16:44 +08:00
|
|
|
|
);
|
2017-03-27 23:04:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-30 18:38:26 +08:00
|
|
|
|
}
|