2019-01-28 06:45:00 +08:00
|
|
|
|
// 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.
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-06 15:09:21 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2021-08-29 20:00:28 +08:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-07-24 05:12:22 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2019-04-26 12:49:44 +08:00
|
|
|
|
using osu.Game.Overlays.Profile.Header.Components;
|
2021-07-17 21:27:40 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Header
|
|
|
|
|
{
|
2019-04-25 17:43:29 +08:00
|
|
|
|
public partial class CentreHeaderContainer : CompositeDrawable
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-04-25 19:05:59 +08:00
|
|
|
|
public readonly BindableBool DetailsVisible = new BindableBool(true);
|
2023-01-11 02:24:54 +08:00
|
|
|
|
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2022-12-30 20:17:59 +08:00
|
|
|
|
private OverlinedInfoContainer hiddenDetailGlobal = null!;
|
|
|
|
|
private OverlinedInfoContainer hiddenDetailCountry = null!;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2019-04-25 19:05:59 +08:00
|
|
|
|
public CentreHeaderContainer()
|
|
|
|
|
{
|
|
|
|
|
Height = 60;
|
|
|
|
|
}
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 08:06:39 +08:00
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-04-25 19:05:59 +08:00
|
|
|
|
Container<Drawable> hiddenDetailContainer;
|
|
|
|
|
Container<Drawable> expandedDetailContainer;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2019-03-10 06:58:14 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-01-30 04:55:41 +08:00
|
|
|
|
Colour = colourProvider.Background4
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Padding = new MarginPadding { Vertical = 10 },
|
|
|
|
|
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
|
|
|
|
|
Spacing = new Vector2(10, 0),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-01-22 04:40:23 +08:00
|
|
|
|
new FollowersButton
|
2021-01-22 03:02:54 +08:00
|
|
|
|
{
|
2023-01-11 02:24:54 +08:00
|
|
|
|
User = { BindTarget = User }
|
2021-01-22 03:02:54 +08:00
|
|
|
|
},
|
|
|
|
|
new MappingSubscribersButton
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2023-01-11 02:24:54 +08:00
|
|
|
|
User = { BindTarget = User }
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
2019-04-26 12:49:44 +08:00
|
|
|
|
new MessageUserButton
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2023-01-11 02:24:54 +08:00
|
|
|
|
User = { BindTarget = User }
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Padding = new MarginPadding { Vertical = 10 },
|
|
|
|
|
Width = UserProfileOverlay.CONTENT_X_MARGIN,
|
2019-04-26 12:29:58 +08:00
|
|
|
|
Child = new ExpandDetailsButton
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-04-26 12:29:58 +08:00
|
|
|
|
DetailsVisible = { BindTarget = DetailsVisible }
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-04-25 19:30:16 +08:00
|
|
|
|
new LevelBadge
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Size = new Vector2(40),
|
2023-01-11 02:24:54 +08:00
|
|
|
|
User = { BindTarget = User }
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
2019-04-25 19:30:16 +08:00
|
|
|
|
expandedDetailContainer = new Container
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Width = 200,
|
|
|
|
|
Height = 6,
|
|
|
|
|
Margin = new MarginPadding { Right = 50 },
|
2019-04-25 19:30:16 +08:00
|
|
|
|
Child = new LevelProgressBar
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-04-25 19:30:16 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2023-01-11 02:24:54 +08:00
|
|
|
|
User = { BindTarget = User }
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
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[]
|
|
|
|
|
{
|
2019-03-10 06:58:14 +08:00
|
|
|
|
hiddenDetailGlobal = new OverlinedInfoContainer
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-07-17 21:27:40 +08:00
|
|
|
|
Title = UsersStrings.ShowRankGlobalSimple,
|
2020-01-30 04:55:41 +08:00
|
|
|
|
LineColour = colourProvider.Highlight1
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
2019-03-10 06:58:14 +08:00
|
|
|
|
hiddenDetailCountry = new OverlinedInfoContainer
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-07-17 21:27:40 +08:00
|
|
|
|
Title = UsersStrings.ShowRankCountrySimple,
|
2020-01-30 04:55:41 +08:00
|
|
|
|
LineColour = colourProvider.Highlight1
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-04-25 19:05:59 +08:00
|
|
|
|
DetailsVisible.BindValueChanged(visible =>
|
2019-03-06 15:09:21 +08:00
|
|
|
|
{
|
2019-05-04 10:01:12 +08:00
|
|
|
|
hiddenDetailContainer.FadeTo(visible.NewValue ? 0 : 1, 200, Easing.OutQuint);
|
|
|
|
|
expandedDetailContainer.FadeTo(visible.NewValue ? 1 : 0, 200, Easing.OutQuint);
|
|
|
|
|
});
|
2019-04-25 19:05:59 +08:00
|
|
|
|
|
2023-01-11 02:24:54 +08:00
|
|
|
|
User.BindValueChanged(user => updateDisplay(user.NewValue?.User));
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-30 20:17:59 +08:00
|
|
|
|
private void updateDisplay(APIUser? user)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-07-25 03:32:26 +08:00
|
|
|
|
hiddenDetailGlobal.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
|
|
|
|
hiddenDetailCountry.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|