1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 06:52:55 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/GameplayAccuracyCounter.cs

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

66 lines
2.6 KiB
C#
Raw Normal View History

// 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 osu.Framework.Allocation;
2022-12-30 20:19:46 +08:00
using osu.Framework.Bindables;
using osu.Framework.Localisation;
2022-12-30 20:19:46 +08:00
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation.HUD;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play.HUD
{
public abstract partial class GameplayAccuracyCounter : PercentageCounter
{
[SettingSource(typeof(GameplayAccuracyCounterStrings), nameof(GameplayAccuracyCounterStrings.AccuracyDisplay), nameof(GameplayAccuracyCounterStrings.AccuracyDisplayDescription))]
2022-12-31 03:30:58 +08:00
public Bindable<AccuracyDisplayMode> AccuracyDisplay { get; } = new Bindable<AccuracyDisplayMode>();
2022-12-30 20:19:46 +08:00
2022-12-31 04:08:48 +08:00
[Resolved]
private ScoreProcessor scoreProcessor { get; set; } = null!;
protected override void LoadComplete()
{
2022-12-31 04:08:48 +08:00
base.LoadComplete();
2022-12-30 22:06:10 +08:00
AccuracyDisplay.BindValueChanged(mod =>
2022-12-30 20:19:46 +08:00
{
Current.UnbindBindings();
switch (mod.NewValue)
{
2022-12-31 03:30:58 +08:00
case AccuracyDisplayMode.Standard:
2022-12-30 20:19:46 +08:00
Current.BindTo(scoreProcessor.Accuracy);
break;
2022-12-31 03:30:58 +08:00
case AccuracyDisplayMode.MinimumAchievable:
Current.BindTo(scoreProcessor.MinimumAccuracy);
2022-12-30 20:19:46 +08:00
break;
2022-12-31 03:30:58 +08:00
case AccuracyDisplayMode.MaximumAchievable:
Current.BindTo(scoreProcessor.MaximumAccuracy);
2022-12-30 20:19:46 +08:00
break;
}
}, true);
// if the accuracy counter is using the "minimum achievable" mode,
// then its initial value is 0%, rather than the 100% that the base PercentageCounter assumes.
// to counteract this, manually finish transforms on DisplayedCount once after the initial callback above
// to stop it from rolling down from 100% to 0%.
FinishTransforms(targetMember: nameof(DisplayedCount));
2022-12-30 20:19:46 +08:00
}
2022-12-31 03:30:58 +08:00
public enum AccuracyDisplayMode
2022-12-30 20:19:46 +08:00
{
[LocalisableDescription(typeof(GameplayAccuracyCounterStrings), nameof(GameplayAccuracyCounterStrings.AccuracyDisplayModeStandard))]
2022-12-31 03:30:58 +08:00
Standard,
2022-12-30 22:24:41 +08:00
[LocalisableDescription(typeof(GameplayAccuracyCounterStrings), nameof(GameplayAccuracyCounterStrings.AccuracyDisplayModeMax))]
2022-12-31 03:30:58 +08:00
MaximumAchievable,
2022-12-30 22:24:41 +08:00
[LocalisableDescription(typeof(GameplayAccuracyCounterStrings), nameof(GameplayAccuracyCounterStrings.AccuracyDisplayModeMin))]
2022-12-31 03:30:58 +08:00
MinimumAchievable
}
}
}