mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
Enable spectating multiplayer matches
This commit is contained in:
parent
3e46d6401e
commit
6eddc6c59e
@ -96,9 +96,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
if (!IsConnected.Value)
|
||||
return Task.CompletedTask;
|
||||
|
||||
if (newState == MultiplayerUserState.Spectating)
|
||||
return Task.CompletedTask; // Not supported yet.
|
||||
|
||||
return connection.InvokeAsync(nameof(IMultiplayerServer.ChangeState), newState);
|
||||
}
|
||||
|
||||
|
@ -148,10 +148,12 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
protected void StartPlay(Func<Player> player)
|
||||
protected void StartPlay(Func<Player> player) => PushTopLevelScreen(() => new PlayerLoader(player));
|
||||
|
||||
protected void PushTopLevelScreen(Func<Screen> screen)
|
||||
{
|
||||
sampleStart?.Play();
|
||||
ParentScreen?.Push(new PlayerLoader(player));
|
||||
ParentScreen?.Push(screen());
|
||||
}
|
||||
|
||||
private void selectedItemChanged()
|
||||
|
@ -25,6 +25,7 @@ using osu.Game.Screens.OnlinePlay.Match;
|
||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Participants;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
@ -405,11 +406,22 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
private void onRoomUpdated()
|
||||
private void onRoomUpdated() => Scheduler.Add(() =>
|
||||
{
|
||||
// user mods may have changed.
|
||||
Scheduler.AddOnce(UpdateMods);
|
||||
}
|
||||
if (client.Room == null)
|
||||
return;
|
||||
|
||||
Debug.Assert(client.LocalUser != null);
|
||||
|
||||
UpdateMods();
|
||||
|
||||
if (client.LocalUser.State == MultiplayerUserState.Spectating
|
||||
&& (client.Room.State == MultiplayerRoomState.Playing || client.Room.State == MultiplayerRoomState.WaitingForLoad)
|
||||
&& ParentScreen.IsCurrentScreen())
|
||||
{
|
||||
PushTopLevelScreen(() => new MultiplayerSpectator(client.CurrentMatchPlayingUserIds.ToArray()));
|
||||
}
|
||||
});
|
||||
|
||||
private void onLoadRequested()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user