1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:32:55 +08:00

Move "required display digits" feature to reside in argon score counter

This commit is contained in:
Salman Ahmed 2023-11-08 01:49:13 +03:00
parent e6d3085353
commit d30bac3f49
2 changed files with 17 additions and 5 deletions

View File

@ -1,8 +1,6 @@
// 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 System;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -25,7 +23,6 @@ namespace osu.Game.Screens.Play.HUD
private readonly ArgonCounterSpriteText wireframesPart;
private readonly ArgonCounterSpriteText textPart;
public IBindable<int> RequiredDisplayDigits { get; } = new BindableInt();
public IBindable<float> WireframeOpacity { get; } = new BindableFloat();
public LocalisableString Text
@ -33,7 +30,7 @@ namespace osu.Game.Screens.Play.HUD
get => textPart.Text;
set
{
wireframesPart.Text = new string('#', Math.Max(value.ToString().Count(char.IsDigit), RequiredDisplayDigits.Value));
wireframesPart.Text = FormatWireframes(value);
textPart.Text = value;
}
}
@ -91,6 +88,8 @@ namespace osu.Game.Screens.Play.HUD
};
}
protected virtual LocalisableString FormatWireframes(LocalisableString text) => text;
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -1,6 +1,7 @@
// 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 System;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
@ -25,10 +26,22 @@ namespace osu.Game.Screens.Play.HUD
protected override LocalisableString FormatCount(long count) => count.ToLocalisableString();
protected override IHasText CreateText() => new ArgonCounterTextComponent(Anchor.TopRight)
protected override IHasText CreateText() => new ArgonScoreTextComponent(Anchor.TopRight)
{
RequiredDisplayDigits = { BindTarget = RequiredDisplayDigits },
WireframeOpacity = { BindTarget = WireframeOpacity },
};
private partial class ArgonScoreTextComponent : ArgonCounterTextComponent
{
public IBindable<int> RequiredDisplayDigits { get; } = new BindableInt();
public ArgonScoreTextComponent(Anchor anchor, LocalisableString? label = null)
: base(anchor, label)
{
}
protected override LocalisableString FormatWireframes(LocalisableString text) => new string('#', Math.Max(text.ToString().Length, RequiredDisplayDigits.Value));
}
}
}