mirror of https://github.com/ppy/osu
Show available information in RankChart.
This commit is contained in:
parent
6967fb1105
commit
9e3935a732
|
@ -23,7 +23,7 @@ public class ProfileHeader : Container
|
||||||
private readonly OsuTextFlowContainer infoTextLeft, infoTextRight;
|
private readonly OsuTextFlowContainer infoTextLeft, infoTextRight;
|
||||||
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
|
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
|
||||||
|
|
||||||
private readonly Container coverContainer;
|
private readonly Container coverContainer, chartContainer;
|
||||||
private readonly Sprite levelBadge;
|
private readonly Sprite levelBadge;
|
||||||
private readonly SpriteText levelText;
|
private readonly SpriteText levelText;
|
||||||
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
|
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
|
||||||
|
@ -217,7 +217,7 @@ public ProfileHeader(User user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Container
|
chartContainer = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
|
@ -229,10 +229,6 @@ public ProfileHeader(User user)
|
||||||
{
|
{
|
||||||
Colour = Color4.Black.Opacity(0.25f),
|
Colour = Color4.Black.Opacity(0.25f),
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both
|
||||||
},
|
|
||||||
new RankChart(user)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,6 +323,8 @@ public void FillFullData(User user)
|
||||||
gradeS.Show();
|
gradeS.Show();
|
||||||
gradeA.Count = user.Statistics.GradesCount.A;
|
gradeA.Count = user.Statistics.GradesCount.A;
|
||||||
gradeA.Show();
|
gradeA.Show();
|
||||||
|
|
||||||
|
chartContainer.Add(new RankChart(user) { RelativeSizeAxes = Axes.Both });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
@ -23,8 +22,8 @@ public class RankChart : Container
|
||||||
private readonly SpriteText rankText, performanceText, relativeText;
|
private readonly SpriteText rankText, performanceText, relativeText;
|
||||||
private readonly RankChartLineGraph graph;
|
private readonly RankChartLineGraph graph;
|
||||||
|
|
||||||
private int[] ranks, performances;
|
private int[] ranks;
|
||||||
private int rank, performance, countryRank;
|
private decimal?[] performances;
|
||||||
|
|
||||||
private const float primary_textsize = 25, secondary_textsize = 13, padding = 10;
|
private const float primary_textsize = 25, secondary_textsize = 13, padding = 10;
|
||||||
|
|
||||||
|
@ -33,6 +32,7 @@ public class RankChart : Container
|
||||||
public RankChart(User user)
|
public RankChart(User user)
|
||||||
{
|
{
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
Padding = new MarginPadding { Vertical = padding };
|
Padding = new MarginPadding { Vertical = padding };
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -69,20 +69,22 @@ public RankChart(User user)
|
||||||
BallMove = showHistoryRankTexts
|
BallMove = showHistoryRankTexts
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
ranks = new[] { user.Statistics.Rank };
|
||||||
|
performances = new decimal?[] { user.Statistics.PP };
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRankTexts()
|
private void updateRankTexts()
|
||||||
{
|
{
|
||||||
rankText.Text = $"#{rank:#,#}";
|
rankText.Text = user.Statistics.Rank > 0 ? $"#{user.Statistics.Rank:#,0}" : "no rank";
|
||||||
performanceText.Text = $"{performance:#,#}pp";
|
performanceText.Text = user.Statistics.PP != null ? $"{user.Statistics.PP:#,0}pp" : string.Empty;
|
||||||
relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,#}";
|
//relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,0}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showHistoryRankTexts(int dayIndex)
|
private void showHistoryRankTexts(int dayIndex)
|
||||||
{
|
{
|
||||||
rankText.Text = $"#{ranks[dayIndex]:#,#}";
|
rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank";
|
||||||
performanceText.Text = $"{performances[dayIndex]:#,#}pp";
|
performanceText.Text = performances[dayIndex] != null ? $"{performances[dayIndex]:#,0}pp" : string.Empty;
|
||||||
relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
|
//relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
|
||||||
//plural should be handled in a general way
|
//plural should be handled in a general way
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,20 +92,10 @@ private void showHistoryRankTexts(int dayIndex)
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
graph.Colour = colours.Yellow;
|
graph.Colour = colours.Yellow;
|
||||||
Task.Factory.StartNew(() =>
|
|
||||||
{
|
|
||||||
System.Threading.Thread.Sleep(1000);
|
|
||||||
|
|
||||||
// put placeholder data here to show the transform
|
// use logarithmic coordinates
|
||||||
rank = 12345;
|
graph.Values = ranks.Select(x => -(float)Math.Log(x));
|
||||||
countryRank = 678;
|
graph.ResetBall();
|
||||||
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();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||||
|
|
Loading…
Reference in New Issue