mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Fix potential crash due to stale index
This commit is contained in:
@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
private readonly OsuSpriteText placeholder;
|
private readonly OsuSpriteText placeholder;
|
||||||
|
|
||||||
private KeyValuePair<int, int>[] ranks;
|
private KeyValuePair<int, int>[] ranks;
|
||||||
private int dayIndex;
|
private int hoveredIndex = -1;
|
||||||
public readonly Bindable<UserStatistics> Statistics = new Bindable<UserStatistics>();
|
public readonly Bindable<UserStatistics> Statistics = new Bindable<UserStatistics>();
|
||||||
|
|
||||||
public RankGraph()
|
public RankGraph()
|
||||||
@ -55,7 +55,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
graph.OnBallMove += i => dayIndex = i;
|
graph.OnBallMove += i => hoveredIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -74,6 +74,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
private void updateStatistics(UserStatistics statistics)
|
private void updateStatistics(UserStatistics statistics)
|
||||||
{
|
{
|
||||||
placeholder.FadeIn(fade_duration, Easing.Out);
|
placeholder.FadeIn(fade_duration, Easing.Out);
|
||||||
|
hoveredIndex = -1;
|
||||||
|
|
||||||
if (statistics?.Ranks.Global == null)
|
if (statistics?.Ranks.Global == null)
|
||||||
{
|
{
|
||||||
@ -201,14 +202,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Statistics.Value?.Ranks.Global == null)
|
if (ranks == null || hoveredIndex == -1)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var days = ranked_days - ranks[dayIndex].Key + 1;
|
var days = ranked_days - ranks[hoveredIndex].Key + 1;
|
||||||
|
|
||||||
return new TooltipDisplayContent
|
return new TooltipDisplayContent
|
||||||
{
|
{
|
||||||
Rank = $"#{ranks[dayIndex].Value:#,##0}",
|
Rank = $"#{ranks[hoveredIndex].Value:#,##0}",
|
||||||
Time = days == 0 ? "now" : $"{days} days ago"
|
Time = days == 0 ? "now" : $"{days} days ago"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user