mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 20:07:29 +08:00
Simplify information propagation logic
This commit is contained in:
parent
cc9ee472d6
commit
8f9b8ed5a1
@ -59,7 +59,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
Content = null;
|
Content = null;
|
||||||
backgroundFlow.Clear();
|
backgroundFlow.Clear();
|
||||||
|
|
||||||
if (value == null || !value.Any())
|
if (value?.Any() != true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < value.Count; i++)
|
for (int i = 0; i < value.Count; i++)
|
||||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -48,16 +47,34 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private APILegacyScores scores;
|
|
||||||
|
|
||||||
protected APILegacyScores Scores
|
protected APILegacyScores Scores
|
||||||
{
|
{
|
||||||
get => scores;
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
scores = value;
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
loading = false;
|
||||||
|
|
||||||
updateDisplay();
|
topScoresContainer.Clear();
|
||||||
|
|
||||||
|
if (value?.Scores.Any() != true)
|
||||||
|
{
|
||||||
|
scoreTable.Scores = null;
|
||||||
|
scoreTable.Hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scoreTable.Scores = value.Scores;
|
||||||
|
scoreTable.Show();
|
||||||
|
|
||||||
|
var topScore = value.Scores.First();
|
||||||
|
var userScore = value.UserScore;
|
||||||
|
|
||||||
|
topScoresContainer.Add(new DrawableTopScore(topScore));
|
||||||
|
|
||||||
|
if (userScore != null && userScore.Score.OnlineScoreID != topScore.OnlineScoreID)
|
||||||
|
topScoresContainer.Add(new DrawableTopScore(userScore.Score, userScore.Position));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +126,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
background.Colour = colours.Gray2;
|
background.Colour = colours.Gray2;
|
||||||
updateDisplay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool loading
|
private bool loading
|
||||||
@ -125,35 +141,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
Scores = null;
|
Scores = null;
|
||||||
|
|
||||||
if (beatmap?.OnlineBeatmapID.HasValue != true)
|
if (beatmap?.OnlineBeatmapID.HasValue != true)
|
||||||
|
{
|
||||||
|
loading = false;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
loading = true;
|
|
||||||
|
|
||||||
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
||||||
getScoresRequest.Success += scores => Schedule(() =>
|
getScoresRequest.Success += scores => Scores = scores;
|
||||||
{
|
|
||||||
Scores = scores;
|
|
||||||
loading = false;
|
|
||||||
});
|
|
||||||
api.Queue(getScoresRequest);
|
api.Queue(getScoresRequest);
|
||||||
}
|
loading = true;
|
||||||
|
|
||||||
private void updateDisplay()
|
|
||||||
{
|
|
||||||
topScoresContainer.Clear();
|
|
||||||
|
|
||||||
scoreTable.Scores = scores?.Scores.Count > 1 ? scores.Scores : new List<APILegacyScoreInfo>();
|
|
||||||
scoreTable.FadeTo(scores?.Scores.Count > 1 ? 1 : 0);
|
|
||||||
|
|
||||||
if (scores?.Scores.Any() ?? false)
|
|
||||||
{
|
|
||||||
topScoresContainer.Add(new DrawableTopScore(scores.Scores.FirstOrDefault()));
|
|
||||||
|
|
||||||
var userScore = scores.UserScore;
|
|
||||||
|
|
||||||
if (userScore != null && userScore.Position != 1)
|
|
||||||
topScoresContainer.Add(new DrawableTopScore(userScore.Score, userScore.Position));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user