1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Forcefully exit multiplayer if API loses connectivity

This commit is contained in:
smoogipoo 2018-12-27 17:12:47 +09:00
parent f70e60747f
commit bd0576537e

View File

@ -21,7 +21,7 @@ using osuTK;
namespace osu.Game.Screens.Multi
{
[Cached]
public class Multiplayer : OsuScreen
public class Multiplayer : OsuScreen, IOnlineComponent
{
private readonly MultiplayerWaveContainer waves;
@ -98,6 +98,30 @@ namespace osu.Game.Screens.Multi
loungeSubScreen.Exited += _ => Exit();
}
[BackgroundDependencyLoader]
private void load()
{
api.Register(this);
}
public void APIStateChanged(APIAccess api, APIState state)
{
if (state != APIState.Online)
forcefullyExit();
}
private void forcefullyExit()
{
// This is temporary since we don't currently have a way to force screens to be exited
if (IsCurrentScreen)
Exit();
else
{
MakeCurrent();
Schedule(forcefullyExit);
}
}
protected override void OnEntering(Screen last)
{
Content.FadeIn();
@ -196,6 +220,12 @@ namespace osu.Game.Screens.Multi
currentScreen = (OsuScreen)newScreen;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
api?.Unregister(this);
}
private class MultiplayerWaveContainer : WaveContainer
{
protected override bool StartHidden => true;