From 37a659b2af22ca0246cd9833ed1d21fe37726fa6 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 9 Sep 2020 17:04:02 +0900 Subject: [PATCH] Refactor/add xmldocs --- .../Online/Leaderboards/LeaderboardScore.cs | 2 +- .../Overlays/BeatmapSet/Scores/ScoreTable.cs | 2 +- .../Scores/TopScoreStatisticsSection.cs | 4 +-- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 14 +++++--- osu.Game/Scoring/ScoreManager.cs | 33 ++++++++++++++++--- .../ContractedPanelMiddleContent.cs | 2 +- .../Expanded/ExpandedPanelMiddleContent.cs | 2 +- 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/osu.Game/Online/Leaderboards/LeaderboardScore.cs b/osu.Game/Online/Leaderboards/LeaderboardScore.cs index 846bebe347..dcd0cb435a 100644 --- a/osu.Game/Online/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Online/Leaderboards/LeaderboardScore.cs @@ -194,7 +194,7 @@ namespace osu.Game.Online.Leaderboards { TextColour = Color4.White, GlowColour = Color4Extensions.FromHex(@"83ccfa"), - Current = scoreManager.GetTotalScoreString(score), + Current = scoreManager.GetBindableTotalScoreString(score), Font = OsuFont.Numeric.With(size: 23), }, RankContainer = new Container diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 6bebd98eef..56866765b6 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -124,7 +124,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores 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 diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs index 507c692eb1..2fd522dc9d 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreStatisticsSection.cs @@ -95,7 +95,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void load() { if (score != null) - totalScoreColumn.Current = scoreManager.GetTotalScoreString(score); + totalScoreColumn.Current = scoreManager.GetBindableTotalScoreString(score); } private ScoreInfo score; @@ -121,7 +121,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores modsColumn.Mods = value.Mods; if (IsLoaded) - totalScoreColumn.Current = scoreManager.GetTotalScoreString(value); + totalScoreColumn.Current = scoreManager.GetBindableTotalScoreString(value); } } diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 46994d4f18..983f9a3abf 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -202,11 +202,17 @@ namespace osu.Game.Rulesets.Scoring 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); + /// + /// Computes the total score. + /// + /// The to compute the total score in. + /// The maximum combo achievable in the beatmap. + /// The accuracy percentage achieved by the player. + /// The proportion of achieved by the player. + /// Any bonus score to be added. + /// The total score. public double GetScore(ScoringMode mode, int maxCombo, double accuracyRatio, double comboRatio, double bonusScore) { switch (mode) diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 5518c86910..5a6ef6945c 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -86,15 +86,34 @@ namespace osu.Game.Scoring => base.CheckLocalAvailability(model, items) || (model.OnlineScoreID != null && items.Any(i => i.OnlineScoreID == model.OnlineScoreID)); - public Bindable GetTotalScore(ScoreInfo score) + /// + /// Retrieves a bindable that represents the total score of a . + /// + /// + /// Responds to changes in the currently-selected . + /// + /// The to retrieve the bindable for. + /// The bindable containing the total score. + public Bindable GetBindableTotalScore(ScoreInfo score) { var bindable = new TotalScoreBindable(score, difficulties); configManager?.BindWith(OsuSetting.ScoreDisplayMode, bindable.ScoringMode); return bindable; } - public Bindable GetTotalScoreString(ScoreInfo score) => new TotalScoreStringBindable(GetTotalScore(score)); + /// + /// Retrieves a bindable that represents the formatted total score string of a . + /// + /// + /// Responds to changes in the currently-selected . + /// + /// The to retrieve the bindable for. + /// The bindable containing the formatted total score string. + public Bindable GetBindableTotalScoreString(ScoreInfo score) => new TotalScoreStringBindable(GetBindableTotalScore(score)); + /// + /// Provides the total score of a . Responds to changes in the currently-selected . + /// private class TotalScoreBindable : Bindable { public readonly Bindable ScoringMode = new Bindable(); @@ -102,13 +121,16 @@ namespace osu.Game.Scoring private readonly ScoreInfo score; private readonly Func difficulties; + /// + /// Creates a new . + /// + /// The to provide the total score of. + /// A function to retrieve the . public TotalScoreBindable(ScoreInfo score, Func difficulties) { this.score = score; this.difficulties = difficulties; - Value = 0; - ScoringMode.BindValueChanged(onScoringModeChanged, true); } @@ -158,6 +180,9 @@ namespace osu.Game.Scoring } } + /// + /// Provides the total score of a as a formatted string. Responds to changes in the currently-selected . + /// private class TotalScoreStringBindable : Bindable { // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (need to hold a reference) diff --git a/osu.Game/Screens/Ranking/Contracted/ContractedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Contracted/ContractedPanelMiddleContent.cs index b37b89e6c0..0b85eeafa8 100644 --- a/osu.Game/Screens/Ranking/Contracted/ContractedPanelMiddleContent.cs +++ b/osu.Game/Screens/Ranking/Contracted/ContractedPanelMiddleContent.cs @@ -163,7 +163,7 @@ namespace osu.Game.Screens.Ranking.Contracted { 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) }, diff --git a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs index 3433410d3c..0033cd1f43 100644 --- a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs +++ b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs @@ -239,7 +239,7 @@ namespace osu.Game.Screens.Ranking.Expanded using (BeginDelayedSequence(AccuracyCircle.ACCURACY_TRANSFORM_DELAY, true)) { scoreCounter.FadeIn(); - scoreCounter.Current = scoreManager.GetTotalScore(score); + scoreCounter.Current = scoreManager.GetBindableTotalScore(score); double delay = 0;