2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-05-24 18:11:07 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-06-09 08:24:19 +00:00
|
|
|
|
using System.Linq;
|
2017-06-09 08:01:16 +00:00
|
|
|
|
using OpenTK;
|
2017-06-22 13:42:06 +00:00
|
|
|
|
using OpenTK.Graphics;
|
2017-06-09 06:25:23 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-06-22 13:42:06 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-06-05 13:04:35 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-06-22 13:42:06 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-21 08:03:47 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-06-09 06:25:23 +00:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2017-06-07 13:15:43 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2017-05-24 18:11:07 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-06-15 14:33:08 +00:00
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
2017-06-16 08:36:23 +00:00
|
|
|
|
using osu.Game.Overlays.Profile;
|
2017-07-13 04:53:45 +00:00
|
|
|
|
using osu.Game.Overlays.Profile.Sections;
|
2017-06-15 09:03:33 +00:00
|
|
|
|
using osu.Game.Users;
|
2017-05-24 18:11:07 +00:00
|
|
|
|
|
2017-06-15 09:03:33 +00:00
|
|
|
|
namespace osu.Game.Overlays
|
2017-05-24 18:11:07 +00:00
|
|
|
|
{
|
2017-06-22 12:38:43 +00:00
|
|
|
|
public class UserProfileOverlay : WaveOverlayContainer
|
2017-05-24 18:11:07 +00:00
|
|
|
|
{
|
2017-06-05 13:07:57 +00:00
|
|
|
|
private ProfileSection lastSection;
|
2017-06-25 02:40:45 +00:00
|
|
|
|
private ProfileSection[] sections;
|
2017-06-15 14:33:08 +00:00
|
|
|
|
private GetUserRequest userReq;
|
|
|
|
|
private APIAccess api;
|
2017-12-25 14:25:47 +00:00
|
|
|
|
protected ProfileHeader Header;
|
2017-06-25 02:40:45 +00:00
|
|
|
|
private SectionsContainer<ProfileSection> sectionsContainer;
|
|
|
|
|
private ProfileTabControl tabs;
|
2017-06-06 03:25:16 +00:00
|
|
|
|
|
2017-06-14 12:39:58 +00:00
|
|
|
|
public const float CONTENT_X_MARGIN = 50;
|
2017-06-16 08:13:23 +00:00
|
|
|
|
|
|
|
|
|
public UserProfileOverlay()
|
|
|
|
|
{
|
2017-06-22 12:38:43 +00:00
|
|
|
|
FirstWaveColour = OsuColour.Gray(0.4f);
|
|
|
|
|
SecondWaveColour = OsuColour.Gray(0.3f);
|
|
|
|
|
ThirdWaveColour = OsuColour.Gray(0.2f);
|
|
|
|
|
FourthWaveColour = OsuColour.Gray(0.1f);
|
|
|
|
|
|
2017-06-16 08:13:23 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
RelativePositionAxes = Axes.Both;
|
2017-06-22 13:42:06 +00:00
|
|
|
|
Width = 0.85f;
|
|
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
2017-06-23 02:54:32 +00:00
|
|
|
|
Colour = Color4.Black.Opacity(0),
|
2017-06-22 13:42:06 +00:00
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Radius = 10
|
|
|
|
|
};
|
2017-06-16 08:13:23 +00:00
|
|
|
|
}
|
2017-06-06 03:25:16 +00:00
|
|
|
|
|
2017-06-15 14:33:08 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(APIAccess api)
|
|
|
|
|
{
|
|
|
|
|
this.api = api;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-23 02:54:32 +00:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
2017-07-22 18:50:25 +00:00
|
|
|
|
FadeEdgeEffectTo(0.5f, APPEAR_DURATION, Easing.In);
|
2017-06-23 02:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
2017-07-22 18:50:25 +00:00
|
|
|
|
FadeEdgeEffectTo(0, DISAPPEAR_DURATION, Easing.Out);
|
2017-06-23 02:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-25 02:40:45 +00:00
|
|
|
|
public void ShowUser(User user, bool fetchOnline = true)
|
2017-05-24 18:11:07 +00:00
|
|
|
|
{
|
2017-06-15 14:33:08 +00:00
|
|
|
|
userReq?.Cancel();
|
2017-06-15 12:01:46 +00:00
|
|
|
|
Clear();
|
|
|
|
|
lastSection = null;
|
2017-06-15 14:33:08 +00:00
|
|
|
|
|
2017-06-25 02:40:45 +00:00
|
|
|
|
sections = new ProfileSection[]
|
2017-06-07 14:49:14 +00:00
|
|
|
|
{
|
2017-11-09 14:12:06 +00:00
|
|
|
|
//new AboutSection(),
|
2017-10-13 11:29:19 +00:00
|
|
|
|
//new RecentSection(),
|
2017-06-15 00:00:15 +00:00
|
|
|
|
new RanksSection(),
|
2017-10-13 11:29:19 +00:00
|
|
|
|
//new MedalsSection(),
|
2017-10-24 18:31:38 +00:00
|
|
|
|
new HistoricalSection(),
|
2017-11-03 17:25:21 +00:00
|
|
|
|
new BeatmapsSection(),
|
2017-11-18 15:19:35 +00:00
|
|
|
|
new KudosuSection()
|
2017-06-07 14:49:14 +00:00
|
|
|
|
};
|
2017-06-25 02:40:45 +00:00
|
|
|
|
tabs = new ProfileTabControl
|
2017-06-07 14:49:14 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-06-09 06:25:23 +00:00
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2017-06-14 23:23:30 +00:00
|
|
|
|
Height = 30
|
2017-06-07 14:49:14 +00:00
|
|
|
|
};
|
2017-06-07 13:15:43 +00:00
|
|
|
|
|
|
|
|
|
Add(new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.Gray(0.2f)
|
|
|
|
|
});
|
|
|
|
|
|
2017-12-25 14:25:47 +00:00
|
|
|
|
Header = new ProfileHeader(user);
|
2017-06-15 14:33:08 +00:00
|
|
|
|
|
2017-06-25 02:40:45 +00:00
|
|
|
|
Add(sectionsContainer = new SectionsContainer<ProfileSection>
|
2017-05-24 18:11:07 +00:00
|
|
|
|
{
|
2017-06-05 13:04:35 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-12-25 14:25:47 +00:00
|
|
|
|
ExpandableHeader = Header,
|
2017-06-09 06:25:23 +00:00
|
|
|
|
FixedHeader = tabs,
|
2017-06-07 14:11:38 +00:00
|
|
|
|
HeaderBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = OsuColour.Gray(34),
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2017-06-15 14:33:08 +00:00
|
|
|
|
}
|
2017-06-25 02:40:45 +00:00
|
|
|
|
});
|
2017-05-24 18:11:07 +00:00
|
|
|
|
sectionsContainer.SelectedSection.ValueChanged += s =>
|
|
|
|
|
{
|
|
|
|
|
if (lastSection != s)
|
|
|
|
|
{
|
2017-06-09 08:24:19 +00:00
|
|
|
|
lastSection = s;
|
2017-06-09 06:25:23 +00:00
|
|
|
|
tabs.Current.Value = lastSection;
|
2017-05-24 18:11:07 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-06-09 06:25:23 +00:00
|
|
|
|
tabs.Current.ValueChanged += s =>
|
2017-05-24 18:11:07 +00:00
|
|
|
|
{
|
2017-06-09 08:05:05 +00:00
|
|
|
|
if (lastSection == null)
|
|
|
|
|
{
|
2017-06-09 08:24:19 +00:00
|
|
|
|
lastSection = sectionsContainer.Children.FirstOrDefault();
|
|
|
|
|
if (lastSection != null)
|
|
|
|
|
tabs.Current.Value = lastSection;
|
2017-06-09 08:05:05 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2017-05-24 18:11:07 +00:00
|
|
|
|
if (lastSection != s)
|
|
|
|
|
{
|
|
|
|
|
lastSection = s;
|
2017-07-14 14:56:27 +00:00
|
|
|
|
sectionsContainer.ScrollTo(lastSection);
|
2017-05-24 18:11:07 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-06-15 14:33:08 +00:00
|
|
|
|
|
2017-06-25 02:40:45 +00:00
|
|
|
|
if (fetchOnline)
|
|
|
|
|
{
|
|
|
|
|
userReq = new GetUserRequest(user.Id);
|
2017-07-17 04:56:50 +00:00
|
|
|
|
userReq.Success += userLoadComplete;
|
2017-06-25 02:40:45 +00:00
|
|
|
|
api.Queue(userReq);
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-06-15 14:33:08 +00:00
|
|
|
|
{
|
2017-06-25 02:40:45 +00:00
|
|
|
|
userReq = null;
|
2017-07-17 04:56:50 +00:00
|
|
|
|
userLoadComplete(user);
|
2017-06-25 02:40:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Show();
|
2017-11-15 10:01:30 +00:00
|
|
|
|
sectionsContainer.ScrollToTop();
|
2017-06-25 02:40:45 +00:00
|
|
|
|
}
|
2017-06-15 15:47:34 +00:00
|
|
|
|
|
2017-07-17 04:56:50 +00:00
|
|
|
|
private void userLoadComplete(User user)
|
2017-06-25 02:40:45 +00:00
|
|
|
|
{
|
2017-12-25 14:25:47 +00:00
|
|
|
|
Header.User = user;
|
2017-06-25 02:40:45 +00:00
|
|
|
|
|
2017-08-05 10:01:10 +00:00
|
|
|
|
foreach (string id in user.ProfileOrder)
|
2017-06-25 02:40:45 +00:00
|
|
|
|
{
|
|
|
|
|
var sec = sections.FirstOrDefault(s => s.Identifier == id);
|
|
|
|
|
if (sec != null)
|
2017-06-22 12:23:49 +00:00
|
|
|
|
{
|
2017-10-25 18:07:12 +00:00
|
|
|
|
sec.User.Value = user;
|
2017-09-14 11:05:43 +00:00
|
|
|
|
|
2017-06-25 02:40:45 +00:00
|
|
|
|
sectionsContainer.Add(sec);
|
|
|
|
|
tabs.AddItem(sec);
|
2017-06-22 12:23:49 +00:00
|
|
|
|
}
|
2017-06-25 02:40:45 +00:00
|
|
|
|
}
|
2017-05-24 18:11:07 +00:00
|
|
|
|
}
|
2017-06-09 06:25:23 +00:00
|
|
|
|
|
2017-06-09 08:01:16 +00:00
|
|
|
|
private class ProfileTabControl : PageTabControl<ProfileSection>
|
2017-06-09 06:25:23 +00:00
|
|
|
|
{
|
2017-06-09 08:01:16 +00:00
|
|
|
|
private readonly Box bottom;
|
2017-06-09 06:25:23 +00:00
|
|
|
|
|
|
|
|
|
public ProfileTabControl()
|
|
|
|
|
{
|
|
|
|
|
TabContainer.RelativeSizeAxes &= ~Axes.X;
|
|
|
|
|
TabContainer.AutoSizeAxes |= Axes.X;
|
|
|
|
|
TabContainer.Anchor |= Anchor.x1;
|
|
|
|
|
TabContainer.Origin |= Anchor.x1;
|
2017-06-09 08:01:16 +00:00
|
|
|
|
Add(bottom = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 1,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
EdgeSmoothness = new Vector2(1)
|
|
|
|
|
});
|
2017-06-09 06:25:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override TabItem<ProfileSection> CreateTabItem(ProfileSection value) => new ProfileTabItem(value);
|
|
|
|
|
|
2017-06-15 14:42:15 +00:00
|
|
|
|
protected override Dropdown<ProfileSection> CreateDropdown() => null;
|
|
|
|
|
|
2017-06-09 08:01:16 +00:00
|
|
|
|
private class ProfileTabItem : PageTabItem
|
2017-06-09 06:25:23 +00:00
|
|
|
|
{
|
|
|
|
|
public ProfileTabItem(ProfileSection value) : base(value)
|
|
|
|
|
{
|
|
|
|
|
Text.Text = value.Title;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-09 08:01:16 +00:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
bottom.Colour = colours.Yellow;
|
|
|
|
|
}
|
2017-06-09 06:25:23 +00:00
|
|
|
|
}
|
2017-05-24 18:11:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|