2019-04-25 20:30:16 +09: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;
|
|
|
|
using osu.Framework.Bindables;
|
2021-08-29 15:00:28 +03:00
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2019-04-25 20:30:16 +09:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2021-06-25 19:10:04 +02:00
|
|
|
using osu.Framework.Localisation;
|
2019-04-25 20:30:16 +09:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-11-04 18:02:44 +09:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-07-17 15:18:45 +02:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-04-25 20:30:16 +09:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2019-04-26 13:49:44 +09:00
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
2019-04-25 20:30:16 +09:00
|
|
|
{
|
|
|
|
public partial class LevelProgressBar : CompositeDrawable, IHasTooltip
|
|
|
|
{
|
2023-01-10 19:24:54 +01:00
|
|
|
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
|
2019-04-25 20:30:16 +09:00
|
|
|
|
2021-06-25 19:10:04 +02:00
|
|
|
public LocalisableString TooltipText { get; }
|
2019-04-25 20:30:16 +09:00
|
|
|
|
2022-12-30 13:17:59 +01:00
|
|
|
private Bar levelProgressBar = null!;
|
|
|
|
private OsuSpriteText levelProgressText = null!;
|
2019-04-25 20:30:16 +09:00
|
|
|
|
|
|
|
public LevelProgressBar()
|
|
|
|
{
|
2021-07-17 15:18:45 +02:00
|
|
|
TooltipText = UsersStrings.ShowStatsLevelProgress;
|
2019-04-25 20:30:16 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-01-30 18:18:42 +01:00
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2019-04-25 20:30:16 +09:00
|
|
|
{
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new CircularContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Child = levelProgressBar = new Bar
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
BackgroundColour = Color4.Black,
|
|
|
|
Direction = BarDirection.LeftToRight,
|
2020-01-30 18:18:42 +01:00
|
|
|
AccentColour = colourProvider.Highlight1
|
2019-04-25 20:30:16 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
levelProgressText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-01-10 19:24:54 +01:00
|
|
|
User.BindValueChanged(user => updateProgress(user.NewValue?.User));
|
2019-04-25 20:30:16 +09:00
|
|
|
}
|
|
|
|
|
2022-12-30 13:17:59 +01:00
|
|
|
private void updateProgress(APIUser? user)
|
2019-04-25 20:30:16 +09:00
|
|
|
{
|
2019-04-26 12:32:15 +09:00
|
|
|
levelProgressBar.Length = user?.Statistics?.Level.Progress / 100f ?? 0;
|
2022-05-02 20:07:53 +08:00
|
|
|
levelProgressText.Text = user?.Statistics?.Level.Progress.ToLocalisableString("0'%'") ?? default;
|
2019-04-25 20:30:16 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|