mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 14:13:18 +08:00
Send Loaded state from PlayerLoader on update thread
This commit is contained in:
parent
fe0fcc7e9e
commit
1d8ac6917d
@ -133,9 +133,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
failAndBail();
|
||||
}
|
||||
}), true);
|
||||
|
||||
client.ChangeState(MultiplayerUserState.Loaded)
|
||||
.ContinueWith(task => failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -2,7 +2,9 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -28,6 +30,26 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
// The server is forcefully starting gameplay.
|
||||
|| multiplayerClient.LocalUser?.State == MultiplayerUserState.Playing;
|
||||
|
||||
protected override void OnPlayerLoaded()
|
||||
{
|
||||
base.OnPlayerLoaded();
|
||||
|
||||
multiplayerClient.ChangeState(MultiplayerUserState.Loaded)
|
||||
.ContinueWith(task => failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion);
|
||||
}
|
||||
|
||||
private void failAndBail(string message = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
Logger.Log(message, LoggingTarget.Runtime, LogLevel.Important);
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (this.IsCurrentScreen())
|
||||
this.Exit();
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnSuspending(ScreenTransitionEvent e)
|
||||
{
|
||||
base.OnSuspending(e);
|
||||
|
@ -368,7 +368,15 @@ namespace osu.Game.Screens.Play
|
||||
CurrentPlayer.RestartCount = restartCount++;
|
||||
CurrentPlayer.RestartRequested = restartRequested;
|
||||
|
||||
LoadTask = LoadComponentAsync(CurrentPlayer, _ => MetadataInfo.Loading = false);
|
||||
LoadTask = LoadComponentAsync(CurrentPlayer, _ =>
|
||||
{
|
||||
MetadataInfo.Loading = false;
|
||||
OnPlayerLoaded();
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void OnPlayerLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
private void restartRequested()
|
||||
|
Loading…
Reference in New Issue
Block a user