2019-04-26 12:29:58 +08:00
|
|
|
// 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.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Users;
|
|
|
|
using osuTK;
|
|
|
|
|
2019-04-26 12:49:44 +08:00
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
2019-04-26 12:29:58 +08:00
|
|
|
{
|
2019-04-26 12:49:44 +08:00
|
|
|
public class AddFriendButton : ProfileHeaderButton
|
2019-04-26 12:29:58 +08:00
|
|
|
{
|
|
|
|
public readonly Bindable<User> User = new Bindable<User>();
|
|
|
|
|
|
|
|
public override string TooltipText => "friends";
|
|
|
|
|
|
|
|
private OsuSpriteText followerText;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Padding = new MarginPadding { Right = 10 },
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new SpriteIcon
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Icon = FontAwesome.Solid.User,
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
Size = new Vector2(50, 14)
|
|
|
|
},
|
|
|
|
followerText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-17 18:33:49 +08:00
|
|
|
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
|
|
|
|
|
2019-04-26 12:29:58 +08:00
|
|
|
User.BindValueChanged(user => updateFollowers(user.NewValue), true);
|
|
|
|
}
|
|
|
|
|
2019-07-18 13:05:57 +08:00
|
|
|
private void updateFollowers(User user) => followerText.Text = user?.FollowerCount.ToString("#,##0");
|
2019-04-26 12:29:58 +08:00
|
|
|
}
|
|
|
|
}
|