2020-10-15 15:32:20 +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.
|
|
|
|
|
2020-10-19 13:05:28 +08:00
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
2020-10-15 15:32:20 +08:00
|
|
|
using osu.Framework.Bindables;
|
2020-10-19 13:05:28 +08:00
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-10-15 15:32:20 +08:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
|
|
|
public class SkinnableScoreCounter : SkinnableDrawable, IScoreCounter
|
|
|
|
{
|
|
|
|
public Bindable<double> Current { get; } = new Bindable<double>();
|
|
|
|
|
2020-10-19 13:05:28 +08:00
|
|
|
private Bindable<ScoringMode> scoreDisplayMode;
|
|
|
|
|
|
|
|
public Bindable<int> RequiredDisplayDigits { get; } = new Bindable<int>();
|
|
|
|
|
2020-10-15 15:32:20 +08:00
|
|
|
public SkinnableScoreCounter()
|
|
|
|
: base(new HUDSkinComponent(HUDSkinComponents.ScoreCounter), _ => new DefaultScoreCounter())
|
|
|
|
{
|
|
|
|
CentreComponent = false;
|
|
|
|
}
|
|
|
|
|
2020-10-19 13:05:28 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuConfigManager config)
|
|
|
|
{
|
|
|
|
scoreDisplayMode = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode);
|
|
|
|
scoreDisplayMode.BindValueChanged(scoreMode =>
|
|
|
|
{
|
|
|
|
switch (scoreMode.NewValue)
|
|
|
|
{
|
|
|
|
case ScoringMode.Standardised:
|
|
|
|
RequiredDisplayDigits.Value = 6;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ScoringMode.Classic:
|
|
|
|
RequiredDisplayDigits.Value = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(scoreMode));
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
2020-10-15 15:32:20 +08:00
|
|
|
private IScoreCounter skinnedCounter;
|
|
|
|
|
|
|
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
|
|
|
{
|
|
|
|
base.SkinChanged(skin, allowFallback);
|
|
|
|
|
|
|
|
skinnedCounter = Drawable as IScoreCounter;
|
2020-10-19 13:05:28 +08:00
|
|
|
|
2020-10-15 15:32:20 +08:00
|
|
|
skinnedCounter?.Current.BindTo(Current);
|
2020-10-19 13:05:28 +08:00
|
|
|
skinnedCounter?.RequiredDisplayDigits.BindTo(RequiredDisplayDigits);
|
2020-10-15 15:32:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|