mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 17:07:38 +08:00
Rearrange and adjust header components where simple
This commit is contained in:
parent
e39eb089ce
commit
f80dddbb5e
@ -3,26 +3,18 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
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.Resources.Localisation.Web;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public partial class CentreHeaderContainer : CompositeDrawable
|
||||
{
|
||||
public readonly BindableBool DetailsVisible = new BindableBool(true);
|
||||
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
|
||||
|
||||
private OverlinedInfoContainer hiddenDetailGlobal = null!;
|
||||
private OverlinedInfoContainer hiddenDetailCountry = null!;
|
||||
|
||||
public CentreHeaderContainer()
|
||||
{
|
||||
Height = 60;
|
||||
@ -31,15 +23,12 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Container<Drawable> hiddenDetailContainer;
|
||||
Container<Drawable> expandedDetailContainer;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background4
|
||||
Colour = colourProvider.Background3
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
@ -66,20 +55,6 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
}
|
||||
},
|
||||
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,
|
||||
Origin = Anchor.CentreRight,
|
||||
@ -94,7 +69,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
Size = new Vector2(40),
|
||||
User = { BindTarget = User }
|
||||
},
|
||||
expandedDetailContainer = new Container
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
@ -107,47 +82,9 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
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)"-";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,35 +26,10 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
private OverlinedInfoContainer ppInfo = null!;
|
||||
private OverlinedInfoContainer detailGlobalRank = null!;
|
||||
private OverlinedInfoContainer detailCountryRank = null!;
|
||||
private FillFlowContainer? fillFlow;
|
||||
private RankGraph rankGraph = null!;
|
||||
|
||||
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]
|
||||
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
||||
{
|
||||
@ -69,10 +44,10 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background5,
|
||||
},
|
||||
fillFlow = new FillFlowContainer
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = expanded ? Axes.Y : Axes.None,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
AutoSizeDuration = 200,
|
||||
AutoSizeEasing = Easing.OutQuint,
|
||||
Masking = true,
|
||||
|
@ -39,8 +39,6 @@ namespace osu.Game.Overlays.Profile
|
||||
// Haphazardly guaranteed by OverlayHeader constructor (see CreateBackground / CreateContent).
|
||||
Debug.Assert(centreHeaderContainer != null);
|
||||
Debug.Assert(detailHeaderContainer != null);
|
||||
|
||||
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true);
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() =>
|
||||
@ -75,7 +73,7 @@ namespace osu.Game.Overlays.Profile
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
centreHeaderContainer = new CentreHeaderContainer
|
||||
new MedalHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
@ -85,7 +83,7 @@ namespace osu.Game.Overlays.Profile
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
new MedalHeaderContainer
|
||||
centreHeaderContainer = new CentreHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
|
Loading…
Reference in New Issue
Block a user