mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Move UserProfileOverlay's header into an abstract implementation
This commit is contained in:
parent
455301de2c
commit
a5bd3262be
@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(ProfileHeader),
|
||||
typeof(RankGraph),
|
||||
typeof(LineGraph),
|
||||
typeof(ProfileHeaderTabControl),
|
||||
typeof(HeaderTabControl),
|
||||
typeof(CentreHeaderContainer),
|
||||
typeof(BottomHeaderContainer),
|
||||
typeof(DetailHeaderContainer),
|
||||
|
71
osu.Game/Overlays/OverlayHeader.cs
Normal file
71
osu.Game/Overlays/OverlayHeader.cs
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Profile.Header;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public abstract class OverlayHeader : Container
|
||||
{
|
||||
protected readonly HeaderTabControl TabControl;
|
||||
|
||||
private const float cover_height = 150;
|
||||
private const float cover_info_height = 75;
|
||||
|
||||
protected OverlayHeader()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = cover_height,
|
||||
Masking = true,
|
||||
Child = CreateBackground()
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
|
||||
Y = cover_height,
|
||||
Height = cover_info_height,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Depth = -float.MaxValue,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
CreateTitle().With(t => t.X = -ScreenTitle.ICON_WIDTH),
|
||||
TabControl = new HeaderTabControl
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = cover_info_height - 30,
|
||||
Margin = new MarginPadding { Left = -UserProfileOverlay.CONTENT_X_MARGIN },
|
||||
Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }
|
||||
}
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Margin = new MarginPadding { Top = cover_height },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = CreateContent()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract Drawable CreateBackground();
|
||||
|
||||
protected abstract Drawable CreateContent();
|
||||
|
||||
protected abstract ScreenTitle CreateTitle();
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class ProfileHeaderTabControl : TabControl<string>
|
||||
public class HeaderTabControl : TabControl<string>
|
||||
{
|
||||
private readonly Box bar;
|
||||
|
||||
@ -32,7 +32,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
|
||||
foreach (TabItem<string> tabItem in TabContainer)
|
||||
{
|
||||
((ProfileHeaderTabItem)tabItem).AccentColour = value;
|
||||
((HeaderTabItem)tabItem).AccentColour = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
set => TabContainer.Padding = value;
|
||||
}
|
||||
|
||||
public ProfileHeaderTabControl()
|
||||
public HeaderTabControl()
|
||||
{
|
||||
TabContainer.Masking = false;
|
||||
TabContainer.Spacing = new Vector2(15, 0);
|
||||
@ -59,12 +59,12 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
|
||||
protected override Dropdown<string> CreateDropdown() => null;
|
||||
|
||||
protected override TabItem<string> CreateTabItem(string value) => new ProfileHeaderTabItem(value)
|
||||
protected override TabItem<string> CreateTabItem(string value) => new HeaderTabItem(value)
|
||||
{
|
||||
AccentColour = AccentColour
|
||||
};
|
||||
|
||||
private class ProfileHeaderTabItem : TabItem<string>
|
||||
private class HeaderTabItem : TabItem<string>
|
||||
{
|
||||
private readonly OsuSpriteText text;
|
||||
private readonly Drawable bar;
|
||||
@ -86,7 +86,7 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
}
|
||||
}
|
||||
|
||||
public ProfileHeaderTabItem(string value)
|
||||
public HeaderTabItem(string value)
|
||||
: base(value)
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
@ -15,124 +15,85 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
public class ProfileHeader : Container
|
||||
public class ProfileHeader : OverlayHeader
|
||||
{
|
||||
private readonly UserCoverBackground coverContainer;
|
||||
private readonly ProfileHeaderTabControl infoTabControl;
|
||||
private UserCoverBackground coverContainer;
|
||||
|
||||
private const float cover_height = 150;
|
||||
private const float cover_info_height = 75;
|
||||
public Bindable<User> User = new Bindable<User>();
|
||||
|
||||
private CentreHeaderContainer centreHeaderContainer;
|
||||
private DetailHeaderContainer detailHeaderContainer;
|
||||
|
||||
public ProfileHeader()
|
||||
{
|
||||
CentreHeaderContainer centreHeaderContainer;
|
||||
DetailHeaderContainer detailHeaderContainer;
|
||||
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = cover_height,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
coverContainer = new UserCoverBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(OsuColour.FromHex("222").Opacity(0.8f), OsuColour.FromHex("222").Opacity(0.2f))
|
||||
},
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
|
||||
Y = cover_height,
|
||||
Height = cover_info_height,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Depth = -float.MaxValue,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ProfileHeaderTitle
|
||||
{
|
||||
X = -ScreenTitle.ICON_WIDTH,
|
||||
},
|
||||
infoTabControl = new ProfileHeaderTabControl
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = cover_info_height - 30,
|
||||
Margin = new MarginPadding { Left = -UserProfileOverlay.CONTENT_X_MARGIN },
|
||||
Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }
|
||||
}
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Top = cover_height },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TopHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
centreHeaderContainer = new CentreHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
detailHeaderContainer = new DetailHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
new MedalHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
new BottomHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
infoTabControl.AddItem("Info");
|
||||
infoTabControl.AddItem("Modding");
|
||||
TabControl.AddItem("Info");
|
||||
TabControl.AddItem("Modding");
|
||||
|
||||
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true);
|
||||
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
infoTabControl.AccentColour = colours.Seafoam;
|
||||
TabControl.AccentColour = colours.Seafoam;
|
||||
}
|
||||
|
||||
public Bindable<User> User = new Bindable<User>();
|
||||
protected override Drawable CreateBackground() =>
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
coverContainer = new UserCoverBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(OsuColour.FromHex("222").Opacity(0.8f), OsuColour.FromHex("222").Opacity(0.2f))
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
private void updateDisplay(User user)
|
||||
protected override Drawable CreateContent() => new FillFlowContainer
|
||||
{
|
||||
coverContainer.User = user;
|
||||
}
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TopHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
centreHeaderContainer = new CentreHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
detailHeaderContainer = new DetailHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
new MedalHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
new BottomHeaderContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
User = { BindTarget = User },
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
protected override ScreenTitle CreateTitle() => new ProfileHeaderTitle();
|
||||
|
||||
private class ProfileHeaderTitle : ScreenTitle
|
||||
{
|
||||
@ -148,5 +109,7 @@ namespace osu.Game.Overlays.Profile
|
||||
AccentColour = colours.Seafoam;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisplay(User user) => coverContainer.User = user;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user