From bdf62870d10ca8b818b8da7504945b1d44fe826a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Sep 2017 15:40:36 +0900 Subject: [PATCH 1/3] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 7347c386dc..3f4545aae8 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 7347c386dcd10eb799b1ce1512536879328109f9 +Subproject commit 3f4545aae82650dc87cac7dd5df64e6e47918da1 From 396a56ddf4febbaffd9a934934e281ebfd133eaf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Sep 2017 15:41:32 +0900 Subject: [PATCH 2/3] Remove global OsuContextMenuContainer --- osu.Game/OsuGameBase.cs | 3 +-- osu.Game/Screens/Select/BeatmapCarousel.cs | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index d81c7cdf73..79e03a8141 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -200,10 +200,9 @@ namespace osu.Game globalBinding = new GlobalKeyBindingInputManager(this) { RelativeSizeAxes = Axes.Both, - Child = new OsuTooltipContainer(Cursor) + Child = content = new OsuTooltipContainer(Cursor) { RelativeSizeAxes = Axes.Both, - Child = content = new OsuContextMenuContainer { RelativeSizeAxes = Axes.Both }, } } } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 94ae740c74..abd288baf2 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -19,6 +19,7 @@ using osu.Framework.Threading; using osu.Framework.Configuration; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Cursor; namespace osu.Game.Screens.Select { @@ -86,9 +87,14 @@ namespace osu.Game.Screens.Select public BeatmapCarousel() { - Add(scrollableContent = new Container + Add(new OsuContextMenuContainer { RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Child = scrollableContent = new Container + { + RelativeSizeAxes = Axes.X, + } }); } From b7c981968091ede7cbc38b19934abba2ee4d09dd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Sep 2017 15:43:47 +0900 Subject: [PATCH 3/3] Add context menus to chat names and user panels --- osu.Game/Overlays/Chat/ChatLine.cs | 33 ++++++++++++++---- osu.Game/Overlays/Chat/DrawableChannel.cs | 34 +++++++++++-------- osu.Game/Overlays/LoginOverlay.cs | 4 +-- .../Sections/General/LoginSettings.cs | 4 --- osu.Game/Overlays/SocialOverlay.cs | 12 +++++-- osu.Game/Users/UserPanel.cs | 14 ++++++-- 6 files changed, 69 insertions(+), 32 deletions(-) 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), + }; } }