1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:13:20 +08:00
osu-lazer/osu.Game/Overlays/Profile/ProfileHeader.cs

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

117 lines
3.9 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
2022-06-17 15:37:17 +08:00
#nullable disable
2019-03-06 15:09:21 +08:00
using osu.Framework.Bindables;
2019-04-04 06:57:15 +08:00
using osu.Framework.Extensions.Color4Extensions;
2019-04-26 12:49:44 +08:00
using osu.Framework.Graphics;
2019-04-04 06:57:15 +08:00
using osu.Framework.Graphics.Colour;
2019-04-26 12:49:44 +08:00
using osu.Framework.Graphics.Containers;
2019-04-04 06:57:15 +08:00
using osu.Framework.Graphics.Shapes;
2021-07-17 20:46:14 +08:00
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
2019-04-26 12:49:44 +08:00
using osu.Game.Overlays.Profile.Header;
2021-07-17 20:46:14 +08:00
using osu.Game.Resources.Localisation.Web;
2019-04-26 12:49:44 +08:00
using osu.Game.Users;
2018-04-13 17:19:50 +08:00
2017-06-16 16:36:23 +08:00
namespace osu.Game.Overlays.Profile
2017-05-25 02:11:07 +08:00
{
public class ProfileHeader : TabControlOverlayHeader<LocalisableString>
2017-05-25 02:11:07 +08:00
{
private UserCoverBackground coverContainer;
2018-12-22 23:51:24 +08:00
public Bindable<APIUser> User = new Bindable<APIUser>();
private CentreHeaderContainer centreHeaderContainer;
private DetailHeaderContainer detailHeaderContainer;
2018-12-25 08:09:49 +08:00
2018-12-22 23:51:24 +08:00
public ProfileHeader()
{
2020-07-22 03:56:44 +08:00
ContentSidePadding = UserProfileOverlay.CONTENT_X_MARGIN;
2020-07-22 01:11:10 +08:00
User.ValueChanged += e => updateDisplay(e.NewValue);
TabControl.AddItem(LayoutStrings.HeaderUsersShow);
// todo: pending implementation.
// TabControl.AddItem(LayoutStrings.HeaderUsersModding);
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true);
}
protected override Drawable CreateBackground() =>
new Container
{
RelativeSizeAxes = Axes.X,
Height = 150,
Masking = true,
Children = new Drawable[]
{
coverContainer = new ProfileCoverBackground
{
RelativeSizeAxes = Axes.Both,
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4Extensions.FromHex("222").Opacity(0.8f), Color4Extensions.FromHex("222").Opacity(0.2f))
},
}
};
2018-04-13 17:19:50 +08:00
2019-12-27 11:36:41 +08:00
protected override Drawable CreateContent() => new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
2017-06-06 11:25:16 +08:00
Children = new Drawable[]
{
new TopHeaderContainer
2017-06-06 11:25:16 +08:00
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
2018-12-22 23:51:24 +08:00
},
centreHeaderContainer = new CentreHeaderContainer
2018-12-22 23:51:24 +08:00
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
},
detailHeaderContainer = new DetailHeaderContainer
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
},
new MedalHeaderContainer
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
},
new BottomHeaderContainer
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
},
}
};
2018-04-13 17:19:50 +08:00
protected override OverlayTitle CreateTitle() => new ProfileHeaderTitle();
2018-12-22 23:51:24 +08:00
private void updateDisplay(APIUser user) => coverContainer.User = user;
2019-05-21 15:05:59 +08:00
private class ProfileHeaderTitle : OverlayTitle
2019-04-04 06:24:42 +08:00
{
public ProfileHeaderTitle()
{
2021-07-17 20:46:14 +08:00
Title = PageTitleStrings.MainUsersControllerDefault;
IconTexture = "Icons/Hexacons/profile";
2019-04-04 06:24:42 +08:00
}
}
private class ProfileCoverBackground : UserCoverBackground
{
protected override double LoadDelay => 0;
}
2017-05-25 02:11:07 +08:00
}
}