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:
parent
f70e60747f
commit
bd0576537e
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user