2019-04-25 19:30:16 +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;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2021-06-26 01:10:04 +08:00
|
|
|
using osu.Framework.Localisation;
|
2019-04-25 19:30:16 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Users;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2019-04-26 12:49:44 +08:00
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
2019-04-25 19:30:16 +08:00
|
|
|
{
|
|
|
|
public class LevelProgressBar : CompositeDrawable, IHasTooltip
|
|
|
|
{
|
|
|
|
public readonly Bindable<User> User = new Bindable<User>();
|
|
|
|
|
2021-06-26 01:10:04 +08:00
|
|
|
public LocalisableString TooltipText { get; }
|
2019-04-25 19:30:16 +08:00
|
|
|
|
|
|
|
private Bar levelProgressBar;
|
|
|
|
private OsuSpriteText levelProgressText;
|
|
|
|
|
|
|
|
public LevelProgressBar()
|
|
|
|
{
|
2020-01-15 03:26:54 +08:00
|
|
|
TooltipText = "progress to next level";
|
2019-04-25 19:30:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-01-31 01:18:42 +08:00
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2019-04-25 19:30:16 +08: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-31 01:18:42 +08:00
|
|
|
AccentColour = colourProvider.Highlight1
|
2019-04-25 19:30:16 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
levelProgressText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-26 11:32:15 +08:00
|
|
|
User.BindValueChanged(user => updateProgress(user.NewValue));
|
2019-04-25 19:30:16 +08:00
|
|
|
}
|
|
|
|
|
2019-04-26 11:32:15 +08:00
|
|
|
private void updateProgress(User user)
|
2019-04-25 19:30:16 +08:00
|
|
|
{
|
2019-04-26 11:32:15 +08:00
|
|
|
levelProgressBar.Length = user?.Statistics?.Level.Progress / 100f ?? 0;
|
|
|
|
levelProgressText.Text = user?.Statistics?.Level.Progress.ToString("0'%'");
|
2019-04-25 19:30:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|