// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Profile.Header; using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Users; namespace osu.Game.Overlays.Profile { public class ProfileHeader : OverlayHeader { private UserCoverBackground coverContainer; private readonly GamemodeControl gamemodeControl; public Bindable User = new Bindable(); private CentreHeaderContainer centreHeaderContainer; private DetailHeaderContainer detailHeaderContainer; public ProfileHeader() { User.ValueChanged += e => updateDisplay(e.NewValue); TabControl.AddItem("Info"); TabControl.AddItem("Modding"); centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true); Add(gamemodeControl = new GamemodeControl { Alpha = 0, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Y = 100, Margin = new MarginPadding { Right = 30 }, }); } [BackgroundDependencyLoader] private void load(OsuColour colours) { TabControl.AccentColour = gamemodeControl.AccentColour = colours.Seafoam; } protected override Drawable CreateBackground() => new Container { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { coverContainer = new UserCoverBackground { RelativeSizeAxes = Axes.Both, }, new Box { RelativeSizeAxes = Axes.Both, Colour = ColourInfo.GradientVertical(OsuColour.FromHex("222").Opacity(0.8f), OsuColour.FromHex("222").Opacity(0.2f)) }, } }; protected override Drawable CreateContent() => new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Children = new Drawable[] { new TopHeaderContainer { RelativeSizeAxes = Axes.X, User = { BindTarget = User }, }, centreHeaderContainer = new CentreHeaderContainer { 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 }, }, } }; protected override ScreenTitle CreateTitle() => new ProfileHeaderTitle(); private void updateDisplay(User user) { coverContainer.User = user; string playMode = user.PlayMode; gamemodeControl.SetDefaultGamemode(playMode); gamemodeControl.FadeInFromZero(100, Easing.OutQuint); } private class ProfileHeaderTitle : ScreenTitle { public ProfileHeaderTitle() { Title = "Player"; Section = "Info"; } [BackgroundDependencyLoader] private void load(OsuColour colours) { AccentColour = colours.Seafoam; } } } }