1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 20:23:00 +08:00

Fill user informations.

This commit is contained in:
Huo Yaoyuan 2017-06-16 13:27:22 +08:00
parent a7e3157363
commit 6967fb1105

View File

@ -20,7 +20,7 @@ namespace osu.Game.Users.Profile
{ {
public class ProfileHeader : Container public class ProfileHeader : Container
{ {
private readonly OsuTextFlowContainer infoText; 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;
@ -28,7 +28,7 @@ namespace osu.Game.Users.Profile
private readonly SpriteText levelText; private readonly SpriteText levelText;
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; private const float cover_height = 350, info_height = 150, info_width = 250, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60;
public ProfileHeader(User user) public ProfileHeader(User user)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -92,17 +92,31 @@ namespace osu.Game.Users.Profile
} }
} }
}, },
infoText = new OsuTextFlowContainer(t => infoTextLeft = new OsuTextFlowContainer(t =>
{ {
t.TextSize = 14; t.TextSize = 14;
t.Alpha = 0.8f; t.Alpha = 0.8f;
}) })
{ {
X = UserProfileOverlay.CONTENT_X_MARGIN,
Y = cover_height + 20, Y = cover_height + 20,
Margin = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN }, Width = info_width,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
ParagraphSpacing = 1 ParagraphSpacing = 0.8f,
LineSpacing = 0.2f
},
infoTextRight = new OsuTextFlowContainer(t =>
{
t.TextSize = 14;
t.Alpha = 0.8f;
})
{
X = UserProfileOverlay.CONTENT_X_MARGIN + info_width + 20,
Y = cover_height + 20,
Width = info_width,
AutoSizeAxes = Axes.Y,
ParagraphSpacing = 0.8f,
LineSpacing = 0.2f
}, },
new Container new Container
{ {
@ -231,33 +245,6 @@ namespace osu.Game.Users.Profile
private void load(TextureStore textures) private void load(TextureStore textures)
{ {
levelBadge.Texture = textures.Get(@"Profile/levelbadge"); levelBadge.Texture = textures.Get(@"Profile/levelbadge");
Action<SpriteText> bold = t =>
{
t.Font = @"Exo2.0-Bold";
t.Alpha = 1;
};
// fill placeholder texts
infoText.AddTextAwesome(FontAwesome.fa_map_marker);
infoText.AddText(" position ");
infoText.AddTextAwesome(FontAwesome.fa_twitter);
infoText.AddText(" tweet ");
infoText.AddTextAwesome(FontAwesome.fa_heart_o);
infoText.AddText(" favorite ");
infoText.NewParagraph();
infoText.AddText("0 years old");
infoText.NewLine();
infoText.AddText("Commander of ");
infoText.AddText("The Color Scribbles", bold);
infoText.NewParagraph();
infoText.AddText("Joined since ");
infoText.AddText("June 2017", bold);
infoText.NewLine();
infoText.AddText("Last seen ");
infoText.AddText("0 minutes ago", bold);
infoText.NewParagraph();
infoText.AddText("Play with ");
infoText.AddText("Mouse, Keyboard, Tablet", bold);
} }
public void FillFullData(User user) public void FillFullData(User user)
@ -275,32 +262,76 @@ namespace osu.Game.Users.Profile
Depth = float.MaxValue Depth = float.MaxValue
}); });
levelBadge.Show(); Action<SpriteText> boldItalic = t =>
levelText.Text = user.Statistics.Level.Current.ToString(); {
t.Font = @"Exo2.0-BoldItalic";
t.Alpha = 1;
};
scoreText.Add(createScoreText("Ranked Score")); if (user.Age != null)
scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); {
scoreText.Add(createScoreText("Accuracy")); infoTextLeft.AddText($"{user.Age} years old", boldItalic);
scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%")); }
scoreText.Add(createScoreText("Play Count")); if (user.Country != null)
scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); {
scoreText.Add(createScoreText("Total Score")); infoTextLeft.AddText(" from ");
scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalScore.ToString(@"#,0"))); infoTextLeft.AddText(user.Country.FullName, boldItalic);
scoreText.Add(createScoreText("Total Hits")); }
scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalHits.ToString(@"#,0"))); infoTextLeft.NewParagraph();
scoreText.Add(createScoreText("Max Combo"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.MaxCombo.ToString(@"#,0")));
scoreText.Add(createScoreText("Replay Watched by Others"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.ReplayWatched.ToString(@"#,0")));
gradeSS.Count = user.Statistics.GradesCount.SS; infoTextLeft.AddText("Joined ");
gradeSS.Show(); infoTextLeft.AddText(user.JoinDate, boldItalic);
gradeS.Count = user.Statistics.GradesCount.S; infoTextLeft.NewLine();
gradeS.Show(); infoTextLeft.AddText("Last seen ");
gradeA.Count = user.Statistics.GradesCount.A; infoTextLeft.AddText(user.LastVisit.LocalDateTime.ToShortDateString(), boldItalic);
gradeA.Show(); infoTextLeft.NewParagraph();
if (user.PlayStyle?.Length > 0)
{
infoTextLeft.AddText("Plays with ");
infoTextLeft.AddText(string.Join(", ", user.PlayStyle), boldItalic);
}
tryAddInfoRightLine(FontAwesome.fa_map_marker, user.Location);
tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Intrerests);
tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation);
infoTextRight.NewParagraph();
if (!string.IsNullOrEmpty(user.Twitter))
tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter);
tryAddInfoRightLine(FontAwesome.fa_globe, user.Website);
tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype);
if (user.Statistics != null)
{
levelBadge.Show();
levelText.Text = user.Statistics.Level.Current.ToString();
scoreText.Add(createScoreText("Ranked Score"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0")));
scoreText.Add(createScoreText("Accuracy"));
scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%"));
scoreText.Add(createScoreText("Play Count"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0")));
scoreText.Add(createScoreText("Total Score"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalScore.ToString(@"#,0")));
scoreText.Add(createScoreText("Total Hits"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalHits.ToString(@"#,0")));
scoreText.Add(createScoreText("Max Combo"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.MaxCombo.ToString(@"#,0")));
scoreText.Add(createScoreText("Replay Watched by Others"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.ReplayWatched.ToString(@"#,0")));
gradeSS.Count = user.Statistics.GradesCount.SS;
gradeSS.Show();
gradeS.Count = user.Statistics.GradesCount.S;
gradeS.Show();
gradeA.Count = user.Statistics.GradesCount.A;
gradeA.Show();
}
} }
// These could be local functions when C# 7 enabled
private OsuSpriteText createScoreText(string text) => new OsuSpriteText private OsuSpriteText createScoreText(string text) => new OsuSpriteText
{ {
TextSize = 14, TextSize = 14,
@ -316,6 +347,18 @@ namespace osu.Game.Users.Profile
Text = text Text = text
}; };
private void tryAddInfoRightLine(FontAwesome icon, string str)
{
if (string.IsNullOrEmpty(str)) return;
infoTextRight.AddTextAwesome(icon);
infoTextRight.AddText(" " + str, t =>
{
t.Font = @"Exo2.0-RegularItalic";
t.Alpha = 1;
});
infoTextRight.NewLine();
}
private class GradeBadge : Container private class GradeBadge : Container
{ {
private const float width = 50; private const float width = 50;