1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 14:02:54 +08:00
osu-lazer/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs

151 lines
6.0 KiB
C#
Raw Normal View History

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.
using osu.Framework.Allocation;
2019-03-06 15:09:21 +08:00
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
2019-04-26 12:49:44 +08:00
using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Overlays.Profile.Header
{
2019-04-25 17:43:29 +08:00
public class CentreHeaderContainer : CompositeDrawable
{
2019-04-25 19:05:59 +08:00
public readonly BindableBool DetailsVisible = new BindableBool(true);
public readonly Bindable<User> User = new Bindable<User>();
2019-04-25 19:05:59 +08:00
private OverlinedInfoContainer hiddenDetailGlobal;
private OverlinedInfoContainer hiddenDetailCountry;
2019-04-25 19:05:59 +08:00
public CentreHeaderContainer()
{
Height = 60;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, TextureStore textures)
{
2019-04-25 19:05:59 +08:00
Container<Drawable> hiddenDetailContainer;
Container<Drawable> expandedDetailContainer;
2019-03-10 06:58:14 +08:00
InternalChildren = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
2019-05-20 14:58:40 +08:00
Colour = colours.GreySeafoam
},
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[]
{
2019-04-26 12:49:44 +08:00
new AddFriendButton
{
RelativeSizeAxes = Axes.Y,
2019-04-26 12:29:58 +08:00
User = { BindTarget = User }
},
2019-04-26 12:49:44 +08:00
new MessageUserButton
{
2019-03-10 06:58:14 +08:00
User = { BindTarget = User }
},
}
},
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
{
RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2019-04-26 12:29:58 +08:00
DetailsVisible = { BindTarget = DetailsVisible }
},
},
new Container
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
Children = new Drawable[]
{
new LevelBadge
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Size = new Vector2(40),
User = { BindTarget = User }
},
expandedDetailContainer = new Container
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Width = 200,
Height = 6,
Margin = new MarginPadding { Right = 50 },
Child = new LevelProgressBar
{
RelativeSizeAxes = Axes.Both,
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[]
{
2019-03-10 06:58:14 +08:00
hiddenDetailGlobal = new OverlinedInfoContainer
{
Title = "Global Ranking",
LineColour = colours.Yellow
},
2019-03-10 06:58:14 +08:00
hiddenDetailCountry = new OverlinedInfoContainer
{
Title = "Country Ranking",
LineColour = colours.Yellow
},
}
}
}
}
};
2019-04-25 19:05:59 +08:00
DetailsVisible.BindValueChanged(visible =>
2019-03-06 15:09:21 +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
User.BindValueChanged(user => updateDisplay(user.NewValue));
}
2019-03-10 06:58:14 +08:00
private void updateDisplay(User user)
{
hiddenDetailGlobal.Content = user?.Statistics?.Ranks.Global?.ToString("\\##,##0") ?? "-";
hiddenDetailCountry.Content = user?.Statistics?.Ranks.Country?.ToString("\\##,##0") ?? "-";
}
}
}