don't create "Start Chat" option when the sender is the local user

This commit is contained in:
LeNitrous 2019-06-03 18:54:29 +08:00
parent 4e6d7137aa
commit 516575a132
1 changed files with 19 additions and 4 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Linq;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -14,6 +15,7 @@
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.Chat;
using osu.Game.Users;
using osuTK;
@ -201,6 +203,9 @@ private class MessageSender : OsuClickableContainer, IHasContextMenu
private Action startChatAction;
[Resolved]
private IAPIProvider api { get; set; }
public MessageSender(User sender)
{
this.sender = sender;
@ -213,11 +218,21 @@ private void load(UserProfileOverlay profile, ChannelManager chatManager)
startChatAction = () => chatManager?.OpenPrivateChannel(sender);
}
public MenuItem[] ContextMenuItems => new MenuItem[]
public MenuItem[] ContextMenuItems
{
new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action),
new OsuMenuItem("Start Chat", MenuItemType.Standard, startChatAction),
};
get
{
List<MenuItem> items = new List<MenuItem>
{
new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action)
};
if (sender.Id != api.LocalUser.Value.Id)
items.Add(new OsuMenuItem("Start Chat", MenuItemType.Standard, startChatAction));
return items.ToArray();
}
}
}
private static readonly Color4[] username_colours =