Update styling

This commit is contained in:
smoogipoo
2021-09-30 17:54:52 +09:00
parent 84bddf0885
commit d2a8f35b4c
2 changed files with 45 additions and 6 deletions

View File

@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface
set => current.Current = value; set => current.Current = value;
} }
private SpriteText displayedCountSpriteText; private IHasText displayedCountSpriteText;
/// <summary> /// <summary>
/// If true, the roll-up duration will be proportional to change in value. /// If true, the roll-up duration will be proportional to change in value.
@ -72,10 +72,10 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
displayedCountSpriteText = CreateSpriteText(); displayedCountSpriteText = CreateText();
UpdateDisplay(); UpdateDisplay();
Child = displayedCountSpriteText; Child = (Drawable)displayedCountSpriteText;
} }
protected void UpdateDisplay() protected void UpdateDisplay()
@ -160,6 +160,8 @@ namespace osu.Game.Graphics.UserInterface
this.TransformTo(nameof(DisplayedCount), newValue, rollingTotalDuration, RollingEasing); this.TransformTo(nameof(DisplayedCount), newValue, rollingTotalDuration, RollingEasing);
} }
protected virtual IHasText CreateText() => CreateSpriteText();
protected virtual OsuSpriteText CreateSpriteText() => new OsuSpriteText protected virtual OsuSpriteText CreateSpriteText() => new OsuSpriteText
{ {
Font = OsuFont.Numeric.With(size: 40f), Font = OsuFont.Numeric.With(size: 40f),

View File

@ -68,10 +68,9 @@ namespace osu.Game.Screens.Play.HUD
Current.Value = (int)(ppProcessor?.Calculate() ?? 0); 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() protected override IHasText CreateText() => new TextComponent();
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(size: 20f));
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
@ -81,6 +80,44 @@ namespace osu.Game.Screens.Play.HUD
scoreProcessor.NewJudgement -= onNewJudgement; 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 class GameplayWorkingBeatmap : WorkingBeatmap
{ {
private readonly GameplayBeatmap gameplayBeatmap; private readonly GameplayBeatmap gameplayBeatmap;