2021-05-07 15:26:54 +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 osu.Framework.Allocation;
|
2022-12-30 20:19:46 +08:00
|
|
|
using osu.Framework.Bindables;
|
2023-02-02 07:44:00 +08:00
|
|
|
using osu.Framework.Localisation;
|
2022-12-30 20:19:46 +08:00
|
|
|
using osu.Game.Configuration;
|
2021-05-07 15:26:54 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2023-02-02 08:46:14 +08:00
|
|
|
using osu.Game.Localisation;
|
2021-05-07 15:26:54 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
|
|
|
public abstract partial class GameplayAccuracyCounter : PercentageCounter
|
|
|
|
{
|
2023-02-02 07:44:00 +08:00
|
|
|
[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()
|
2021-05-07 15:26:54 +08:00
|
|
|
{
|
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);
|
2022-12-31 04:12:29 +08:00
|
|
|
|
|
|
|
// 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
|
|
|
{
|
2023-02-02 07:44:00 +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
|
|
|
|
2023-02-02 07:44:00 +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
|
|
|
|
2023-02-02 07:44:00 +08:00
|
|
|
[LocalisableDescription(typeof(GameplayAccuracyCounterStrings), nameof(GameplayAccuracyCounterStrings.AccuracyDisplayModeMin))]
|
2022-12-31 03:30:58 +08:00
|
|
|
MinimumAchievable
|
2021-05-07 15:26:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|