1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00

Add Rank as a property to the Score Processor

This commit is contained in:
EVAST9919 2017-10-02 05:56:38 +03:00
parent 5ce2723719
commit c2f487aa3e
4 changed files with 13 additions and 15 deletions

View File

@ -51,6 +51,11 @@ namespace osu.Game.Rulesets.Scoring
/// </summary>
public readonly BindableInt Combo = new BindableInt();
/// <summary>
/// The current rank.
/// </summary>
public readonly Bindable<ScoreRank> Rank = new Bindable<ScoreRank>(ScoreRank.X);
/// <summary>
/// THe highest combo achieved by this score.
/// </summary>
@ -74,9 +79,10 @@ namespace osu.Game.Rulesets.Scoring
protected ScoreProcessor()
{
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
Accuracy.ValueChanged += delegate { Rank.Value = rankFrom(Accuracy.Value); };
}
public static ScoreRank RankFrom(double acc)
private ScoreRank rankFrom(double acc)
{
if (acc == 1)
return ScoreRank.X;
@ -101,6 +107,7 @@ namespace osu.Game.Rulesets.Scoring
Accuracy.Value = 1;
Health.Value = 1;
Combo.Value = 0;
Rank.Value = ScoreRank.X;
HighestCombo.Value = 0;
alreadyFailed = false;
@ -142,7 +149,7 @@ namespace osu.Game.Rulesets.Scoring
score.Combo = Combo;
score.MaxCombo = HighestCombo;
score.Accuracy = Accuracy;
score.Rank = RankFrom(Accuracy);
score.Rank = Rank;
score.Date = DateTimeOffset.Now;
score.Health = Health;
}

View File

@ -147,7 +147,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay
public void BindProcessor(ScoreProcessor processor)
{
info.AccuracyDisplay.Current.BindTo(processor.Accuracy);
info.GradeDisplay.Current.BindTo(processor.Accuracy);
info.GradeDisplay.Current.BindTo(processor.Rank);
}
}
}

View File

@ -5,6 +5,7 @@ using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play.BreaksOverlay
{
@ -12,7 +13,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay
{
public PercentageInfoLine AccuracyDisplay;
public InfoLine<int> RankDisplay;
public GradeInfoLine GradeDisplay;
public InfoLine<ScoreRank> GradeDisplay;
public InfoContainer()
{
@ -40,7 +41,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay
{
AccuracyDisplay = new PercentageInfoLine("Accuracy"),
RankDisplay = new InfoLine<int>("Rank", @"#"),
GradeDisplay = new GradeInfoLine("Grade"),
GradeDisplay = new InfoLine<ScoreRank>("Grade"),
},
}
};

View File

@ -7,7 +7,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play.BreaksOverlay
{
@ -80,13 +79,4 @@ namespace osu.Game.Screens.Play.BreaksOverlay
protected override string Format(double count) => $@"{count:P2}";
}
public class GradeInfoLine : InfoLine<double>
{
public GradeInfoLine(string name, string prefix = "") : base(name, prefix)
{
}
protected override string Format(double count) => $@"{ScoreProcessor.RankFrom(count)}";
}
}