mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 22:47:26 +08:00
Make data nullable
This commit is contained in:
parent
432c52bf27
commit
06855c09c7
@ -42,13 +42,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
{
|
{
|
||||||
int[] userRanks = statistics?.RankHistory?.Data;
|
int[] userRanks = statistics?.RankHistory?.Data;
|
||||||
|
|
||||||
if (userRanks == null)
|
Data = userRanks?.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
|
||||||
{
|
|
||||||
Data = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
protected override float GetDataPointHeight(int rank) => -MathF.Log(rank);
|
||||||
|
@ -27,8 +27,6 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
protected UserGraph()
|
protected UserGraph()
|
||||||
{
|
{
|
||||||
data = Array.Empty<KeyValuePair<TKey, TValue>>();
|
|
||||||
|
|
||||||
Add(graph = new UserLineGraph
|
Add(graph = new UserLineGraph
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -46,7 +44,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
if (data.Length > 1)
|
if (data?.Length > 1)
|
||||||
{
|
{
|
||||||
graph.UpdateBallPosition(e.MousePosition.X);
|
graph.UpdateBallPosition(e.MousePosition.X);
|
||||||
graph.ShowBar();
|
graph.ShowBar();
|
||||||
@ -59,7 +57,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
{
|
{
|
||||||
if (data.Length > 1)
|
if (data?.Length > 1)
|
||||||
graph.UpdateBallPosition(e.MousePosition.X);
|
graph.UpdateBallPosition(e.MousePosition.X);
|
||||||
|
|
||||||
return base.OnMouseMove(e);
|
return base.OnMouseMove(e);
|
||||||
@ -67,7 +65,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
if (data.Length > 1)
|
if (data?.Length > 1)
|
||||||
graph.HideBar();
|
graph.HideBar();
|
||||||
|
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
@ -85,7 +83,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
private void redrawGraph()
|
private void redrawGraph()
|
||||||
{
|
{
|
||||||
if (data.Length == 0)
|
if (!data?.Any() ?? true)
|
||||||
{
|
{
|
||||||
HideGraph();
|
HideGraph();
|
||||||
return;
|
return;
|
||||||
@ -108,7 +106,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (data.Length == 0)
|
if (!data?.Any() ?? true)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var (key, value) = data[dataIndex];
|
var (key, value) = data[dataIndex];
|
||||||
|
Loading…
Reference in New Issue
Block a user