1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:47:25 +08:00

Make data nullable

This commit is contained in:
Andrei Zavatski 2020-03-09 19:42:35 +03:00
parent 432c52bf27
commit 06855c09c7
2 changed files with 6 additions and 14 deletions

View File

@ -42,13 +42,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{
int[] userRanks = statistics?.RankHistory?.Data;
if (userRanks == null)
{
Data = null;
return;
}
Data = userRanks.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
Data = userRanks?.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
}
protected override float GetDataPointHeight(int rank) => -MathF.Log(rank);

View File

@ -27,8 +27,6 @@ namespace osu.Game.Overlays.Profile
protected UserGraph()
{
data = Array.Empty<KeyValuePair<TKey, TValue>>();
Add(graph = new UserLineGraph
{
RelativeSizeAxes = Axes.Both,
@ -46,7 +44,7 @@ namespace osu.Game.Overlays.Profile
protected override bool OnHover(HoverEvent e)
{
if (data.Length > 1)
if (data?.Length > 1)
{
graph.UpdateBallPosition(e.MousePosition.X);
graph.ShowBar();
@ -59,7 +57,7 @@ namespace osu.Game.Overlays.Profile
protected override bool OnMouseMove(MouseMoveEvent e)
{
if (data.Length > 1)
if (data?.Length > 1)
graph.UpdateBallPosition(e.MousePosition.X);
return base.OnMouseMove(e);
@ -67,7 +65,7 @@ namespace osu.Game.Overlays.Profile
protected override void OnHoverLost(HoverLostEvent e)
{
if (data.Length > 1)
if (data?.Length > 1)
graph.HideBar();
base.OnHoverLost(e);
@ -85,7 +83,7 @@ namespace osu.Game.Overlays.Profile
private void redrawGraph()
{
if (data.Length == 0)
if (!data?.Any() ?? true)
{
HideGraph();
return;
@ -108,7 +106,7 @@ namespace osu.Game.Overlays.Profile
{
get
{
if (data.Length == 0)
if (!data?.Any() ?? true)
return null;
var (key, value) = data[dataIndex];