1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 06:12:58 +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 osu.Framework.Bindables;
using osuTK; using osuTK;
using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users; using osu.Game.Users;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.Profile.Sections.Kudosu namespace osu.Game.Overlays.Profile.Sections.Kudosu
{ {
public class KudosuInfo : Container public class KudosuInfo : Container
{ {
private readonly Bindable<User> user = new Bindable<User>(); private readonly Bindable<User> user = new Bindable<User>();
public KudosuInfo(Bindable<User> user) public KudosuInfo(Bindable<User> user)
{ {
this.user.BindTo(user); this.user.BindTo(user);
CountSection total; CountSection total;
CountSection avaliable; CountSection avaliable;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
Masking = true; Masking = true;
CornerRadius = 3; CornerRadius = 3;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 3f,
Colour = Color4.Black.Opacity(0.2f),
};
Children = new Drawable[] Children = new Drawable[]
{ {
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
},
new FillFlowContainer new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new[] Children = new[]
{ {
total = new CountSection( total = new CountSection(
@ -63,31 +48,29 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
} }
} }
}; };
this.user.ValueChanged += u => this.user.ValueChanged += u =>
{ {
total.Count = u.NewValue?.Kudosu.Total ?? 0; total.Count = u.NewValue?.Kudosu.Total ?? 0;
avaliable.Count = u.NewValue?.Kudosu.Available ?? 0; avaliable.Count = u.NewValue?.Kudosu.Available ?? 0;
}; };
} }
protected override bool OnClick(ClickEvent e) => true; protected override bool OnClick(ClickEvent e) => true;
private class CountSection : Container private class CountSection : Container
{ {
private readonly OsuSpriteText valueText; private readonly OsuSpriteText valueText;
private readonly OsuTextFlowContainer descriptionText;
private readonly Box lineBackground;
public new int Count public new int Count
{ {
set => valueText.Text = value.ToString(); set => valueText.Text = value.ToString();
} }
public CountSection(string header, string description) public CountSection(string header, string description)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Width = 0.5f; Width = 0.5f;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Horizontal = 10, Top = 10, Bottom = 20 }; Padding = new MarginPadding { Top = 10, Bottom = 20 };
Child = new FillFlowContainer Child = new FillFlowContainer
{ {
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
@ -96,31 +79,28 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
Spacing = new Vector2(0, 5), Spacing = new Vector2(0, 5),
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer new CircularContainer
{ {
AutoSizeAxes = Axes.Both, Masking = true,
Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X,
Spacing = new Vector2(5, 0), Height = 5,
Children = new Drawable[] Child = lineBackground = new Box
{ {
RelativeSizeAxes = Axes.Both,
}
},
new OsuSpriteText new OsuSpriteText
{ {
Anchor = Anchor.BottomLeft, Text = header,
Origin = Anchor.BottomLeft, Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold)
Text = header + ":",
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular, italics: true)
}, },
valueText = new OsuSpriteText valueText = new OsuSpriteText
{ {
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Text = "0", Text = "0",
Font = OsuFont.GetFont(size: 40, weight: FontWeight.Regular, italics: true), Font = OsuFont.GetFont(size: 50, weight: FontWeight.Light),
UseFullGlyphHeight = false, UseFullGlyphHeight = false,
}
}
}, },
new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 19)) descriptionText = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 17))
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, 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;
}
} }
} }
} }