mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Separate bindables
This commit is contained in:
parent
8ffc4309fb
commit
d7bbb362bf
@ -194,7 +194,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
{
|
||||
TextColour = Color4.White,
|
||||
GlowColour = Color4Extensions.FromHex(@"83ccfa"),
|
||||
Current = scoreManager.GetTotalScore(score),
|
||||
Current = scoreManager.GetTotalScoreString(score),
|
||||
Font = OsuFont.Numeric.With(size: 23),
|
||||
},
|
||||
RankContainer = new Container
|
||||
|
@ -124,7 +124,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
new OsuSpriteText
|
||||
{
|
||||
Margin = new MarginPadding { Right = horizontal_inset },
|
||||
Current = scoreManager.GetTotalScore(score),
|
||||
Current = scoreManager.GetTotalScoreString(score),
|
||||
Font = OsuFont.GetFont(size: text_size, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium)
|
||||
},
|
||||
new OsuSpriteText
|
||||
|
@ -86,14 +86,16 @@ namespace osu.Game.Scoring
|
||||
=> base.CheckLocalAvailability(model, items)
|
||||
|| (model.OnlineScoreID != null && items.Any(i => i.OnlineScoreID == model.OnlineScoreID));
|
||||
|
||||
public Bindable<string> GetTotalScore(ScoreInfo score)
|
||||
public Bindable<long> GetTotalScore(ScoreInfo score)
|
||||
{
|
||||
var bindable = new TotalScoreBindable(score, difficulties);
|
||||
configManager?.BindWith(OsuSetting.ScoreDisplayMode, bindable.ScoringMode);
|
||||
return bindable;
|
||||
}
|
||||
|
||||
private class TotalScoreBindable : Bindable<string>
|
||||
public Bindable<string> GetTotalScoreString(ScoreInfo score) => new TotalScoreStringBindable(GetTotalScore(score));
|
||||
|
||||
private class TotalScoreBindable : Bindable<long>
|
||||
{
|
||||
public readonly Bindable<ScoringMode> ScoringMode = new Bindable<ScoringMode>();
|
||||
|
||||
@ -105,7 +107,7 @@ namespace osu.Game.Scoring
|
||||
this.score = score;
|
||||
this.difficulties = difficulties;
|
||||
|
||||
Value = "0";
|
||||
Value = 0;
|
||||
|
||||
ScoringMode.BindValueChanged(onScoringModeChanged, true);
|
||||
}
|
||||
@ -121,7 +123,7 @@ namespace osu.Game.Scoring
|
||||
if (score.Beatmap.ID == 0 || difficulties == null)
|
||||
{
|
||||
// We don't have enough information (max combo) to compute the score, so let's use the provided score.
|
||||
Value = score.TotalScore.ToString("N0");
|
||||
Value = score.TotalScore;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -137,7 +139,7 @@ namespace osu.Game.Scoring
|
||||
{
|
||||
if (beatmapMaxCombo == 0)
|
||||
{
|
||||
Value = "0";
|
||||
Value = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -149,7 +151,19 @@ namespace osu.Game.Scoring
|
||||
double maxBaseScore = 300 * beatmapMaxCombo;
|
||||
double maxHighestCombo = beatmapMaxCombo;
|
||||
|
||||
Value = Math.Round(scoreProcessor.GetScore(ScoringMode.Value, maxBaseScore, maxHighestCombo, score.Accuracy, score.MaxCombo / maxHighestCombo, 0)).ToString("N0");
|
||||
Value = (long)Math.Round(scoreProcessor.GetScore(ScoringMode.Value, maxBaseScore, maxHighestCombo, score.Accuracy, score.MaxCombo / maxHighestCombo, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private class TotalScoreStringBindable : Bindable<string>
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (need to hold a reference)
|
||||
private readonly IBindable<long> totalScore;
|
||||
|
||||
public TotalScoreStringBindable(IBindable<long> totalScore)
|
||||
{
|
||||
this.totalScore = totalScore;
|
||||
this.totalScore.BindValueChanged(v => Value = v.NewValue.ToString("N0"), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user