mirror of https://github.com/ppy/osu
Separate bindables
This commit is contained in:
parent
8ffc4309fb
commit
d7bbb362bf
|
@ -194,7 +194,7 @@ private void load(IAPIProvider api, OsuColour colour, ScoreManager scoreManager)
|
|||
{
|
||||
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 @@ private Drawable[] createContent(int index, ScoreInfo score)
|
|||
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 @@ protected override bool CheckLocalAvailability(ScoreInfo model, IQueryable<Score
|
|||
=> 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 @@ public TotalScoreBindable(ScoreInfo score, Func<BeatmapDifficultyManager> diffic
|
|||
this.score = score;
|
||||
this.difficulties = difficulties;
|
||||
|
||||
Value = "0";
|
||||
Value = 0;
|
||||
|
||||
ScoringMode.BindValueChanged(onScoringModeChanged, true);
|
||||
}
|
||||
|
@ -121,7 +123,7 @@ private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
|
|||
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 @@ private void updateScore(int beatmapMaxCombo)
|
|||
{
|
||||
if (beatmapMaxCombo == 0)
|
||||
{
|
||||
Value = "0";
|
||||
Value = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -149,7 +151,19 @@ private void updateScore(int beatmapMaxCombo)
|
|||
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