From 4060373e0399d3d0cd80639050fcbf06e03dc0ae Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Sat, 5 Aug 2023 21:15:31 +0800 Subject: [PATCH] add rank display element --- osu.Game/Screens/Play/HUD/RankDisplay.cs | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 osu.Game/Screens/Play/HUD/RankDisplay.cs diff --git a/osu.Game/Screens/Play/HUD/RankDisplay.cs b/osu.Game/Screens/Play/HUD/RankDisplay.cs new file mode 100644 index 0000000000..be8841b647 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/RankDisplay.cs @@ -0,0 +1,46 @@ +// Copyright (c) ppy Pty Ltd . 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); + } +}