mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 09:27:18 +09:00
Add user top score on selected beatmap
This commit is contained in:
parent
a0efd50f62
commit
67a6abb96c
@ -23,10 +23,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
private Color4 backgroundHoveredColour;
|
private Color4 backgroundHoveredColour;
|
||||||
|
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private readonly TopScoreUserSection userSection;
|
|
||||||
private readonly TopScoreStatisticsSection statisticsSection;
|
|
||||||
|
|
||||||
public DrawableTopScore()
|
public DrawableTopScore(ScoreInfo score, int position = 1)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
@ -61,16 +59,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
userSection = new TopScoreUserSection
|
new TopScoreUserSection(position)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
|
Score = score,
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
statisticsSection = new TopScoreStatisticsSection
|
new TopScoreStatisticsSection
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
|
Score = score,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -91,18 +91,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
background.Colour = backgroundIdleColour;
|
background.Colour = backgroundIdleColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the score to be displayed.
|
|
||||||
/// </summary>
|
|
||||||
public ScoreInfo Score
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
userSection.Score = value;
|
|
||||||
statisticsSection.Score = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
background.FadeColour(backgroundHoveredColour, fade_duration, Easing.OutQuint);
|
background.FadeColour(backgroundHoveredColour, fade_duration, Easing.OutQuint);
|
||||||
|
@ -14,6 +14,7 @@ using osuTK;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapSet.Scores
|
namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||||
{
|
{
|
||||||
@ -25,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private readonly ScoreTable scoreTable;
|
private readonly ScoreTable scoreTable;
|
||||||
|
|
||||||
private readonly DrawableTopScore topScore;
|
private readonly FillFlowContainer topScoresContainer;
|
||||||
private readonly LoadingAnimation loadingAnimation;
|
private readonly LoadingAnimation loadingAnimation;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -54,7 +55,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
Margin = new MarginPadding { Vertical = spacing },
|
Margin = new MarginPadding { Vertical = spacing },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
topScore = new DrawableTopScore(),
|
topScoresContainer = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(0, 5),
|
||||||
|
},
|
||||||
scoreTable = new ScoreTable
|
scoreTable = new ScoreTable
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
@ -97,6 +104,20 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private APILegacyUserTopScoreInfo userScore;
|
||||||
|
|
||||||
|
public APILegacyUserTopScoreInfo UserScore
|
||||||
|
{
|
||||||
|
get => userScore;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
getScoresRequest?.Cancel();
|
||||||
|
userScore = value;
|
||||||
|
|
||||||
|
updateDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmap;
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo Beatmap
|
||||||
@ -114,7 +135,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
loading = true;
|
loading = true;
|
||||||
|
|
||||||
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
||||||
getScoresRequest.Success += r => Schedule(() => Scores = r.Scores);
|
getScoresRequest.Success += r => Schedule(() =>
|
||||||
|
{
|
||||||
|
scores = r.Scores;
|
||||||
|
userScore = r.UserScore;
|
||||||
|
updateDisplay();
|
||||||
|
});
|
||||||
api.Queue(getScoresRequest);
|
api.Queue(getScoresRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,17 +148,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
private void updateDisplay()
|
private void updateDisplay()
|
||||||
{
|
{
|
||||||
loading = false;
|
loading = false;
|
||||||
|
topScoresContainer.Clear();
|
||||||
|
|
||||||
scoreTable.Scores = scores?.Count > 1 ? scores : new List<ScoreInfo>();
|
scoreTable.Scores = scores?.Count > 1 ? scores : new List<ScoreInfo>();
|
||||||
scoreTable.FadeTo(scores?.Count > 1 ? 1 : 0);
|
scoreTable.FadeTo(scores?.Count > 1 ? 1 : 0);
|
||||||
|
|
||||||
if (scores?.Any() == true)
|
if (scores?.Any() == true)
|
||||||
{
|
{
|
||||||
topScore.Score = scores.FirstOrDefault();
|
topScoresContainer.Add(new DrawableTopScore(scores.FirstOrDefault()));
|
||||||
topScore.Show();
|
|
||||||
|
if (userScore != null && userScore.Position != 1)
|
||||||
|
topScoresContainer.Add(new DrawableTopScore(userScore.Score, userScore.Position));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
topScore.Hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
private readonly SpriteText date;
|
private readonly SpriteText date;
|
||||||
private readonly UpdateableFlag flag;
|
private readonly UpdateableFlag flag;
|
||||||
|
|
||||||
public TopScoreUserSection()
|
public TopScoreUserSection(int position)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Text = "#1",
|
Text = position.ToString(),
|
||||||
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true)
|
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true)
|
||||||
},
|
},
|
||||||
rank = new UpdateableRank(ScoreRank.D)
|
rank = new UpdateableRank(ScoreRank.D)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user