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

Rearrange and adjust header components where simple

This commit is contained in:
Bartłomiej Dach 2022-12-31 17:41:57 +01:00
parent e39eb089ce
commit f80dddbb5e
No known key found for this signature in database
3 changed files with 6 additions and 96 deletions

View File

@ -3,26 +3,18 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Resources.Localisation.Web;
using osuTK; using osuTK;
namespace osu.Game.Overlays.Profile.Header namespace osu.Game.Overlays.Profile.Header
{ {
public partial class CentreHeaderContainer : CompositeDrawable public partial class CentreHeaderContainer : CompositeDrawable
{ {
public readonly BindableBool DetailsVisible = new BindableBool(true);
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>(); public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
private OverlinedInfoContainer hiddenDetailGlobal = null!;
private OverlinedInfoContainer hiddenDetailCountry = null!;
public CentreHeaderContainer() public CentreHeaderContainer()
{ {
Height = 60; Height = 60;
@ -31,15 +23,12 @@ namespace osu.Game.Overlays.Profile.Header
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)
{ {
Container<Drawable> hiddenDetailContainer;
Container<Drawable> expandedDetailContainer;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4 Colour = colourProvider.Background3
}, },
new FillFlowContainer new FillFlowContainer
{ {
@ -66,20 +55,6 @@ namespace osu.Game.Overlays.Profile.Header
} }
}, },
new Container new Container
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
RelativeSizeAxes = Axes.Y,
Padding = new MarginPadding { Vertical = 10 },
Width = UserProfileOverlay.CONTENT_X_MARGIN,
Child = new ExpandDetailsButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
DetailsVisible = { BindTarget = DetailsVisible }
},
},
new Container
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
@ -94,7 +69,7 @@ namespace osu.Game.Overlays.Profile.Header
Size = new Vector2(40), Size = new Vector2(40),
User = { BindTarget = User } User = { BindTarget = User }
}, },
expandedDetailContainer = new Container new Container
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
@ -107,47 +82,9 @@ namespace osu.Game.Overlays.Profile.Header
User = { BindTarget = User } User = { BindTarget = User }
} }
}, },
hiddenDetailContainer = new FillFlowContainer
{
Direction = FillDirection.Horizontal,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Width = 200,
AutoSizeAxes = Axes.Y,
Alpha = 0,
Spacing = new Vector2(10, 0),
Margin = new MarginPadding { Right = 50 },
Children = new[]
{
hiddenDetailGlobal = new OverlinedInfoContainer
{
Title = UsersStrings.ShowRankGlobalSimple,
LineColour = colourProvider.Highlight1
},
hiddenDetailCountry = new OverlinedInfoContainer
{
Title = UsersStrings.ShowRankCountrySimple,
LineColour = colourProvider.Highlight1
},
}
}
} }
} }
}; };
DetailsVisible.BindValueChanged(visible =>
{
hiddenDetailContainer.FadeTo(visible.NewValue ? 0 : 1, 200, Easing.OutQuint);
expandedDetailContainer.FadeTo(visible.NewValue ? 1 : 0, 200, Easing.OutQuint);
});
User.BindValueChanged(user => updateDisplay(user.NewValue?.User));
}
private void updateDisplay(APIUser? user)
{
hiddenDetailGlobal.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
hiddenDetailCountry.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
} }
} }
} }

View File

@ -26,35 +26,10 @@ namespace osu.Game.Overlays.Profile.Header
private OverlinedInfoContainer ppInfo = null!; private OverlinedInfoContainer ppInfo = null!;
private OverlinedInfoContainer detailGlobalRank = null!; private OverlinedInfoContainer detailGlobalRank = null!;
private OverlinedInfoContainer detailCountryRank = null!; private OverlinedInfoContainer detailCountryRank = null!;
private FillFlowContainer? fillFlow;
private RankGraph rankGraph = null!; private RankGraph rankGraph = null!;
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>(); public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
private bool expanded = true;
public bool Expanded
{
set
{
if (expanded == value) return;
expanded = value;
if (fillFlow == null) return;
fillFlow.ClearTransforms();
if (expanded)
fillFlow.AutoSizeAxes = Axes.Y;
else
{
fillFlow.AutoSizeAxes = Axes.None;
fillFlow.ResizeHeightTo(0, 200, Easing.OutQuint);
}
}
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, OsuColour colours) private void load(OverlayColourProvider colourProvider, OsuColour colours)
{ {
@ -69,10 +44,10 @@ namespace osu.Game.Overlays.Profile.Header
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background5, Colour = colourProvider.Background5,
}, },
fillFlow = new FillFlowContainer new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = expanded ? Axes.Y : Axes.None, AutoSizeAxes = Axes.Y,
AutoSizeDuration = 200, AutoSizeDuration = 200,
AutoSizeEasing = Easing.OutQuint, AutoSizeEasing = Easing.OutQuint,
Masking = true, Masking = true,

View File

@ -39,8 +39,6 @@ namespace osu.Game.Overlays.Profile
// Haphazardly guaranteed by OverlayHeader constructor (see CreateBackground / CreateContent). // Haphazardly guaranteed by OverlayHeader constructor (see CreateBackground / CreateContent).
Debug.Assert(centreHeaderContainer != null); Debug.Assert(centreHeaderContainer != null);
Debug.Assert(detailHeaderContainer != null); Debug.Assert(detailHeaderContainer != null);
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true);
} }
protected override Drawable CreateBackground() => protected override Drawable CreateBackground() =>
@ -75,7 +73,7 @@ namespace osu.Game.Overlays.Profile
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
User = { BindTarget = User }, User = { BindTarget = User },
}, },
centreHeaderContainer = new CentreHeaderContainer new MedalHeaderContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
User = { BindTarget = User }, User = { BindTarget = User },
@ -85,7 +83,7 @@ namespace osu.Game.Overlays.Profile
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
User = { BindTarget = User }, User = { BindTarget = User },
}, },
new MedalHeaderContainer centreHeaderContainer = new CentreHeaderContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
User = { BindTarget = User }, User = { BindTarget = User },