Make multiplayer screen handle user activity updates from subscreens.

This commit is contained in:
Lucas A 2020-11-08 13:16:27 +01:00
parent 55070556a7
commit 89b98b5388
1 changed files with 12 additions and 5 deletions

View File

@ -24,6 +24,7 @@
using osu.Game.Screens.Multi.Lounge.Components;
using osu.Game.Screens.Multi.Match;
using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Screens.Multi
@ -140,10 +141,10 @@ public Multiplayer()
}
};
screenStack.Push(loungeSubScreen = new LoungeSubScreen());
screenStack.ScreenPushed += screenPushed;
screenStack.ScreenExited += screenExited;
screenStack.Push(loungeSubScreen = new LoungeSubScreen());
}
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
@ -311,18 +312,18 @@ private void endHandlingTrack()
private void screenPushed(IScreen lastScreen, IScreen newScreen)
{
subScreenChanged(newScreen);
subScreenChanged(lastScreen, newScreen);
}
private void screenExited(IScreen lastScreen, IScreen newScreen)
{
subScreenChanged(newScreen);
subScreenChanged(lastScreen, newScreen);
if (screenStack.CurrentScreen == null && this.IsCurrentScreen())
this.Exit();
}
private void subScreenChanged(IScreen newScreen)
private void subScreenChanged(IScreen lastScreen, IScreen newScreen)
{
switch (newScreen)
{
@ -337,6 +338,12 @@ private void subScreenChanged(IScreen newScreen)
break;
}
if (lastScreen is IOsuScreen lastOsuScreen)
Activity.UnbindFrom(lastOsuScreen.Activity);
if (newScreen is IOsuScreen newOsuScreen)
((IBindable<UserActivity>)Activity).BindTo(newOsuScreen.Activity);
updatePollingRate(isIdle.Value);
createButton.FadeTo(newScreen is LoungeSubScreen ? 1 : 0, 200);