1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 16:42:55 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/GameplayScoreCounter.cs
Dean Herbert 9a886125ad Ensure GameplayScoreCounter's display score is updated on ScoringMode change
This isn't strictly required, but only because of a kind of hacky
behaviour where `HUDOverlay` will recreate all components on a scoring
mode change currently (see
8f6df5ea0f/osu.Game/Screens/Play/HUDOverlay.cs (L410-L418)).

Best we do this just in case that happens to go away in the future.
2023-05-29 19:00:02 +09:00

55 lines
1.7 KiB
C#

// 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.Allocation;
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring.Legacy;
namespace osu.Game.Screens.Play.HUD
{
public abstract partial class GameplayScoreCounter : ScoreCounter
{
private Bindable<ScoringMode> scoreDisplayMode = null!;
private Bindable<long> totalScoreBindable = null!;
protected GameplayScoreCounter()
: base(6)
{
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, ScoreProcessor scoreProcessor)
{
totalScoreBindable = scoreProcessor.TotalScore.GetBoundCopy();
totalScoreBindable.BindValueChanged(_ => updateDisplayScore());
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));
}
updateDisplayScore();
}, true);
void updateDisplayScore() => Current.Value = scoreProcessor.GetDisplayScore(scoreDisplayMode.Value);
}
}
}