From d2a8f35b4c5428118d306174cb72503dd2ff66c1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 30 Sep 2021 17:54:52 +0900 Subject: [PATCH] Update styling --- .../Graphics/UserInterface/RollingCounter.cs | 8 ++-- .../HUD/DefaultPerformancePointsCounter.cs | 43 +++++++++++++++++-- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 244658b75e..f03287e7de 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface set => current.Current = value; } - private SpriteText displayedCountSpriteText; + private IHasText displayedCountSpriteText; /// /// If true, the roll-up duration will be proportional to change in value. @@ -72,10 +72,10 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load() { - displayedCountSpriteText = CreateSpriteText(); + displayedCountSpriteText = CreateText(); UpdateDisplay(); - Child = displayedCountSpriteText; + Child = (Drawable)displayedCountSpriteText; } protected void UpdateDisplay() @@ -160,6 +160,8 @@ namespace osu.Game.Graphics.UserInterface this.TransformTo(nameof(DisplayedCount), newValue, rollingTotalDuration, RollingEasing); } + protected virtual IHasText CreateText() => CreateSpriteText(); + protected virtual OsuSpriteText CreateSpriteText() => new OsuSpriteText { Font = OsuFont.Numeric.With(size: 40f), diff --git a/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs index 18bb621dd1..a7651187c2 100644 --- a/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs @@ -68,10 +68,9 @@ namespace osu.Game.Screens.Play.HUD Current.Value = (int)(ppProcessor?.Calculate() ?? 0); } - protected override LocalisableString FormatCount(int count) => $@"{count}pp"; + protected override LocalisableString FormatCount(int count) => count.ToString(@"D"); - protected override OsuSpriteText CreateSpriteText() - => base.CreateSpriteText().With(s => s.Font = s.Font.With(size: 20f)); + protected override IHasText CreateText() => new TextComponent(); protected override void Dispose(bool isDisposing) { @@ -81,6 +80,44 @@ namespace osu.Game.Screens.Play.HUD scoreProcessor.NewJudgement -= onNewJudgement; } + private class TextComponent : CompositeDrawable, IHasText + { + public LocalisableString Text + { + get => text.Text; + set => text.Text = value; + } + + private readonly OsuSpriteText text; + + public TextComponent() + { + AutoSizeAxes = Axes.Both; + + InternalChild = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(2), + Children = new Drawable[] + { + text = new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Font = OsuFont.Numeric.With(size: 16) + }, + new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Text = @"pp", + Font = OsuFont.Numeric.With(size: 8) + } + } + }; + } + } + private class GameplayWorkingBeatmap : WorkingBeatmap { private readonly GameplayBeatmap gameplayBeatmap;