1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-30 04:07:25 +08:00
osu-lazer/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
3.6 KiB
C#
Raw Normal View History

2019-01-28 06:45:00 +08:00
// 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.
using osu.Framework.Allocation;
2019-03-06 15:09:21 +08:00
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Online.API.Requests.Responses;
2019-04-26 12:49:44 +08:00
using osu.Game.Overlays.Profile.Header.Components;
using osuTK;
namespace osu.Game.Overlays.Profile.Header
{
2019-04-25 17:43:29 +08:00
public partial class CentreHeaderContainer : CompositeDrawable
{
2023-01-11 02:24:54 +08:00
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
private LevelBadge levelBadge = null!;
2019-04-25 19:05:59 +08:00
public CentreHeaderContainer()
{
Height = 60;
}
[BackgroundDependencyLoader]
2022-01-15 08:06:39 +08:00
private void load(OverlayColourProvider colourProvider)
{
2019-03-10 06:58:14 +08:00
InternalChildren = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background3
},
new FillFlowContainer
{
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Padding = new MarginPadding { Vertical = 10 },
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
Spacing = new Vector2(10, 0),
Children = new Drawable[]
{
new FollowersButton
{
2023-01-11 02:24:54 +08:00
User = { BindTarget = User }
},
new MappingSubscribersButton
{
2023-01-11 02:24:54 +08:00
User = { BindTarget = User }
},
2019-04-26 12:49:44 +08:00
new MessageUserButton
{
2023-01-11 02:24:54 +08:00
User = { BindTarget = User }
},
}
},
new Container
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
Children = new Drawable[]
{
levelBadge = new LevelBadge
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Size = new Vector2(40)
},
new Container
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Width = 200,
Height = 6,
Margin = new MarginPadding { Right = 50 },
Child = new LevelProgressBar
{
RelativeSizeAxes = Axes.Both,
2023-01-11 02:24:54 +08:00
User = { BindTarget = User }
}
},
}
}
};
2023-01-17 04:47:31 +08:00
}
protected override void LoadComplete()
{
base.LoadComplete();
2023-01-17 04:47:31 +08:00
User.BindValueChanged(user => updateDisplay(user.NewValue?.User), true);
}
private void updateDisplay(APIUser? user)
{
levelBadge.LevelInfo.Value = user?.Statistics?.Level;
}
}
}