From f03530cdd2bf31681a0fdfdae2b7e148f8bd6891 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 22:33:08 +0800 Subject: [PATCH] Fetch latest user data. --- osu.Game/Overlays/UserProfileOverlay.cs | 31 +++++++++++++++++++++---- osu.Game/Users/Profile/ProfileHeader.cs | 5 ++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index d0c5726cdc..d630e11a99 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -11,6 +11,8 @@ using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Users; using osu.Game.Users.Profile; @@ -19,13 +21,23 @@ namespace osu.Game.Overlays public class UserProfileOverlay : WaveOverlayContainer { private ProfileSection lastSection; + private GetUserRequest userReq; + private APIAccess api; public const float CONTENT_X_MARGIN = 50; + [BackgroundDependencyLoader] + private void load(APIAccess api) + { + this.api = api; + } + public void ShowUser(User user) { + userReq?.Cancel(); Clear(); lastSection = null; + var sections = new ProfileSection[] { new AboutSection(), @@ -43,7 +55,6 @@ namespace osu.Game.Overlays Origin = Anchor.TopCentre, Height = 30 }; - sections.ForEach(tabs.AddItem); Add(new Box { @@ -51,20 +62,20 @@ namespace osu.Game.Overlays Colour = OsuColour.Gray(0.2f) }); + var header = new ProfileHeader(user); + var sectionsContainer = new SectionsContainer { RelativeSizeAxes = Axes.Both, - ExpandableHeader = new ProfileHeader(user), + ExpandableHeader = header, FixedHeader = tabs, HeaderBackground = new Box { Colour = OsuColour.Gray(34), RelativeSizeAxes = Axes.Both - }, - Children = sections + } }; Add(sectionsContainer); - sectionsContainer.SelectedSection.ValueChanged += s => { if (lastSection != s) @@ -89,6 +100,16 @@ namespace osu.Game.Overlays 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(); } diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 43d86950fb..628767271a 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -295,6 +295,11 @@ namespace osu.Game.Users.Profile gradeA.Count = 1234; } + public void FillFullData(User user) + { + + } + private OsuSpriteText createScoreText(string text) => new OsuSpriteText { TextSize = 14,