2019-07-14 09:34:12 +00: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-07-14 09:40:54 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-07-14 09:34:12 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
|
using osu.Game.Online.Leaderboards;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select.Details
|
|
|
|
|
{
|
|
|
|
|
public class UserTopScoreContainer : VisibilityContainer
|
|
|
|
|
{
|
2019-07-14 11:03:14 +00:00
|
|
|
|
private const int height = 90;
|
2019-07-14 09:34:12 +00:00
|
|
|
|
private const int duration = 300;
|
|
|
|
|
|
|
|
|
|
private readonly Container contentContainer;
|
|
|
|
|
private readonly Container scoreContainer;
|
|
|
|
|
|
2019-07-14 11:03:14 +00:00
|
|
|
|
public Bindable<APILegacyUserTopScoreInfo> Score = new Bindable<APILegacyUserTopScoreInfo>();
|
2019-07-14 09:34:12 +00:00
|
|
|
|
|
|
|
|
|
protected override bool StartHidden => true;
|
|
|
|
|
|
|
|
|
|
public UserTopScoreContainer()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = height;
|
|
|
|
|
Anchor = Anchor.BottomCentre;
|
|
|
|
|
Origin = Anchor.BottomCentre;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
contentContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Height = height,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2019-07-14 11:03:14 +00:00
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
2019-07-14 09:34:12 +00:00
|
|
|
|
Text = @"your personal best".ToUpper(),
|
|
|
|
|
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold),
|
|
|
|
|
},
|
|
|
|
|
scoreContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2019-07-14 09:40:54 +00:00
|
|
|
|
|
2019-07-14 13:16:21 +00:00
|
|
|
|
Score.BindValueChanged(score => onScoreChanged(score.NewValue));
|
2019-07-14 09:40:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onScoreChanged(APILegacyUserTopScoreInfo score)
|
|
|
|
|
{
|
|
|
|
|
if (score != null)
|
2019-07-14 11:03:14 +00:00
|
|
|
|
{
|
2019-07-14 13:37:05 +00:00
|
|
|
|
scoreContainer.Clear();
|
2019-07-14 09:40:54 +00:00
|
|
|
|
scoreContainer.Add(new LeaderboardScore(score.Score, score.Position));
|
2019-07-14 11:03:14 +00:00
|
|
|
|
Show();
|
|
|
|
|
}
|
2019-07-14 13:37:05 +00:00
|
|
|
|
else
|
|
|
|
|
Hide();
|
2019-07-14 09:34:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
this.ResizeHeightTo(height, duration, Easing.OutQuint);
|
|
|
|
|
contentContainer.FadeIn(duration, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
this.ResizeHeightTo(0, duration, Easing.OutQuint);
|
|
|
|
|
contentContainer.FadeOut(duration, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|