1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Fetch latest user data.

This commit is contained in:
Huo Yaoyuan 2017-06-15 22:33:08 +08:00
parent 273e2b4a3c
commit f03530cdd2
2 changed files with 31 additions and 5 deletions

View File

@ -11,6 +11,8 @@ using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Users; using osu.Game.Users;
using osu.Game.Users.Profile; using osu.Game.Users.Profile;
@ -19,13 +21,23 @@ namespace osu.Game.Overlays
public class UserProfileOverlay : WaveOverlayContainer public class UserProfileOverlay : WaveOverlayContainer
{ {
private ProfileSection lastSection; private ProfileSection lastSection;
private GetUserRequest userReq;
private APIAccess api;
public const float CONTENT_X_MARGIN = 50; public const float CONTENT_X_MARGIN = 50;
[BackgroundDependencyLoader]
private void load(APIAccess api)
{
this.api = api;
}
public void ShowUser(User user) public void ShowUser(User user)
{ {
userReq?.Cancel();
Clear(); Clear();
lastSection = null; lastSection = null;
var sections = new ProfileSection[] var sections = new ProfileSection[]
{ {
new AboutSection(), new AboutSection(),
@ -43,7 +55,6 @@ namespace osu.Game.Overlays
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Height = 30 Height = 30
}; };
sections.ForEach(tabs.AddItem);
Add(new Box Add(new Box
{ {
@ -51,20 +62,20 @@ namespace osu.Game.Overlays
Colour = OsuColour.Gray(0.2f) Colour = OsuColour.Gray(0.2f)
}); });
var header = new ProfileHeader(user);
var sectionsContainer = new SectionsContainer<ProfileSection> var sectionsContainer = new SectionsContainer<ProfileSection>
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ExpandableHeader = new ProfileHeader(user), ExpandableHeader = header,
FixedHeader = tabs, FixedHeader = tabs,
HeaderBackground = new Box HeaderBackground = new Box
{ {
Colour = OsuColour.Gray(34), Colour = OsuColour.Gray(34),
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}, }
Children = sections
}; };
Add(sectionsContainer); Add(sectionsContainer);
sectionsContainer.SelectedSection.ValueChanged += s => sectionsContainer.SelectedSection.ValueChanged += s =>
{ {
if (lastSection != s) if (lastSection != s)
@ -89,6 +100,16 @@ namespace osu.Game.Overlays
sectionsContainer.ScrollContainer.ScrollIntoView(lastSection); sectionsContainer.ScrollContainer.ScrollIntoView(lastSection);
} }
}; };
userReq = new GetUserRequest(user.Id); //fetch latest full data
userReq.Success += u =>
{
header.FillFullData(u);
sectionsContainer.Children = sections;
sections.ForEach(tabs.AddItem);
};
api.Queue(userReq);
Show(); Show();
} }

View File

@ -295,6 +295,11 @@ namespace osu.Game.Users.Profile
gradeA.Count = 1234; gradeA.Count = 1234;
} }
public void FillFullData(User user)
{
}
private OsuSpriteText createScoreText(string text) => new OsuSpriteText private OsuSpriteText createScoreText(string text) => new OsuSpriteText
{ {
TextSize = 14, TextSize = 14,