Show available information in RankChart.

This commit is contained in:
Huo Yaoyuan 2017-06-16 14:34:08 +08:00
parent 6967fb1105
commit 9e3935a732
2 changed files with 18 additions and 28 deletions

View File

@ -23,7 +23,7 @@ public class ProfileHeader : Container
private readonly OsuTextFlowContainer infoTextLeft, infoTextRight;
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
private readonly Container coverContainer;
private readonly Container coverContainer, chartContainer;
private readonly Sprite levelBadge;
private readonly SpriteText levelText;
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
@ -217,7 +217,7 @@ public ProfileHeader(User user)
}
}
},
new Container
chartContainer = new Container
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.BottomCentre,
@ -229,10 +229,6 @@ public ProfileHeader(User user)
{
Colour = Color4.Black.Opacity(0.25f),
RelativeSizeAxes = Axes.Both
},
new RankChart(user)
{
RelativeSizeAxes = Axes.Both
}
}
}
@ -327,6 +323,8 @@ public void FillFullData(User user)
gradeS.Show();
gradeA.Count = user.Statistics.GradesCount.A;
gradeA.Show();
chartContainer.Add(new RankChart(user) { RelativeSizeAxes = Axes.Both });
}
}

View File

@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -23,8 +22,8 @@ public class RankChart : Container
private readonly SpriteText rankText, performanceText, relativeText;
private readonly RankChartLineGraph graph;
private int[] ranks, performances;
private int rank, performance, countryRank;
private int[] ranks;
private decimal?[] performances;
private const float primary_textsize = 25, secondary_textsize = 13, padding = 10;
@ -33,6 +32,7 @@ public class RankChart : Container
public RankChart(User user)
{
this.user = user;
Padding = new MarginPadding { Vertical = padding };
Children = new Drawable[]
{
@ -69,20 +69,22 @@ public RankChart(User user)
BallMove = showHistoryRankTexts
}
};
ranks = new[] { user.Statistics.Rank };
performances = new decimal?[] { user.Statistics.PP };
}
private void updateRankTexts()
{
rankText.Text = $"#{rank:#,#}";
performanceText.Text = $"{performance:#,#}pp";
relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,#}";
rankText.Text = user.Statistics.Rank > 0 ? $"#{user.Statistics.Rank:#,0}" : "no rank";
performanceText.Text = user.Statistics.PP != null ? $"{user.Statistics.PP:#,0}pp" : string.Empty;
//relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,0}";
}
private void showHistoryRankTexts(int dayIndex)
{
rankText.Text = $"#{ranks[dayIndex]:#,#}";
performanceText.Text = $"{performances[dayIndex]:#,#}pp";
relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank";
performanceText.Text = performances[dayIndex] != null ? $"{performances[dayIndex]:#,0}pp" : string.Empty;
//relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
//plural should be handled in a general way
}
@ -90,20 +92,10 @@ private void showHistoryRankTexts(int dayIndex)
private void load(OsuColour colours)
{
graph.Colour = colours.Yellow;
Task.Factory.StartNew(() =>
{
System.Threading.Thread.Sleep(1000);
// put placeholder data here to show the transform
rank = 12345;
countryRank = 678;
performance = 4567;
ranks = Enumerable.Range(1234, 80).ToArray();
performances = ranks.Select(x => 6000 - x).ToArray();
// use logarithmic coordinates
graph.Values = ranks.Select(x => -(float)Math.Log(x));
graph.ResetBall();
});
// use logarithmic coordinates
graph.Values = ranks.Select(x => -(float)Math.Log(x));
graph.ResetBall();
}
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)