Add invite button to UserPanel context menu

This commit is contained in:
Marvin Schürz 2023-10-02 22:55:53 +02:00
parent 574dc67a9e
commit 7629b725a2
1 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
@ -18,6 +19,7 @@
using osu.Game.Online.Chat;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Localisation;
using osu.Game.Online.Multiplayer;
namespace osu.Game.Users
{
@ -61,6 +63,9 @@ protected UserPanel(APIUser user)
[Resolved]
protected OsuColour Colours { get; private set; } = null!;
[Resolved]
private MultiplayerClient multiplayerClient { get; set; } = null!;
[BackgroundDependencyLoader]
private void load()
{
@ -117,6 +122,15 @@ public MenuItem[] ContextMenuItems
}));
}
if (
User.IsOnline &&
multiplayerClient.Room != null &&
multiplayerClient.Room.Users.All(u => u.UserID != User.Id)
)
{
items.Add(new OsuMenuItem(ContextMenuStrings.InvitePlayer, MenuItemType.Standard, () => multiplayerClient.InvitePlayer(User.Id)));
}
return items.ToArray();
}
}