1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 22:22:55 +08:00

Show mapper's profile when clicking on avatar in BeatmapSetOverlay

This commit is contained in:
EVAST9919 2017-09-30 05:41:32 +03:00
parent 04f3802cc0
commit 92c3d722b4
2 changed files with 29 additions and 5 deletions

View File

@ -188,11 +188,11 @@ namespace osu.Game
GetToolbarHeight = () => ToolbarOffset, GetToolbarHeight = () => ToolbarOffset,
Depth = -1 Depth = -1
}, overlayContent.Add); }, overlayContent.Add);
LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add);
LoadComponentAsync(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -2 }, mainContent.Add); LoadComponentAsync(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -2 }, mainContent.Add);
LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -3 }, mainContent.Add);
LoadComponentAsync(musicController = new MusicController LoadComponentAsync(musicController = new MusicController
{ {
Depth = -3, Depth = -4,
Position = new Vector2(0, Toolbar.HEIGHT), Position = new Vector2(0, Toolbar.HEIGHT),
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
@ -200,7 +200,7 @@ namespace osu.Game
LoadComponentAsync(notificationOverlay = new NotificationOverlay LoadComponentAsync(notificationOverlay = new NotificationOverlay
{ {
Depth = -3, Depth = -4,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}, overlayContent.Add); }, overlayContent.Add);

View File

@ -9,6 +9,9 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Users; using osu.Game.Users;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Game.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
namespace osu.Game.Overlays.BeatmapSet namespace osu.Game.Overlays.BeatmapSet
{ {
@ -17,8 +20,11 @@ namespace osu.Game.Overlays.BeatmapSet
private const float height = 50; private const float height = 50;
private readonly UpdateableAvatar avatar; private readonly UpdateableAvatar avatar;
private readonly ClickableArea clickableArea;
private readonly FillFlowContainer fields; private readonly FillFlowContainer fields;
private UserProfileOverlay profile;
private BeatmapSetInfo beatmapSet; private BeatmapSetInfo beatmapSet;
public BeatmapSetInfo BeatmapSet public BeatmapSetInfo BeatmapSet
{ {
@ -31,6 +37,8 @@ namespace osu.Game.Overlays.BeatmapSet
var i = BeatmapSet.OnlineInfo; var i = BeatmapSet.OnlineInfo;
avatar.User = i.Author; avatar.User = i.Author;
clickableArea.Action = () => profile?.ShowUser(avatar.User);
fields.Children = new Drawable[] fields.Children = new Drawable[]
{ {
new Field("made by", i.Author.Username, @"Exo2.0-RegularItalic"), new Field("made by", i.Author.Username, @"Exo2.0-RegularItalic"),
@ -58,11 +66,15 @@ namespace osu.Game.Overlays.BeatmapSet
Children = new Drawable[] Children = new Drawable[]
{ {
avatar = new UpdateableAvatar clickableArea = new ClickableArea
{ {
Size = new Vector2(height), AutoSizeAxes = Axes.Both,
CornerRadius = 3, CornerRadius = 3,
Masking = true, Masking = true,
Child = avatar = new UpdateableAvatar
{
Size = new Vector2(height),
},
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
{ {
Colour = Color4.Black.Opacity(0.25f), Colour = Color4.Black.Opacity(0.25f),
@ -80,6 +92,13 @@ namespace osu.Game.Overlays.BeatmapSet
}; };
} }
[BackgroundDependencyLoader(true)]
private void load(UserProfileOverlay profile)
{
this.profile = profile;
clickableArea.Action = () => profile?.ShowUser(avatar.User);
}
private class Field : FillFlowContainer private class Field : FillFlowContainer
{ {
public Field(string first, string second, string secondFont) public Field(string first, string second, string secondFont)
@ -103,5 +122,10 @@ namespace osu.Game.Overlays.BeatmapSet
}; };
} }
} }
private class ClickableArea : OsuClickableContainer, IHasTooltip
{
public string TooltipText => @"View Profile";
}
} }
} }