Move namespace and setup for DI.

This commit is contained in:
Huo Yaoyuan
2017-06-15 17:03:33 +08:00
parent 74f503874f
commit 13d9f3b9bb
6 changed files with 18 additions and 12 deletions

View File

@ -14,6 +14,7 @@ using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
namespace osu.Game.Users.Profile
{
@ -65,7 +66,7 @@ namespace osu.Game.Users.Profile
Size = new Vector2(avatar_size),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
X = UserProfile.CONTENT_X_MARGIN,
X = UserProfileOverlay.CONTENT_X_MARGIN,
Y = avatar_bottom_position,
Masking = true,
CornerRadius = 5,
@ -80,7 +81,7 @@ namespace osu.Game.Users.Profile
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
X = UserProfile.CONTENT_X_MARGIN + avatar_size + 10,
X = UserProfileOverlay.CONTENT_X_MARGIN + avatar_size + 10,
Y = avatar_bottom_position,
Children = new Drawable[]
{
@ -111,14 +112,14 @@ namespace osu.Game.Users.Profile
})
{
Y = cover_height + 20,
Margin = new MarginPadding { Horizontal = UserProfile.CONTENT_X_MARGIN },
Margin = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ParagraphSpacing = 1
},
new Container
{
X = -UserProfile.CONTENT_X_MARGIN,
X = -UserProfileOverlay.CONTENT_X_MARGIN,
RelativeSizeAxes = Axes.Y,
Width = 280,
Anchor = Anchor.TopRight,

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
namespace osu.Game.Users.Profile
{
@ -31,7 +32,7 @@ namespace osu.Game.Users.Profile
Font = @"Exo2.0-RegularItalic",
Margin = new MarginPadding
{
Horizontal = UserProfile.CONTENT_X_MARGIN,
Horizontal = UserProfileOverlay.CONTENT_X_MARGIN,
Vertical = 20
}
},
@ -42,7 +43,7 @@ namespace osu.Game.Users.Profile
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding
{
Horizontal = UserProfile.CONTENT_X_MARGIN,
Horizontal = UserProfileOverlay.CONTENT_X_MARGIN,
Bottom = 20
}
},

View File

@ -1,129 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Users.Profile;
namespace osu.Game.Users
{
public class UserProfile : FocusedOverlayContainer
{
private ProfileSection lastSection;
public const float CONTENT_X_MARGIN = 50;
public UserProfile(User user)
{
var sections = new ProfileSection[]
{
new AboutSection(),
new RecentSection(),
new RanksSection(),
new MedalsSection(),
new HistoricalSection(),
new BeatmapsSection(),
new KudosuSection()
};
var tabs = new ProfileTabControl
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Height = 30
};
sections.ForEach(tabs.AddItem);
Add(new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
});
var sectionsContainer = new SectionsContainer<ProfileSection>
{
RelativeSizeAxes = Axes.Both,
ExpandableHeader = new ProfileHeader(user),
FixedHeader = tabs,
HeaderBackground = new Box
{
Colour = OsuColour.Gray(34),
RelativeSizeAxes = Axes.Both
},
Children = sections
};
Add(sectionsContainer);
sectionsContainer.SelectedSection.ValueChanged += s =>
{
if (lastSection != s)
{
lastSection = s;
tabs.Current.Value = lastSection;
}
};
tabs.Current.ValueChanged += s =>
{
if (lastSection == null)
{
lastSection = sectionsContainer.Children.FirstOrDefault();
if (lastSection != null)
tabs.Current.Value = lastSection;
return;
}
if (lastSection != s)
{
lastSection = s;
sectionsContainer.ScrollContainer.ScrollIntoView(lastSection);
}
};
}
private class ProfileTabControl : PageTabControl<ProfileSection>
{
private readonly Box bottom;
public ProfileTabControl()
{
TabContainer.RelativeSizeAxes &= ~Axes.X;
TabContainer.AutoSizeAxes |= Axes.X;
TabContainer.Anchor |= Anchor.x1;
TabContainer.Origin |= Anchor.x1;
Add(bottom = new Box
{
RelativeSizeAxes = Axes.X,
Height = 1,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
EdgeSmoothness = new Vector2(1)
});
}
protected override TabItem<ProfileSection> CreateTabItem(ProfileSection value) => new ProfileTabItem(value);
private class ProfileTabItem : PageTabItem
{
public ProfileTabItem(ProfileSection value) : base(value)
{
Text.Text = value.Title;
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
bottom.Colour = colours.Yellow;
}
}
}
}