osu/osu.Game/Users/UpdateableAvatar.cs

50 lines
1.3 KiB
C#
Raw Normal View History

2017-03-27 15:13:38 +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.Graphics;
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-03-28 05:24:21 +00:00
private Container displayedAvatar;
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-04-02 07:17:13 +00:00
Add(displayedAvatar = new AsyncLoadWrapper(new Avatar(user)
2017-03-28 05:24:21 +00:00
{
RelativeSizeAxes = Axes.Both,
2017-04-02 06:56:12 +00:00
OnLoadComplete = d => d.FadeInFromZero(200),
}));
}
}
}