mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 15:27:30 +08:00
Add the ability to spectate a user by right clicking their user panel
This commit is contained in:
parent
3a3b4d445c
commit
2ec9343868
@ -20,9 +20,14 @@ namespace osu.Game.Localisation
|
||||
public static LocalisableString ViewBeatmap => new TranslatableString(getKey(@"view_beatmap"), @"View beatmap");
|
||||
|
||||
/// <summary>
|
||||
/// "Invite player"
|
||||
/// "Invite to room"
|
||||
/// </summary>
|
||||
public static LocalisableString InvitePlayer => new TranslatableString(getKey(@"invite_player"), @"Invite player");
|
||||
public static LocalisableString InvitePlayer => new TranslatableString(getKey(@"invite_player"), @"Invite to room");
|
||||
|
||||
/// <summary>
|
||||
/// "Spectate"
|
||||
/// </summary>
|
||||
public static LocalisableString SpectatePlayer => new TranslatableString(getKey(@"spectate_player"), @"Spectate");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Overlays;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -20,6 +21,8 @@ using osu.Game.Online.Chat;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
@ -60,6 +63,9 @@ namespace osu.Game.Users
|
||||
[Resolved]
|
||||
protected OverlayColourProvider? ColourProvider { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private IPerformFromScreenRunner? performer { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected OsuColour Colours { get; private set; } = null!;
|
||||
|
||||
@ -113,23 +119,26 @@ namespace osu.Game.Users
|
||||
new OsuMenuItem(ContextMenuStrings.ViewProfile, MenuItemType.Highlighted, ViewProfile)
|
||||
};
|
||||
|
||||
if (!User.Equals(api.LocalUser.Value))
|
||||
{
|
||||
items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, () =>
|
||||
{
|
||||
channelManager?.OpenPrivateChannel(User);
|
||||
chatOverlay?.Show();
|
||||
}));
|
||||
}
|
||||
if (User.Equals(api.LocalUser.Value))
|
||||
return items.ToArray();
|
||||
|
||||
if (
|
||||
// TODO: uncomment this once lazer / osu-web is updating online states
|
||||
// User.IsOnline &&
|
||||
multiplayerClient?.Room != null &&
|
||||
multiplayerClient.Room.Users.All(u => u.UserID != User.Id)
|
||||
)
|
||||
items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, () =>
|
||||
{
|
||||
items.Add(new OsuMenuItem(ContextMenuStrings.InvitePlayer, MenuItemType.Standard, () => multiplayerClient.InvitePlayer(User.Id)));
|
||||
channelManager?.OpenPrivateChannel(User);
|
||||
chatOverlay?.Show();
|
||||
}));
|
||||
|
||||
if (User.IsOnline)
|
||||
{
|
||||
items.Add(new OsuMenuItem(ContextMenuStrings.SpectatePlayer, MenuItemType.Standard, () =>
|
||||
{
|
||||
performer?.PerformFromScreen(s => s.Push(new SoloSpectatorScreen(User)));
|
||||
}));
|
||||
|
||||
if (multiplayerClient?.Room?.Users.All(u => u.UserID != User.Id) == true)
|
||||
{
|
||||
items.Add(new OsuMenuItem(ContextMenuStrings.InvitePlayer, MenuItemType.Standard, () => multiplayerClient.InvitePlayer(User.Id)));
|
||||
}
|
||||
}
|
||||
|
||||
return items.ToArray();
|
||||
|
Loading…
Reference in New Issue
Block a user