mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 16:27:26 +08:00
Implement MappingSubscribersButton component
This commit is contained in:
parent
966440f109
commit
a7c22ebe88
@ -49,9 +49,12 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
Spacing = new Vector2(10, 0),
|
Spacing = new Vector2(10, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new AddFriendButton
|
new FriendsButton
|
||||||
|
{
|
||||||
|
User = { BindTarget = User }
|
||||||
|
},
|
||||||
|
new MappingSubscribersButton
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
User = { BindTarget = User }
|
User = { BindTarget = User }
|
||||||
},
|
},
|
||||||
new MessageUserButton
|
new MessageUserButton
|
||||||
|
@ -8,7 +8,7 @@ using osu.Game.Users;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header.Components
|
namespace osu.Game.Overlays.Profile.Header.Components
|
||||||
{
|
{
|
||||||
public class AddFriendButton : ProfileHeaderStatisticsButton
|
public class FriendsButton : ProfileHeaderStatisticsButton
|
||||||
{
|
{
|
||||||
public readonly Bindable<User> User = new Bindable<User>();
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
@ -20,9 +20,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
|
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
|
||||||
User.BindValueChanged(user => updateFollowers(user.NewValue), true);
|
User.BindValueChanged(user => SetValue(user.NewValue?.FollowerCount ?? 0), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFollowers(User user) => SetValue(user?.FollowerCount.ToString("#,##0"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
// 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.Sprites;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Header.Components
|
||||||
|
{
|
||||||
|
public class MappingSubscribersButton : ProfileHeaderStatisticsButton
|
||||||
|
{
|
||||||
|
public readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
|
public override string TooltipText => "mapping subscribers";
|
||||||
|
|
||||||
|
protected override IconUsage CreateIcon() => FontAwesome.Solid.Bell;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
User.BindValueChanged(user => SetValue(user.NewValue?.MappingFollowerCount ?? 0), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
@ -17,13 +16,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
|
|
||||||
protected ProfileHeaderStatisticsButton()
|
protected ProfileHeaderStatisticsButton()
|
||||||
{
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
Child = new FillFlowContainer
|
Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.X,
|
||||||
Anchor = Anchor.CentreLeft,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Origin = Anchor.CentreLeft,
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Padding = new MarginPadding { Right = 10 },
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SpriteIcon
|
new SpriteIcon
|
||||||
@ -38,15 +38,15 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
|
Margin = new MarginPadding { Right = 10 },
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotNull]
|
|
||||||
protected abstract IconUsage CreateIcon();
|
protected abstract IconUsage CreateIcon();
|
||||||
|
|
||||||
protected void SetValue(string value) => drawableText.Text = value;
|
protected void SetValue(int value) => drawableText.Text = value.ToString("#,##0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user