diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index afc6589f57..cac0ce01ae 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -13,6 +12,9 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; using osu.Game.Users; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Chat { @@ -63,8 +65,6 @@ namespace osu.Game.Overlays.Chat private const float message_padding = 200; private const float text_size = 20; - private Action loadProfile; - private Color4 customUsernameColour; private OsuSpriteText timestamp; @@ -100,10 +100,9 @@ namespace osu.Game.Overlays.Chat } [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, UserProfileOverlay profile) + private void load(OsuColour colours) { customUsernameColour = colours.ChatBlue; - loadProfile = u => profile?.ShowUser(u); } private bool senderHasBackground => !string.IsNullOrEmpty(message.Sender.Colour); @@ -171,13 +170,12 @@ namespace osu.Game.Overlays.Chat FixedWidth = true, TextSize = text_size * 0.75f, }, - new ClickableContainer + new MessageSender(message.Sender) { AutoSizeAxes = Axes.Both, Origin = Anchor.TopRight, Anchor = Anchor.TopRight, Child = effectedUsername, - Action = () => loadProfile(message.Sender), }, } }, @@ -210,5 +208,26 @@ namespace osu.Game.Overlays.Chat username.Text = $@"{message.Sender.Username}" + (senderHasBackground ? "" : ":"); contentFlow.Text = message.Content; } + + private class MessageSender : ClickableContainer, IHasContextMenu + { + private readonly User sender; + + public MessageSender(User sender) + { + this.sender = sender; + } + + [BackgroundDependencyLoader(true)] + private void load(UserProfileOverlay profile) + { + Action = () => profile?.ShowUser(sender); + } + + public MenuItem[] ContextMenuItems => new MenuItem[] + { + new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action), + }; + } } } diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 840edaece2..7179d8ed90 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -10,23 +10,13 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Cursor; using osu.Game.Online.Chat; namespace osu.Game.Overlays.Chat { public class DrawableChannel : Container { - private class ChatLineContainer : FillFlowContainer - { - protected override int Compare(Drawable x, Drawable y) - { - var xC = (ChatLine)x; - var yC = (ChatLine)y; - - return xC.Message.CompareTo(yC.Message); - } - } - public readonly Channel Channel; private readonly ChatLineContainer flow; private readonly ScrollContainer scroll; @@ -45,12 +35,17 @@ namespace osu.Game.Overlays.Chat // Some chat lines have effects that slightly protrude to the bottom, // which we do not want to mask away, hence the padding. Padding = new MarginPadding { Bottom = 5 }, - Child = flow = new ChatLineContainer + Child = new OsuContextMenuContainer { - Padding = new MarginPadding { Left = 20, Right = 20 }, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, + Child = flow = new ChatLineContainer + { + Padding = new MarginPadding { Left = 20, Right = 20 }, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + } }, } }; @@ -124,5 +119,16 @@ namespace osu.Game.Overlays.Chat } private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd()); + + private class ChatLineContainer : FillFlowContainer + { + protected override int Compare(Drawable x, Drawable y) + { + var xC = (ChatLine)x; + var yC = (ChatLine)y; + + return xC.Message.CompareTo(yC.Message); + } + } } } diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 1bce31c789..58b259fcbb 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -3,12 +3,12 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Overlays.Settings.Sections.General; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Cursor; namespace osu.Game.Overlays { @@ -34,7 +34,7 @@ namespace osu.Game.Overlays Colour = Color4.Black, Alpha = 0.6f, }, - new Container + new OsuContextMenuContainer { Width = 360, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index e62050fae1..8b7d7b0d69 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -366,10 +366,6 @@ namespace osu.Game.Overlays.Settings.Sections.General BackgroundColour = colours.Gray3; } } - - - - } private enum UserAction diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index 1cd2343848..954a838461 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -9,6 +9,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; +using osu.Game.Graphics.Cursor; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; @@ -63,12 +64,17 @@ namespace osu.Game.Overlays ScrollFlow.Children = new[] { - panelFlow = new FillFlowContainer + new OsuContextMenuContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Top = 20 }, - Spacing = new Vector2(10f), + Child = panelFlow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Top = 20 }, + Spacing = new Vector2(10f), + } }, }; diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 89bd4b68d2..e5518b5845 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -13,10 +13,13 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.UserInterface; +using osu.Framework.Graphics.Cursor; namespace osu.Game.Users { - public class UserPanel : ClickableContainer + public class UserPanel : ClickableContainer, IHasContextMenu { private readonly User user; private const float height = 100; @@ -31,6 +34,8 @@ namespace osu.Game.Users public new Action Action; + protected Action ViewProfile; + public UserPanel(User user) { this.user = user; @@ -171,7 +176,7 @@ namespace osu.Game.Users Status.ValueChanged += displayStatus; Status.ValueChanged += status => statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); - base.Action = () => + base.Action = ViewProfile = () => { Action?.Invoke(); profile?.ShowUser(user); @@ -203,5 +208,10 @@ namespace osu.Game.Users statusMessage.Text = status.Message; } } + + public MenuItem[] ContextMenuItems => new MenuItem[] + { + new OsuMenuItem("View Profile", MenuItemType.Highlighted, ViewProfile), + }; } }