mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Add context menus to chat names and user panels
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
// 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;
|
||||
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<User> 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),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user