1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 03:22:55 +08:00

Move user cover lower down

This commit is contained in:
Bartłomiej Dach 2022-12-31 19:36:17 +01:00
parent edb9c76edf
commit ff22a91d52
No known key found for this signature in database
2 changed files with 99 additions and 101 deletions

View File

@ -14,6 +14,7 @@ using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Users;
using osu.Game.Users.Drawables; using osu.Game.Users.Drawables;
using osuTK; using osuTK;
@ -28,6 +29,7 @@ namespace osu.Game.Overlays.Profile.Header
[Resolved] [Resolved]
private IAPIProvider api { get; set; } = null!; private IAPIProvider api { get; set; } = null!;
private UserCoverBackground cover = null!;
private SupporterIcon supporterTag = null!; private SupporterIcon supporterTag = null!;
private UpdateableAvatar avatar = null!; private UpdateableAvatar avatar = null!;
private OsuSpriteText usernameText = null!; private OsuSpriteText usernameText = null!;
@ -40,7 +42,8 @@ namespace osu.Game.Overlays.Profile.Header
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)
{ {
Height = 150; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
@ -51,52 +54,73 @@ namespace osu.Game.Overlays.Profile.Header
}, },
new FillFlowContainer new FillFlowContainer
{ {
Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X,
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }, AutoSizeAxes = Axes.Y,
Height = avatar_size, Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.X,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Drawable[] Children = new Drawable[]
{ {
avatar = new UpdateableAvatar(isInteractive: false, showGuestOnNull: false) cover = new ProfileCoverBackground
{ {
Size = new Vector2(avatar_size), RelativeSizeAxes = Axes.X,
Masking = true, Height = 250,
CornerRadius = avatar_size * 0.25f,
}, },
new OsuContextMenuContainer new FillFlowContainer
{ {
RelativeSizeAxes = Axes.Y, Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.X, Margin = new MarginPadding
Child = new Container
{ {
RelativeSizeAxes = Axes.Y, Left = UserProfileOverlay.CONTENT_X_MARGIN,
AutoSizeAxes = Axes.X, Vertical = 10
Padding = new MarginPadding { Left = 10 }, },
Children = new Drawable[] Height = avatar_size,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
avatar = new UpdateableAvatar(isInteractive: false, showGuestOnNull: false)
{ {
new FillFlowContainer Size = new Vector2(avatar_size),
Masking = true,
CornerRadius = avatar_size * 0.25f,
},
new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Child = new Container
{ {
AutoSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, AutoSizeAxes = Axes.X,
Padding = new MarginPadding { Left = 10 },
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Vertical,
Spacing = new Vector2(5),
Children = new Drawable[] Children = new Drawable[]
{ {
usernameText = new OsuSpriteText new FillFlowContainer
{ {
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Regular) AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
usernameText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Regular)
},
openUserExternally = new ExternalLinkButton
{
Margin = new MarginPadding { Left = 5 },
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
}
}, },
openUserExternally = new ExternalLinkButton titleText = new OsuSpriteText
{ {
Anchor = Anchor.CentreLeft, Font = OsuFont.GetFont(size: 18, weight: FontWeight.Regular)
Origin = Anchor.CentreLeft,
}, },
groupBadgeFlow = new GroupBadgeFlow groupBadgeFlow = new GroupBadgeFlow
{ {
@ -105,54 +129,50 @@ namespace osu.Game.Overlays.Profile.Header
} }
} }
}, },
titleText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Regular)
},
}
},
new FillFlowContainer
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
supporterTag = new SupporterIcon
{
Height = 20,
Margin = new MarginPadding { Top = 5 }
},
new Box
{
RelativeSizeAxes = Axes.X,
Height = 1.5f,
Margin = new MarginPadding { Top = 10 },
Colour = colourProvider.Light1,
},
new FillFlowContainer new FillFlowContainer
{ {
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 5 },
Direction = FillDirection.Horizontal,
Children = new Drawable[] Children = new Drawable[]
{ {
userFlag = new UpdateableFlag supporterTag = new SupporterIcon
{ {
Size = new Vector2(28, 20), Height = 20,
ShowPlaceholderOnUnknown = false, Margin = new MarginPadding { Top = 5 }
}, },
userCountryText = new OsuSpriteText new Box
{ {
Font = OsuFont.GetFont(size: 17.5f, weight: FontWeight.Regular), RelativeSizeAxes = Axes.X,
Margin = new MarginPadding { Left = 10 }, Height = 1.5f,
Origin = Anchor.CentreLeft, Margin = new MarginPadding { Top = 10 },
Anchor = Anchor.CentreLeft,
Colour = colourProvider.Light1, Colour = colourProvider.Light1,
} },
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 5 },
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
userFlag = new UpdateableFlag
{
Size = new Vector2(28, 20),
ShowPlaceholderOnUnknown = false,
},
userCountryText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 17.5f, weight: FontWeight.Regular),
Margin = new MarginPadding { Left = 10 },
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Colour = colourProvider.Light1,
}
}
},
} }
}, }
} }
} }
} }
@ -169,6 +189,7 @@ namespace osu.Game.Overlays.Profile.Header
{ {
var user = data?.User; var user = data?.User;
cover.User = user;
avatar.User = user; avatar.User = user;
usernameText.Text = user?.Username ?? string.Empty; usernameText.Text = user?.Username ?? string.Empty;
openUserExternally.Link = $@"{api.WebsiteRootUrl}/users/{user?.Id ?? 0}"; openUserExternally.Link = $@"{api.WebsiteRootUrl}/users/{user?.Id ?? 0}";
@ -179,5 +200,15 @@ namespace osu.Game.Overlays.Profile.Header
titleText.Colour = Color4Extensions.FromHex(user?.Colour ?? "fff"); titleText.Colour = Color4Extensions.FromHex(user?.Colour ?? "fff");
groupBadgeFlow.User.Value = user; groupBadgeFlow.User.Value = user;
} }
private partial class ProfileCoverBackground : UserCoverBackground
{
protected override double LoadDelay => 0;
public ProfileCoverBackground()
{
Masking = true;
}
}
} }
} }

