mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 18:07:25 +08:00
Move RankHistoryData to User Statistics
This commit is contained in:
parent
b0a27161c6
commit
d693a54c84
@ -69,28 +69,22 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("null user", () => graph.User.Value = null);
|
AddStep("null user", () => graph.Statistics.Value = null);
|
||||||
AddStep("rank only", () =>
|
AddStep("rank only", () =>
|
||||||
{
|
{
|
||||||
graph.User.Value = new User
|
graph.Statistics.Value = new UserStatistics
|
||||||
{
|
{
|
||||||
Statistics = new UserStatistics
|
Ranks = new UserStatistics.UserRanks { Global = 123456 },
|
||||||
{
|
PP = 12345,
|
||||||
Ranks = new UserStatistics.UserRanks { Global = 123456 },
|
|
||||||
PP = 12345,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("with rank history", () =>
|
AddStep("with rank history", () =>
|
||||||
{
|
{
|
||||||
graph.User.Value = new User
|
graph.Statistics.Value = new UserStatistics
|
||||||
{
|
{
|
||||||
Statistics = new UserStatistics
|
Ranks = new UserStatistics.UserRanks { Global = 89000 },
|
||||||
{
|
PP = 12345,
|
||||||
Ranks = new UserStatistics.UserRanks { Global = 89000 },
|
|
||||||
PP = 12345,
|
|
||||||
},
|
|
||||||
RankHistory = new User.RankHistoryData
|
RankHistory = new User.RankHistoryData
|
||||||
{
|
{
|
||||||
Data = data,
|
Data = data,
|
||||||
@ -100,13 +94,10 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
AddStep("with zero values", () =>
|
AddStep("with zero values", () =>
|
||||||
{
|
{
|
||||||
graph.User.Value = new User
|
graph.Statistics.Value = new UserStatistics
|
||||||
{
|
{
|
||||||
Statistics = new UserStatistics
|
Ranks = new UserStatistics.UserRanks { Global = 89000 },
|
||||||
{
|
PP = 12345,
|
||||||
Ranks = new UserStatistics.UserRanks { Global = 89000 },
|
|
||||||
PP = 12345,
|
|
||||||
},
|
|
||||||
RankHistory = new User.RankHistoryData
|
RankHistory = new User.RankHistoryData
|
||||||
{
|
{
|
||||||
Data = dataWithZeros,
|
Data = dataWithZeros,
|
||||||
@ -116,13 +107,10 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
AddStep("small amount of data", () =>
|
AddStep("small amount of data", () =>
|
||||||
{
|
{
|
||||||
graph.User.Value = new User
|
graph.Statistics.Value = new UserStatistics
|
||||||
{
|
{
|
||||||
Statistics = new UserStatistics
|
Ranks = new UserStatistics.UserRanks { Global = 12000 },
|
||||||
{
|
PP = 12345,
|
||||||
Ranks = new UserStatistics.UserRanks { Global = 12000 },
|
|
||||||
PP = 12345,
|
|
||||||
},
|
|
||||||
RankHistory = new User.RankHistoryData
|
RankHistory = new User.RankHistoryData
|
||||||
{
|
{
|
||||||
Data = smallData,
|
Data = smallData,
|
||||||
@ -132,13 +120,10 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
AddStep("graph with edges", () =>
|
AddStep("graph with edges", () =>
|
||||||
{
|
{
|
||||||
graph.User.Value = new User
|
graph.Statistics.Value = new UserStatistics
|
||||||
{
|
{
|
||||||
Statistics = new UserStatistics
|
Ranks = new UserStatistics.UserRanks { Global = 12000 },
|
||||||
{
|
PP = 12345,
|
||||||
Ranks = new UserStatistics.UserRanks { Global = 12000 },
|
|
||||||
PP = 12345,
|
|
||||||
},
|
|
||||||
RankHistory = new User.RankHistoryData
|
RankHistory = new User.RankHistoryData
|
||||||
{
|
{
|
||||||
Data = edgyData,
|
Data = edgyData,
|
||||||
|
@ -50,12 +50,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
Current = 727,
|
Current = 727,
|
||||||
Progress = 69,
|
Progress = 69,
|
||||||
}
|
},
|
||||||
},
|
RankHistory = new User.RankHistoryData
|
||||||
RankHistory = new User.RankHistoryData
|
{
|
||||||
{
|
Mode = @"osu",
|
||||||
Mode = @"osu",
|
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
||||||
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
},
|
||||||
},
|
},
|
||||||
Badges = new[]
|
Badges = new[]
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
|
|
||||||
private KeyValuePair<int, int>[] ranks;
|
private KeyValuePair<int, int>[] ranks;
|
||||||
private int dayIndex;
|
private int dayIndex;
|
||||||
public Bindable<User> User = new Bindable<User>();
|
public readonly Bindable<UserStatistics> Statistics = new Bindable<UserStatistics>();
|
||||||
|
|
||||||
public RankGraph()
|
public RankGraph()
|
||||||
{
|
{
|
||||||
@ -56,8 +56,6 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
};
|
};
|
||||||
|
|
||||||
graph.OnBallMove += i => dayIndex = i;
|
graph.OnBallMove += i => dayIndex = i;
|
||||||
|
|
||||||
User.ValueChanged += userChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -66,18 +64,25 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
graph.LineColour = colours.Yellow;
|
graph.LineColour = colours.Yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void userChanged(ValueChangedEvent<User> e)
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
Statistics.BindValueChanged(statistics => updateStatistics(statistics.NewValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStatistics(UserStatistics statistics)
|
||||||
{
|
{
|
||||||
placeholder.FadeIn(fade_duration, Easing.Out);
|
placeholder.FadeIn(fade_duration, Easing.Out);
|
||||||
|
|
||||||
if (e.NewValue?.Statistics?.Ranks.Global == null)
|
if (statistics?.Ranks.Global == null)
|
||||||
{
|
{
|
||||||
graph.FadeOut(fade_duration, Easing.Out);
|
graph.FadeOut(fade_duration, Easing.Out);
|
||||||
ranks = null;
|
ranks = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] userRanks = e.NewValue.RankHistory?.Data ?? new[] { e.NewValue.Statistics.Ranks.Global.Value };
|
int[] userRanks = statistics.RankHistory?.Data ?? new[] { statistics.Ranks.Global.Value };
|
||||||
ranks = userRanks.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
|
ranks = userRanks.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
|
||||||
|
|
||||||
if (ranks.Length > 1)
|
if (ranks.Length > 1)
|
||||||
@ -191,7 +196,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TooltipText => User.Value?.Statistics?.Ranks.Global == null ? "" : $"#{ranks[dayIndex].Value:#,##0}|{ranked_days - ranks[dayIndex].Key + 1}";
|
public string TooltipText => Statistics.Value?.Ranks.Global == null ? "" : $"#{ranks[dayIndex].Value:#,##0}|{ranked_days - ranks[dayIndex].Key + 1}";
|
||||||
|
|
||||||
public ITooltip GetCustomTooltip() => new RankGraphTooltip();
|
public ITooltip GetCustomTooltip() => new RankGraphTooltip();
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
detailGlobalRank.Content = user?.Statistics?.Ranks.Global?.ToString("\\##,##0") ?? "-";
|
detailGlobalRank.Content = user?.Statistics?.Ranks.Global?.ToString("\\##,##0") ?? "-";
|
||||||
detailCountryRank.Content = user?.Statistics?.Ranks.Country?.ToString("\\##,##0") ?? "-";
|
detailCountryRank.Content = user?.Statistics?.Ranks.Country?.ToString("\\##,##0") ?? "-";
|
||||||
|
|
||||||
rankGraph.User.Value = user;
|
rankGraph.Statistics.Value = user?.Statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ScoreRankInfo : CompositeDrawable
|
private class ScoreRankInfo : CompositeDrawable
|
||||||
|
@ -159,7 +159,10 @@ namespace osu.Game.Users
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty(@"rankHistory")]
|
[JsonProperty(@"rankHistory")]
|
||||||
public RankHistoryData RankHistory;
|
private RankHistoryData rankHistory
|
||||||
|
{
|
||||||
|
set => Statistics.RankHistory = value;
|
||||||
|
}
|
||||||
|
|
||||||
[JsonProperty("badges")]
|
[JsonProperty("badges")]
|
||||||
public Badge[] Badges;
|
public Badge[] Badges;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using static osu.Game.Users.User;
|
||||||
|
|
||||||
namespace osu.Game.Users
|
namespace osu.Game.Users
|
||||||
{
|
{
|
||||||
@ -113,5 +114,7 @@ namespace osu.Game.Users
|
|||||||
[JsonProperty(@"country")]
|
[JsonProperty(@"country")]
|
||||||
public int? Country;
|
public int? Country;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RankHistoryData RankHistory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user