2017-05-25 02:11:07 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-06-13 03:31:17 +08:00
|
|
|
|
using System;
|
2017-06-06 11:25:16 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-06-14 12:55:01 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-06-06 11:25:16 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
2017-06-13 19:43:56 +08:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2017-05-25 02:11:07 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-13 03:31:17 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-06-14 12:55:01 +08:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2017-06-13 03:31:17 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-06-06 11:25:16 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-25 02:11:07 +08:00
|
|
|
|
|
2017-06-05 21:07:57 +08:00
|
|
|
|
namespace osu.Game.Users.Profile
|
2017-05-25 02:11:07 +08:00
|
|
|
|
{
|
2017-06-09 14:53:30 +08:00
|
|
|
|
public class ProfileHeader : Container
|
2017-05-25 02:11:07 +08:00
|
|
|
|
{
|
2017-05-27 23:37:15 +08:00
|
|
|
|
private readonly User user;
|
2017-06-06 11:25:16 +08:00
|
|
|
|
|
2017-06-13 03:31:17 +08:00
|
|
|
|
private readonly OsuTextFlowContainer infoText;
|
2017-06-14 12:55:01 +08:00
|
|
|
|
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
|
|
|
|
|
|
|
|
|
|
private readonly Sprite levelBadge;
|
|
|
|
|
private readonly SpriteText levelText;
|
2017-06-14 14:35:47 +08:00
|
|
|
|
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
|
2017-06-13 03:31:17 +08:00
|
|
|
|
|
2017-06-13 19:43:56 +08:00
|
|
|
|
private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60;
|
2017-06-09 14:53:30 +08:00
|
|
|
|
public ProfileHeader(User user)
|
2017-05-27 23:37:15 +08:00
|
|
|
|
{
|
|
|
|
|
this.user = user;
|
2017-06-06 11:25:16 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-06-14 20:39:58 +08:00
|
|
|
|
Height = cover_height + info_height;
|
2017-06-06 11:25:16 +08:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = cover_height,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new AsyncLoadWrapper(new UserCoverBackground(user)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
|
OnLoadComplete = d => d.FadeInFromZero(200)
|
2017-06-07 22:11:38 +08:00
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Masking = true,
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
2017-06-13 19:43:56 +08:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColourInfo = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f))
|
|
|
|
|
},
|
2017-06-06 11:25:16 +08:00
|
|
|
|
new UpdateableAvatar
|
|
|
|
|
{
|
|
|
|
|
User = user,
|
|
|
|
|
Size = new Vector2(avatar_size),
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
X = UserProfile.CONTENT_X_MARGIN,
|
|
|
|
|
Y = avatar_bottom_position,
|
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = 5,
|
2017-06-12 14:42:14 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2017-06-06 11:25:16 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
|
Radius = 4,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
X = UserProfile.CONTENT_X_MARGIN + avatar_size + 10,
|
|
|
|
|
Y = avatar_bottom_position,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = user.Username,
|
2017-06-15 07:23:30 +08:00
|
|
|
|
TextSize = 30,
|
2017-06-06 11:25:16 +08:00
|
|
|
|
Font = @"Exo2.0-RegularItalic",
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Y = -55
|
|
|
|
|
},
|
|
|
|
|
new DrawableFlag(user.Country?.FlagName ?? "__")
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Width = 30,
|
|
|
|
|
Height = 20
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-13 03:31:17 +08:00
|
|
|
|
},
|
|
|
|
|
infoText = new OsuTextFlowContainer(t =>
|
|
|
|
|
{
|
2017-06-14 20:39:58 +08:00
|
|
|
|
t.TextSize = 14;
|
2017-06-13 03:31:17 +08:00
|
|
|
|
t.Alpha = 0.8f;
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Y = cover_height + 20,
|
|
|
|
|
Margin = new MarginPadding { Horizontal = UserProfile.CONTENT_X_MARGIN },
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-06-13 19:43:56 +08:00
|
|
|
|
ParagraphSpacing = 1
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
X = -UserProfile.CONTENT_X_MARGIN,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = 280,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Y = level_position,
|
|
|
|
|
Height = level_height,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.5f),
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2017-06-14 12:55:01 +08:00
|
|
|
|
},
|
|
|
|
|
levelBadge = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Height = 50,
|
|
|
|
|
Width = 50
|
|
|
|
|
},
|
|
|
|
|
levelText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Y = 11,
|
2017-06-15 07:23:30 +08:00
|
|
|
|
TextSize = 20
|
2017-06-13 19:43:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Y = cover_height,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Height = cover_height - level_height - level_position - 5,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.5f),
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2017-06-14 12:55:01 +08:00
|
|
|
|
},
|
|
|
|
|
scoreText = new FillFlowContainer<SpriteText>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Padding = new MarginPadding { Horizontal = 20, Vertical = 18 },
|
|
|
|
|
Spacing = new Vector2(0, 2)
|
|
|
|
|
},
|
|
|
|
|
scoreNumberText = new FillFlowContainer<SpriteText>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Padding = new MarginPadding { Horizontal = 20, Vertical = 18 },
|
|
|
|
|
Spacing = new Vector2(0, 2)
|
2017-06-14 14:35:47 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer<GradeBadge>
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Y = -64,
|
|
|
|
|
Spacing = new Vector2(20, 0),
|
|
|
|
|
Children = new GradeBadge[]
|
|
|
|
|
{
|
|
|
|
|
gradeSSPlus = new GradeBadge("SSPlus") { Count = 12 },
|
|
|
|
|
gradeSS = new GradeBadge("SS") { Count = 34 },
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer<GradeBadge>
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Y = -18,
|
|
|
|
|
Spacing = new Vector2(20, 0),
|
|
|
|
|
Children = new GradeBadge[]
|
|
|
|
|
{
|
|
|
|
|
gradeSPlus = new GradeBadge("SPlus") { Count = 567 },
|
|
|
|
|
gradeS = new GradeBadge("S") { Count = 890 },
|
|
|
|
|
gradeA = new GradeBadge("A") { Count = 1234 },
|
|
|
|
|
}
|
2017-06-13 19:43:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
2017-06-14 20:39:58 +08:00
|
|
|
|
Height = info_height - 15,
|
2017-06-13 19:43:56 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2017-06-15 00:48:01 +08:00
|
|
|
|
},
|
|
|
|
|
new RankChart(user)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2017-06-13 19:43:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-06 11:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-06-13 03:31:17 +08:00
|
|
|
|
|
|
|
|
|
Action<SpriteText> bold = t =>
|
|
|
|
|
{
|
|
|
|
|
t.Font = @"Exo2.0-Bold";
|
|
|
|
|
t.Alpha = 1;
|
|
|
|
|
};
|
|
|
|
|
// placeholder text
|
|
|
|
|
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);
|
2017-06-14 12:55:01 +08:00
|
|
|
|
|
|
|
|
|
levelText.Text = "98";
|
|
|
|
|
|
|
|
|
|
scoreText.Add(createScoreText("Ranked Score"));
|
|
|
|
|
scoreNumberText.Add(createScoreNumberText("1,870,716,897"));
|
|
|
|
|
scoreText.Add(createScoreText("Accuracy"));
|
|
|
|
|
scoreNumberText.Add(createScoreNumberText("98.51%"));
|
|
|
|
|
scoreText.Add(createScoreText("Play Count"));
|
|
|
|
|
scoreNumberText.Add(createScoreNumberText("25,287"));
|
|
|
|
|
scoreText.Add(createScoreText("Total Score"));
|
|
|
|
|
scoreNumberText.Add(createScoreNumberText("28,444,797,570"));
|
|
|
|
|
scoreText.Add(createScoreText("Total Hits"));
|
|
|
|
|
scoreNumberText.Add(createScoreNumberText("4,612,765"));
|
|
|
|
|
scoreText.Add(createScoreText("Max Combo"));
|
|
|
|
|
scoreNumberText.Add(createScoreNumberText("2,056"));
|
|
|
|
|
scoreText.Add(createScoreText("Replay Watched"));
|
|
|
|
|
scoreNumberText.Add(createScoreNumberText("23"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(TextureStore textures)
|
|
|
|
|
{
|
|
|
|
|
levelBadge.Texture = textures.Get(@"Profile/levelbadge");
|
2017-05-27 23:37:15 +08:00
|
|
|
|
}
|
2017-06-14 12:55:01 +08:00
|
|
|
|
|
|
|
|
|
private OsuSpriteText createScoreText(string text) => new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
TextSize = 14,
|
|
|
|
|
Text = text
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private OsuSpriteText createScoreNumberText(string text) => new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
TextSize = 14,
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Text = text
|
|
|
|
|
};
|
2017-06-14 14:35:47 +08:00
|
|
|
|
|
|
|
|
|
private class GradeBadge : Container
|
|
|
|
|
{
|
|
|
|
|
private const float width = 50;
|
|
|
|
|
private readonly string grade;
|
|
|
|
|
private readonly Sprite badge;
|
|
|
|
|
private readonly SpriteText numberText;
|
|
|
|
|
|
|
|
|
|
public int Count
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
numberText.Text = value.ToString(@"#,#");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GradeBadge(string grade)
|
|
|
|
|
{
|
|
|
|
|
this.grade = grade;
|
|
|
|
|
Width = width;
|
|
|
|
|
Height = 41;
|
|
|
|
|
Add(badge = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Width = width,
|
|
|
|
|
Height = 26
|
|
|
|
|
});
|
|
|
|
|
Add(numberText = new SpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
TextSize = 14,
|
|
|
|
|
Font = @"Exo2.0-Bold"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(TextureStore textures)
|
|
|
|
|
{
|
|
|
|
|
badge.Texture = textures.Get($"Grades/{grade}");
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-25 02:11:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|