1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

85 lines
2.9 KiB
C#
Raw Normal View History

2023-10-23 06:58:41 +08:00
// 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;
2023-10-23 06:58:41 +08:00
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
2023-10-23 06:58:41 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Localisation.SkinComponents;
using osu.Game.Resources.Localisation.Web;
2023-10-23 06:58:41 +08:00
using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD
{
public partial class ArgonScoreCounter : GameplayScoreCounter, ISerialisableDrawable
{
private ArgonScoreTextComponent scoreText = null!;
protected override double RollingDuration => 250;
2023-11-10 14:06:19 +08:00
2024-03-08 10:19:00 +08:00
[SettingSource("Wireframe opacity", "Controls the opacity of the wireframes behind the digits.")]
public BindableFloat WireframeOpacity { get; } = new BindableFloat(0.25f)
2023-10-23 06:58:41 +08:00
{
Precision = 0.01f,
MinValue = 0,
MaxValue = 1,
};
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.ShowLabel), nameof(SkinnableComponentStrings.ShowLabelDescription))]
public Bindable<bool> ShowLabel { get; } = new BindableBool(true);
2023-10-23 06:58:41 +08:00
public bool UsesFixedAnchor { get; set; }
protected override LocalisableString FormatCount(long count) => count.ToString();
protected override IHasText CreateText() => scoreText = new ArgonScoreTextComponent(Anchor.TopRight, BeatmapsetsStrings.ShowScoreboardHeadersScore.ToUpper())
2023-10-23 06:58:41 +08:00
{
WireframeOpacity = { BindTarget = WireframeOpacity },
ShowLabel = { BindTarget = ShowLabel },
2023-10-23 06:58:41 +08:00
};
public ArgonScoreCounter()
{
RequiredDisplayDigits.BindValueChanged(_ => updateWireframe());
}
public override long DisplayedCount
{
get => base.DisplayedCount;
set
{
base.DisplayedCount = value;
updateWireframe();
}
}
private void updateWireframe()
{
int digitsRequiredForDisplayCount = Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount());
if (digitsRequiredForDisplayCount != scoreText.WireframeTemplate.Length)
2024-02-29 06:01:55 +08:00
scoreText.WireframeTemplate = new string('#', digitsRequiredForDisplayCount);
}
private int getDigitsRequiredForDisplayCount()
{
int digitsRequired = 1;
long c = DisplayedCount;
while ((c /= 10) > 0)
digitsRequired++;
return digitsRequired;
}
private partial class ArgonScoreTextComponent : ArgonCounterTextComponent
{
public ArgonScoreTextComponent(Anchor anchor, LocalisableString? label = null)
: base(anchor, label)
{
}
}
2023-10-23 06:58:41 +08:00
}
}