mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 23:42:55 +08:00
use Drawable Rank
This commit is contained in:
parent
c67f6d949b
commit
92bf363ecf
40
osu.Game/Screens/Play/HUD/DefaultRankDisplay.cs
Normal file
40
osu.Game/Screens/Play/HUD/DefaultRankDisplay.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Game.Online.Leaderboards;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public partial class DefaultRankDisplay : GameplayRankDisplay
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private ScoreProcessor scoreProcessor { get; set; } = null!;
|
||||||
|
|
||||||
|
private UpdateableRank rank;
|
||||||
|
|
||||||
|
public DefaultRankDisplay()
|
||||||
|
{
|
||||||
|
Size = new Vector2(70, 35);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[] {
|
||||||
|
rank = new UpdateableRank(Scoring.ScoreRank.X) {
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
rank.Rank = scoreProcessor.Rank.Value;
|
||||||
|
|
||||||
|
scoreProcessor.Rank.BindValueChanged(v => rank.Rank = v.NewValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
osu.Game/Screens/Play/HUD/GameplayRankDisplay.cs
Normal file
14
osu.Game/Screens/Play/HUD/GameplayRankDisplay.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 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.Game.Skinning;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public abstract partial class GameplayRankDisplay : Container, ISerialisableDrawable
|
||||||
|
{
|
||||||
|
public bool UsesFixedAnchor { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,46 +0,0 @@
|
|||||||
// 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.Game.Rulesets.Scoring;
|
|
||||||
using osu.Game.Skinning;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Extensions;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
|
||||||
{
|
|
||||||
public partial class RankDisplay : FontAdjustableSkinComponent
|
|
||||||
{
|
|
||||||
[Resolved]
|
|
||||||
private ScoreProcessor scoreProcessor { get; set; } = null!;
|
|
||||||
|
|
||||||
private readonly OsuSpriteText text;
|
|
||||||
|
|
||||||
public RankDisplay()
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
text = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
text.Text = scoreProcessor.Rank.Value.GetDescription();
|
|
||||||
|
|
||||||
scoreProcessor.Rank.BindValueChanged(v => text.Text = v.NewValue.GetDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user