1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-08 10:47:24 +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.

65 lines
2.2 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.
2022-12-30 22:24:41 +08:00
using System.ComponentModel;
using osu.Framework.Allocation;
2022-12-30 20:19:46 +08:00
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play.HUD
{
public abstract partial class GameplayAccuracyCounter : PercentageCounter
{
2022-12-31 03:30:58 +08:00
[SettingSource("Accuracy display mode", "Which accuracy mode should be displayed.")]
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
{
2022-12-31 03:30:58 +08:00
[Description("Standard")]
Standard,
2022-12-30 22:24:41 +08:00
2022-12-31 03:30:58 +08:00
[Description("Maximum achievable")]
MaximumAchievable,
2022-12-30 22:24:41 +08:00
2022-12-31 03:30:58 +08:00
[Description("Minimum achievable")]
MinimumAchievable
}
}
}