mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Use single method for starting/restarting spectator screen
This commit is contained in:
@ -21,7 +21,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
{
|
||||
base.OnResuming(last);
|
||||
|
||||
if (client.Room != null)
|
||||
if (client.Room != null && client.LocalUser?.State != MultiplayerUserState.Spectating)
|
||||
client.ChangeState(MultiplayerUserState.Idle);
|
||||
}
|
||||
|
||||
|
@ -406,29 +406,22 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
private void onRoomUpdated() => Scheduler.Add(() =>
|
||||
private void onRoomUpdated()
|
||||
{
|
||||
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())
|
||||
{
|
||||
StartPlay();
|
||||
|
||||
// If the current user was host, they started the match and the in-progress operation needs to be stopped now.
|
||||
readyClickOperation?.Dispose();
|
||||
readyClickOperation = null;
|
||||
}
|
||||
});
|
||||
Scheduler.AddOnce(UpdateMods);
|
||||
}
|
||||
|
||||
private void onLoadRequested()
|
||||
{
|
||||
// If the user is spectating, the multi-spectator screen may still be the current screen.
|
||||
if (!ParentScreen.IsCurrentScreen())
|
||||
{
|
||||
ParentScreen.MakeCurrent();
|
||||
|
||||
Schedule(onLoadRequested);
|
||||
return;
|
||||
}
|
||||
|
||||
StartPlay();
|
||||
|
||||
readyClickOperation?.Dispose();
|
||||
|
@ -140,6 +140,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
leaderboard.RemoveClock(userId);
|
||||
}
|
||||
|
||||
public override bool OnBackButton()
|
||||
{
|
||||
// On a manual exit, set the player state back to idle.
|
||||
multiplayerClient.ChangeState(MultiplayerUserState.Idle);
|
||||
return base.OnBackButton();
|
||||
}
|
||||
|
||||
private int getIndexForUser(int userId) => Array.IndexOf(userIds, userId);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user