Refactor/add xmldocs

This commit is contained in:
smoogipoo 2020-09-09 17:04:02 +09:00
parent e271408fca
commit 37a659b2af
7 changed files with 45 additions and 14 deletions

View File

@ -194,7 +194,7 @@ private void load(IAPIProvider api, OsuColour colour, ScoreManager scoreManager)
{
TextColour = Color4.White,
GlowColour = Color4Extensions.FromHex(@"83ccfa"),
Current = scoreManager.GetTotalScoreString(score),
Current = scoreManager.GetBindableTotalScoreString(score),
Font = OsuFont.Numeric.With(size: 23),
},
RankContainer = new Container

View File

@ -124,7 +124,7 @@ private Drawable[] createContent(int index, ScoreInfo score)
new OsuSpriteText
{
Margin = new MarginPadding { Right = horizontal_inset },
Current = scoreManager.GetTotalScoreString(score),
Current = scoreManager.GetBindableTotalScoreString(score),
Font = OsuFont.GetFont(size: text_size, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium)
},
new OsuSpriteText

View File

@ -95,7 +95,7 @@ public TopScoreStatisticsSection()
private void load()
{
if (score != null)
totalScoreColumn.Current = scoreManager.GetTotalScoreString(score);
totalScoreColumn.Current = scoreManager.GetBindableTotalScoreString(score);
}
private ScoreInfo score;
@ -121,7 +121,7 @@ public ScoreInfo Score
modsColumn.Mods = value.Mods;
if (IsLoaded)
totalScoreColumn.Current = scoreManager.GetTotalScoreString(value);
totalScoreColumn.Current = scoreManager.GetBindableTotalScoreString(value);
}
}

View File

@ -202,11 +202,17 @@ private void updateScore()
TotalScore.Value = getScore(Mode.Value);
}
private double getScore(ScoringMode mode)
{
return GetScore(mode, maxHighestCombo, baseScore / maxBaseScore, (double)HighestCombo.Value / maxHighestCombo, bonusScore);
}
private double getScore(ScoringMode mode) => GetScore(mode, maxHighestCombo, baseScore / maxBaseScore, (double)HighestCombo.Value / maxHighestCombo, bonusScore);
/// <summary>
/// Computes the total score.
/// </summary>
/// <param name="mode">The <see cref="ScoringMode"/> to compute the total score in.</param>
/// <param name="maxCombo">The maximum combo achievable in the beatmap.</param>
/// <param name="accuracyRatio">The accuracy percentage achieved by the player.</param>
/// <param name="comboRatio">The proportion of <paramref name="maxCombo"/> achieved by the player.</param>
/// <param name="bonusScore">Any bonus score to be added.</param>
/// <returns>The total score.</returns>
public double GetScore(ScoringMode mode, int maxCombo, double accuracyRatio, double comboRatio, double bonusScore)
{
switch (mode)

View File

@ -86,15 +86,34 @@ protected override bool CheckLocalAvailability(ScoreInfo model, IQueryable<Score
=> base.CheckLocalAvailability(model, items)
|| (model.OnlineScoreID != null && items.Any(i => i.OnlineScoreID == model.OnlineScoreID));
public Bindable<long> GetTotalScore(ScoreInfo score)
/// <summary>
/// Retrieves a bindable that represents the total score of a <see cref="ScoreInfo"/>.
/// </summary>
/// <remarks>
/// Responds to changes in the currently-selected <see cref="ScoringMode"/>.
/// </remarks>
/// <param name="score">The <see cref="ScoreInfo"/> to retrieve the bindable for.</param>
/// <returns>The bindable containing the total score.</returns>
public Bindable<long> GetBindableTotalScore(ScoreInfo score)
{
var bindable = new TotalScoreBindable(score, difficulties);
configManager?.BindWith(OsuSetting.ScoreDisplayMode, bindable.ScoringMode);
return bindable;
}
public Bindable<string> GetTotalScoreString(ScoreInfo score) => new TotalScoreStringBindable(GetTotalScore(score));
/// <summary>
/// Retrieves a bindable that represents the formatted total score string of a <see cref="ScoreInfo"/>.
/// </summary>
/// <remarks>
/// Responds to changes in the currently-selected <see cref="ScoringMode"/>.
/// </remarks>
/// <param name="score">The <see cref="ScoreInfo"/> to retrieve the bindable for.</param>
/// <returns>The bindable containing the formatted total score string.</returns>
public Bindable<string> GetBindableTotalScoreString(ScoreInfo score) => new TotalScoreStringBindable(GetBindableTotalScore(score));
/// <summary>
/// Provides the total score of a <see cref="ScoreInfo"/>. Responds to changes in the currently-selected <see cref="ScoringMode"/>.
/// </summary>
private class TotalScoreBindable : Bindable<long>
{
public readonly Bindable<ScoringMode> ScoringMode = new Bindable<ScoringMode>();
@ -102,13 +121,16 @@ private class TotalScoreBindable : Bindable<long>
private readonly ScoreInfo score;
private readonly Func<BeatmapDifficultyManager> difficulties;
/// <summary>
/// Creates a new <see cref="TotalScoreBindable"/>.
/// </summary>
/// <param name="score">The <see cref="ScoreInfo"/> to provide the total score of.</param>
/// <param name="difficulties">A function to retrieve the <see cref="BeatmapDifficultyManager"/>.</param>
public TotalScoreBindable(ScoreInfo score, Func<BeatmapDifficultyManager> difficulties)
{
this.score = score;
this.difficulties = difficulties;
Value = 0;
ScoringMode.BindValueChanged(onScoringModeChanged, true);
}
@ -158,6 +180,9 @@ private void updateScore(int beatmapMaxCombo)
}
}
/// <summary>
/// Provides the total score of a <see cref="ScoreInfo"/> as a formatted string. Responds to changes in the currently-selected <see cref="ScoringMode"/>.
/// </summary>
private class TotalScoreStringBindable : Bindable<string>
{
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (need to hold a reference)

View File

@ -163,7 +163,7 @@ private void load()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = scoreManager.GetTotalScoreString(score),
Current = scoreManager.GetBindableTotalScoreString(score),
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, fixedWidth: true),
Spacing = new Vector2(-1, 0)
},

View File

@ -239,7 +239,7 @@ protected override void LoadComplete()
using (BeginDelayedSequence(AccuracyCircle.ACCURACY_TRANSFORM_DELAY, true))
{
scoreCounter.FadeIn();
scoreCounter.Current = scoreManager.GetTotalScore(score);
scoreCounter.Current = scoreManager.GetBindableTotalScore(score);
double delay = 0;