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 @@ namespace osu.Game.Online.Leaderboards
{ {
TextColour = Color4.White, TextColour = Color4.White,
GlowColour = Color4Extensions.FromHex(@"83ccfa"), GlowColour = Color4Extensions.FromHex(@"83ccfa"),
Current = scoreManager.GetTotalScoreString(score), Current = scoreManager.GetBindableTotalScoreString(score),
Font = OsuFont.Numeric.With(size: 23), Font = OsuFont.Numeric.With(size: 23),
}, },
RankContainer = new Container RankContainer = new Container

View File

@ -124,7 +124,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
new OsuSpriteText new OsuSpriteText
{ {
Margin = new MarginPadding { Right = horizontal_inset }, 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) Font = OsuFont.GetFont(size: text_size, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium)
}, },
new OsuSpriteText new OsuSpriteText

View File

@ -95,7 +95,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private void load() private void load()
{ {
if (score != null) if (score != null)
totalScoreColumn.Current = scoreManager.GetTotalScoreString(score); totalScoreColumn.Current = scoreManager.GetBindableTotalScoreString(score);
} }
private ScoreInfo score; private ScoreInfo score;
@ -121,7 +121,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
modsColumn.Mods = value.Mods; modsColumn.Mods = value.Mods;
if (IsLoaded) if (IsLoaded)
totalScoreColumn.Current = scoreManager.GetTotalScoreString(value); totalScoreColumn.Current = scoreManager.GetBindableTotalScoreString(value);
} }
} }

View File

@ -202,11 +202,17 @@ namespace osu.Game.Rulesets.Scoring
TotalScore.Value = getScore(Mode.Value); TotalScore.Value = getScore(Mode.Value);
} }
private double getScore(ScoringMode mode) private double getScore(ScoringMode mode) => GetScore(mode, maxHighestCombo, baseScore / maxBaseScore, (double)HighestCombo.Value / maxHighestCombo, bonusScore);
{
return 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) public double GetScore(ScoringMode mode, int maxCombo, double accuracyRatio, double comboRatio, double bonusScore)
{ {
switch (mode) switch (mode)

View File

@ -86,15 +86,34 @@ namespace osu.Game.Scoring
=> base.CheckLocalAvailability(model, items) => base.CheckLocalAvailability(model, items)
|| (model.OnlineScoreID != null && items.Any(i => i.OnlineScoreID == model.OnlineScoreID)); || (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); var bindable = new TotalScoreBindable(score, difficulties);
configManager?.BindWith(OsuSetting.ScoreDisplayMode, bindable.ScoringMode); configManager?.BindWith(OsuSetting.ScoreDisplayMode, bindable.ScoringMode);
return bindable; 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> private class TotalScoreBindable : Bindable<long>
{ {
public readonly Bindable<ScoringMode> ScoringMode = new Bindable<ScoringMode>(); public readonly Bindable<ScoringMode> ScoringMode = new Bindable<ScoringMode>();
@ -102,13 +121,16 @@ namespace osu.Game.Scoring
private readonly ScoreInfo score; private readonly ScoreInfo score;
private readonly Func<BeatmapDifficultyManager> difficulties; 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) public TotalScoreBindable(ScoreInfo score, Func<BeatmapDifficultyManager> difficulties)
{ {
this.score = score; this.score = score;
this.difficulties = difficulties; this.difficulties = difficulties;
Value = 0;
ScoringMode.BindValueChanged(onScoringModeChanged, true); ScoringMode.BindValueChanged(onScoringModeChanged, true);
} }
@ -158,6 +180,9 @@ namespace osu.Game.Scoring
} }
} }
/// <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> private class TotalScoreStringBindable : Bindable<string>
{ {
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (need to hold a reference) // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (need to hold a reference)

View File

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

View File

@ -239,7 +239,7 @@ namespace osu.Game.Screens.Ranking.Expanded
using (BeginDelayedSequence(AccuracyCircle.ACCURACY_TRANSFORM_DELAY, true)) using (BeginDelayedSequence(AccuracyCircle.ACCURACY_TRANSFORM_DELAY, true))
{ {
scoreCounter.FadeIn(); scoreCounter.FadeIn();
scoreCounter.Current = scoreManager.GetTotalScore(score); scoreCounter.Current = scoreManager.GetBindableTotalScore(score);
double delay = 0; double delay = 0;