1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:03:11 +08:00

Merge pull request #26184 from peppy/spectate-from-context-menu

Allow entering spectator mode from context menu on user panels
This commit is contained in:
Bartłomiej Dach 2023-12-28 12:24:29 +01:00 committed by GitHub
commit a9c7131d47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 20 deletions

View File

@ -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}";
}

View File

@ -131,9 +131,6 @@ namespace osu.Game.Overlays.Dashboard
{
int userId = kvp.Key;
if (userId == api.LocalUser.Value.Id)
continue;
users.GetUserAsync(userId).ContinueWith(task =>
{
APIUser user = task.GetResultSafely();

View File

@ -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();