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

126 lines
4.6 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-11-20 15:51:59 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
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.Game.Users;
2019-05-30 02:02:20 +08:00
using osu.Framework.Allocation;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
public class KudosuInfo : Container
{
private readonly Bindable<User> user = new Bindable<User>();
2019-05-30 02:19:03 +08:00
2018-04-13 17:19:50 +08:00
public KudosuInfo(Bindable<User> user)
{
this.user.BindTo(user);
CountSection total;
CountSection avaliable;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Masking = true;
CornerRadius = 3;
Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2019-05-30 02:02:20 +08:00
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
2018-04-13 17:19:50 +08:00
Children = new[]
{
total = new CountSection(
"Total Kudosu Earned",
"Based on how much of a contribution the user has made to beatmap moderation. See this link for more information."
),
avaliable = new CountSection(
"Kudosu Avaliable",
"Kudosu can be traded for kudosu stars, which will help your beatmap get more attention. This is the number of kudosu you haven't traded in yet."
),
}
}
};
this.user.ValueChanged += u =>
2018-04-13 17:19:50 +08:00
{
total.Count = u.NewValue?.Kudosu.Total ?? 0;
avaliable.Count = u.NewValue?.Kudosu.Available ?? 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
2018-04-13 17:19:50 +08:00
private class CountSection : Container
{
private readonly OsuSpriteText valueText;
2019-05-30 02:02:20 +08:00
private readonly OsuTextFlowContainer descriptionText;
private readonly Box lineBackground;
2018-04-13 17:19:50 +08:00
public new int Count
{
set => valueText.Text = value.ToString();
2018-04-13 17:19:50 +08:00
}
2019-05-30 02:19:03 +08:00
2018-04-13 17:19:50 +08:00
public CountSection(string header, string description)
{
RelativeSizeAxes = Axes.X;
Width = 0.5f;
AutoSizeAxes = Axes.Y;
2019-05-30 02:02:20 +08:00
Padding = new MarginPadding { Top = 10, Bottom = 20 };
2018-04-13 17:19:50 +08:00
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
2019-05-30 02:02:20 +08:00
new CircularContainer
2018-04-13 17:19:50 +08:00
{
2019-05-30 02:02:20 +08:00
Masking = true,
RelativeSizeAxes = Axes.X,
Height = 5,
Child = lineBackground = new Box
2018-04-13 17:19:50 +08:00
{
2019-05-30 02:02:20 +08:00
RelativeSizeAxes = Axes.Both,
2018-04-13 17:19:50 +08:00
}
},
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
UseFullGlyphHeight = false,
},
2019-05-30 15:49:18 +08:00
descriptionText = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14))
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Text = description
}
}
};
}
2019-05-30 02:02:20 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
lineBackground.Colour = colours.Yellow;
descriptionText.Colour = colours.GreySeafoamLighter;
}
2018-04-13 17:19:50 +08:00
}
}
}