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

136 lines
5.0 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
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
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;
namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
public class KudosuInfo : Container
{
private readonly Bindable<User> user = new Bindable<User>();
public KudosuInfo(Bindable<User> user)
{
this.user.BindTo(user);
CountSection total;
CountSection avaliable;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Masking = true;
CornerRadius = 3;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 3f,
Colour = Color4.Black.Opacity(0.2f),
};
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
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."
),
}
}
};
2019-02-21 17:56:34 +08:00
this.user.ValueChanged += e =>
2018-04-13 17:19:50 +08:00
{
2019-02-21 17:56:34 +08:00
total.Count = e.NewValue?.Kudosu.Total ?? 0;
avaliable.Count = e.NewValue?.Kudosu.Available ?? 0;
2018-04-13 17:19:50 +08:00
};
}
2018-10-02 11:02:47 +08:00
protected override bool OnClick(ClickEvent e) => true;
2018-04-13 17:19:50 +08:00
private class CountSection : Container
{
private readonly OsuSpriteText valueText;
public new int Count
{
set { valueText.Text = value.ToString(); }
}
public CountSection(string header, string description)
{
RelativeSizeAxes = Axes.X;
Width = 0.5f;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Horizontal = 10, Top = 10, Bottom = 20 };
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Text = header + ":",
TextSize = 20,
Font = @"Exo2.0-RegularItalic",
},
valueText = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Text = "0",
TextSize = 40,
UseFullGlyphHeight = false,
Font = @"Exo2.0-RegularItalic"
}
}
},
new OsuTextFlowContainer(t => { t.TextSize = 19; })
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Text = description
}
}
};
}
}
}
}