View File

@ -3,23 +3,17 @@
using System.Diagnostics; using System.Diagnostics;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Overlays.Profile.Header; using osu.Game.Overlays.Profile.Header;
using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;
namespace osu.Game.Overlays.Profile namespace osu.Game.Overlays.Profile
{ {
public partial class ProfileHeader : TabControlOverlayHeader<LocalisableString> public partial class ProfileHeader : TabControlOverlayHeader<LocalisableString>
{ {
private UserCoverBackground coverContainer = null!;
public Bindable<UserProfileData?> User = new Bindable<UserProfileData?>(); public Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
private CentreHeaderContainer centreHeaderContainer; private CentreHeaderContainer centreHeaderContainer;
@ -29,8 +23,6 @@ namespace osu.Game.Overlays.Profile
{ {
ContentSidePadding = UserProfileOverlay.CONTENT_X_MARGIN; ContentSidePadding = UserProfileOverlay.CONTENT_X_MARGIN;
User.ValueChanged += e => updateDisplay(e.NewValue);
TabControl.AddItem(LayoutStrings.HeaderUsersShow); TabControl.AddItem(LayoutStrings.HeaderUsersShow);
// todo: pending implementation. // todo: pending implementation.
@ -41,25 +33,7 @@ namespace osu.Game.Overlays.Profile
Debug.Assert(detailHeaderContainer != null); Debug.Assert(detailHeaderContainer != null);
} }
protected override Drawable CreateBackground() => protected override Drawable CreateBackground() => Empty();
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))
},
}
};
protected override Drawable CreateContent() => new FillFlowContainer protected override Drawable CreateContent() => new FillFlowContainer
{ {
@ -103,8 +77,6 @@ namespace osu.Game.Overlays.Profile
User = { BindTarget = User } User = { BindTarget = User }
}; };
private void updateDisplay(UserProfileData? user) => coverContainer.User = user?.User;
private partial class ProfileHeaderTitle : OverlayTitle private partial class ProfileHeaderTitle : OverlayTitle
{ {
public ProfileHeaderTitle() public ProfileHeaderTitle()
@ -113,10 +85,5 @@ namespace osu.Game.Overlays.Profile
IconTexture = "Icons/Hexacons/profile"; IconTexture = "Icons/Hexacons/profile";
} }
} }
private partial class ProfileCoverBackground : UserCoverBackground
{
protected override double LoadDelay => 0;
}
} }
} }