osu/osu.Game/Users/UserProfile.cs

82 lines
2.5 KiB
C#
Raw Normal View History

2017-05-24 18:11:07 +00: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-07 14:49:14 +00:00
using osu.Framework.Extensions.IEnumerableExtensions;
2017-06-05 13:04:35 +00:00
using osu.Framework.Graphics;
2017-05-24 18:11:07 +00:00
using osu.Framework.Graphics.Containers;
2017-06-07 13:15:43 +00:00
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
2017-05-24 18:11:07 +00:00
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
2017-06-05 13:07:57 +00:00
using osu.Game.Users.Profile;
2017-05-24 18:11:07 +00:00
namespace osu.Game.Users
2017-05-24 18:11:07 +00:00
{
2017-06-05 13:07:57 +00:00
public class UserProfile : FocusedOverlayContainer
2017-05-24 18:11:07 +00:00
{
private readonly User user;
2017-06-05 13:07:57 +00:00
private ProfileSection lastSection;
2017-06-06 03:25:16 +00:00
public const float CONTENT_X_MARGIN = 50;
2017-06-05 13:07:57 +00:00
public UserProfile(User user)
2017-05-24 18:11:07 +00:00
{
this.user = user;
2017-06-07 14:49:14 +00:00
var sections = new ProfileSection[]
{
new AboutSection(user),
new RecentSection(user),
new RanksSection(user),
new MedalsSection(user),
new HistoricalSection(user),
new BeatmapsSection(user),
new KudosuSection(user)
};
var tab = new OsuTabControl<ProfileSection>
{
RelativeSizeAxes = Axes.X,
Height = 24
};
sections.ForEach(tab.AddItem);
2017-06-07 13:15:43 +00:00
Add(new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
});
2017-05-24 18:11:07 +00:00
var sectionsContainer = new SectionsContainer
{
2017-06-05 13:04:35 +00:00
RelativeSizeAxes = Axes.Both,
ExpandableHeader = new UserPageHeader(user),
2017-05-24 18:11:07 +00:00
FixedHeader = tab,
HeaderBackground = new Box
{
Colour = OsuColour.Gray(34),
RelativeSizeAxes = Axes.Both
},
2017-05-24 18:11:07 +00:00
Sections = sections
};
Add(sectionsContainer);
sectionsContainer.SelectedSection.ValueChanged += s =>
{
if (lastSection != s)
{
2017-06-05 13:07:57 +00:00
lastSection = s as ProfileSection;
2017-05-24 18:11:07 +00:00
tab.Current.Value = lastSection;
}
};
tab.Current.ValueChanged += s =>
{
if (lastSection != s)
{
lastSection = s;
sectionsContainer.ScrollContainer.ScrollIntoView(lastSection);
}
};
}
}
}