1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 02:02:54 +08:00
osu-lazer/osu.Game/Overlays/Profile/Sections/Kudosu/KudosuInfo.cs

91 lines
3.2 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2018-10-02 11:02:47 +08:00
using osu.Framework.Input.Events;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Framework.Extensions.LocalisationExtensions;
2021-07-17 22:29:09 +08:00
using osu.Game.Resources.Localisation.Web;
using osu.Framework.Localisation;
using osu.Game.Online.Chat;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
2022-11-24 13:32:20 +08:00
public partial class KudosuInfo : Container
2018-04-13 17:19:50 +08:00
{
2023-01-11 02:24:54 +08:00
private readonly Bindable<UserProfileData?> user = new Bindable<UserProfileData?>();
2019-05-30 02:19:03 +08:00
2023-01-11 02:24:54 +08:00
public KudosuInfo(Bindable<UserProfileData?> user)
2018-04-13 17:19:50 +08:00
{
2023-01-11 02:24:54 +08:00
this.user.BindTo(user);
2018-04-13 17:19:50 +08:00
CountSection total;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Masking = true;
CornerRadius = 3;
Child = total = new CountTotal();
2023-01-11 02:24:54 +08:00
this.user.ValueChanged += u => total.Count = u.NewValue?.User.Kudosu.Total ?? 0;
2018-04-13 17:19:50 +08:00
}
2019-05-30 02:19:03 +08:00
2018-10-02 11:02:47 +08:00
protected override bool OnClick(ClickEvent e) => true;
2019-05-30 02:19:03 +08:00
2022-11-24 13:32:20 +08:00
private partial class CountTotal : CountSection
2019-05-30 15:57:54 +08:00
{
public CountTotal()
2021-07-17 22:29:09 +08:00
: base(UsersStrings.ShowExtraKudosuTotal)
2019-05-30 15:57:54 +08:00
{
DescriptionText.AddText("Based on how much of a contribution the user has made to beatmap moderation. See ");
DescriptionText.AddLink("this page", LinkAction.OpenWiki, @"Modding/Kudosu");
2019-05-30 15:57:54 +08:00
DescriptionText.AddText(" for more information.");
}
}
2022-11-24 13:32:20 +08:00
private partial class CountSection : Container
2018-04-13 17:19:50 +08:00
{
private readonly OsuSpriteText valueText;
2019-05-30 15:57:54 +08:00
protected readonly LinkFlowContainer DescriptionText;
2018-04-13 17:19:50 +08:00
public new int Count
{
2021-07-24 16:16:47 +08:00
set => valueText.Text = value.ToLocalisableString("N0");
2018-04-13 17:19:50 +08:00
}
2019-05-30 02:19:03 +08:00
protected CountSection(LocalisableString header)
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Bottom = 20 };
2018-04-13 17:19:50 +08:00
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
2019-05-30 02:02:20 +08:00
new OsuSpriteText
{
Text = header,
2019-05-30 15:49:18 +08:00
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold)
2019-05-30 02:02:20 +08:00
},
valueText = new OsuSpriteText
{
Text = "0",
2019-05-30 15:49:18 +08:00
Font = OsuFont.GetFont(size: 40, weight: FontWeight.Light),
2019-05-30 02:02:20 +08:00
},
2019-05-30 15:57:54 +08:00
DescriptionText = new LinkFlowContainer(t => t.Font = t.Font.With(size: 14))
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}
}
};
}
}
}
}