1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:32:55 +08:00

Merge pull request #11560 from EVAST9919/profile-mapping-subscribers

Add mapping subscribers counter to ProfileOverlay
This commit is contained in:
Dan Balasescu 2021-01-22 14:42:11 +09:00 committed by GitHub
commit a81f4a1ed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 111 additions and 64 deletions

View File

@ -49,9 +49,12 @@ namespace osu.Game.Overlays.Profile.Header
Spacing = new Vector2(10, 0),
Children = new Drawable[]
{
new AddFriendButton
new FollowersButton
{
User = { BindTarget = User }
},
new MappingSubscribersButton
{
RelativeSizeAxes = Axes.Y,
User = { BindTarget = User }
},
new MessageUserButton
@ -69,7 +72,6 @@ namespace osu.Game.Overlays.Profile.Header
Width = UserProfileOverlay.CONTENT_X_MARGIN,
Child = new ExpandDetailsButton
{
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
DetailsVisible = { BindTarget = DetailsVisible }

View File

@ -1,60 +0,0 @@
// 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;
namespace osu.Game.Overlays.Profile.Header.Components
{
public class AddFriendButton : ProfileHeaderButton
{
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)
}
}
};
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
User.BindValueChanged(user => updateFollowers(user.NewValue), true);
}
private void updateFollowers(User user) => followerText.Text = user?.FollowerCount.ToString("#,##0");
}
}

View File

@ -0,0 +1,26 @@
// 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 FollowersButton : ProfileHeaderStatisticsButton
{
public readonly Bindable<User> User = new Bindable<User>();
public override string TooltipText => "followers";
protected override IconUsage Icon => FontAwesome.Solid.User;
[BackgroundDependencyLoader]
private void load()
{
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
User.BindValueChanged(user => SetValue(user.NewValue?.FollowerCount ?? 0), true);
}
}
}

View File

@ -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 Icon => FontAwesome.Solid.Bell;
[BackgroundDependencyLoader]
private void load()
{
User.BindValueChanged(user => SetValue(user.NewValue?.MappingFollowerCount ?? 0), true);
}
}
}

View File

@ -33,7 +33,6 @@ namespace osu.Game.Overlays.Profile.Header.Components
public MessageUserButton()
{
Content.Alpha = 0;
RelativeSizeAxes = Axes.Y;
Child = new SpriteIcon
{

View File

@ -22,6 +22,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
protected ProfileHeaderButton()
{
AutoSizeAxes = Axes.X;
Height = 40;
base.Content.Add(new CircularContainer
{

View File

@ -0,0 +1,51 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
namespace osu.Game.Overlays.Profile.Header.Components
{
public abstract class ProfileHeaderStatisticsButton : ProfileHeaderButton
{
private readonly OsuSpriteText drawableText;
protected ProfileHeaderStatisticsButton()
{
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Icon = Icon,
FillMode = FillMode.Fit,
Size = new Vector2(50, 14)
},
drawableText = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Right = 10 },
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold)
}
}
};
}
protected abstract IconUsage Icon { get; }
protected void SetValue(int value) => drawableText.Text = value.ToString("#,##0");
}
}

View File

@ -126,6 +126,9 @@ namespace osu.Game.Users
[JsonProperty(@"follower_count")]
public int FollowerCount;
[JsonProperty(@"mapping_follower_count")]
public int MappingFollowerCount;
[JsonProperty(@"favourite_beatmapset_count")]
public int FavouriteBeatmapsetCount;