1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 05:52:54 +08:00

Kudosu section update

This commit is contained in:
EVAST9919 2019-05-29 21:02:20 +03:00
parent 2d4ef1bec9
commit 97dbc95bc6

View File

@ -3,53 +3,38 @@
using osu.Framework.Bindables;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Users;
using osu.Framework.Allocation;
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,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new[]
{
total = new CountSection(
@ -63,31 +48,29 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
}
}
};
this.user.ValueChanged += u =>
{
total.Count = u.NewValue?.Kudosu.Total ?? 0;
avaliable.Count = u.NewValue?.Kudosu.Available ?? 0;
};
}
protected override bool OnClick(ClickEvent e) => true;
private class CountSection : Container
{
private readonly OsuSpriteText valueText;
private readonly OsuTextFlowContainer descriptionText;
private readonly Box lineBackground;
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 };
Padding = new MarginPadding { Top = 10, Bottom = 20 };
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
@ -96,31 +79,28 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
new FillFlowContainer
new CircularContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
Masking = true,
RelativeSizeAxes = Axes.X,
Height = 5,
Child = lineBackground = new Box
{
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Text = header + ":",
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular, italics: true)
},
valueText = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Text = "0",
Font = OsuFont.GetFont(size: 40, weight: FontWeight.Regular, italics: true),
UseFullGlyphHeight = false,
}
RelativeSizeAxes = Axes.Both,
}
},
new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 19))
new OsuSpriteText
{
Text = header,
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold)
},
valueText = new OsuSpriteText
{
Text = "0",
Font = OsuFont.GetFont(size: 50, weight: FontWeight.Light),
UseFullGlyphHeight = false,
},
descriptionText = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 17))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@ -129,6 +109,13 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
lineBackground.Colour = colours.Yellow;
descriptionText.Colour = colours.GreySeafoamLighter;
}
}
}
}