mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
Fix OnlinePlayScreen
sub-screens not loaded asynchronously
This commit is contained in:
parent
6cc81c24b4
commit
d87ea741ed
@ -30,17 +30,19 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
[Cached]
|
[Cached]
|
||||||
public abstract class OnlinePlayScreen : OsuScreen, IHasSubScreenStack
|
public abstract class OnlinePlayScreen : OsuScreen, IHasSubScreenStack
|
||||||
{
|
{
|
||||||
public override bool CursorVisible => (screenStack.CurrentScreen as IOnlinePlaySubScreen)?.CursorVisible ?? true;
|
public override bool CursorVisible => (screenStack?.CurrentScreen as IOnlinePlaySubScreen)?.CursorVisible ?? true;
|
||||||
|
|
||||||
// this is required due to PlayerLoader eventually being pushed to the main stack
|
// this is required due to PlayerLoader eventually being pushed to the main stack
|
||||||
// while leases may be taken out by a subscreen.
|
// while leases may be taken out by a subscreen.
|
||||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||||
|
|
||||||
private readonly MultiplayerWaveContainer waves;
|
private MultiplayerWaveContainer waves;
|
||||||
|
|
||||||
private readonly OsuButton createButton;
|
private OsuButton createButton;
|
||||||
private readonly LoungeSubScreen loungeSubScreen;
|
|
||||||
private readonly ScreenStack screenStack;
|
private ScreenStack screenStack;
|
||||||
|
|
||||||
|
private LoungeSubScreen loungeSubScreen;
|
||||||
|
|
||||||
private readonly IBindable<bool> isIdle = new BindableBool();
|
private readonly IBindable<bool> isIdle = new BindableBool();
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
private readonly Bindable<FilterCriteria> currentFilter = new Bindable<FilterCriteria>(new FilterCriteria());
|
private readonly Bindable<FilterCriteria> currentFilter = new Bindable<FilterCriteria>(new FilterCriteria());
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private OngoingOperationTracker ongoingOperationTracker { get; set; }
|
private readonly OngoingOperationTracker ongoingOperationTracker = new OngoingOperationTracker();
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private MusicController music { get; set; }
|
private MusicController music { get; set; }
|
||||||
@ -65,11 +67,14 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
protected IAPIProvider API { get; private set; }
|
protected IAPIProvider API { get; private set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private IdleTracker idleTracker { get; set; }
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private OsuLogo logo { get; set; }
|
private OsuLogo logo { get; set; }
|
||||||
|
|
||||||
private readonly Drawable header;
|
private Drawable header;
|
||||||
private readonly Drawable headerBackground;
|
private Drawable headerBackground;
|
||||||
|
|
||||||
protected OnlinePlayScreen()
|
protected OnlinePlayScreen()
|
||||||
{
|
{
|
||||||
@ -78,6 +83,14 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING };
|
Padding = new MarginPadding { Horizontal = -HORIZONTAL_OVERFLOW_PADDING };
|
||||||
|
|
||||||
|
RoomManager = CreateRoomManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
var backgroundColour = Color4Extensions.FromHex(@"3e3a44");
|
var backgroundColour = Color4Extensions.FromHex(@"3e3a44");
|
||||||
|
|
||||||
InternalChild = waves = new MultiplayerWaveContainer
|
InternalChild = waves = new MultiplayerWaveContainer
|
||||||
@ -144,27 +157,14 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
};
|
};
|
||||||
button.Action = () => OpenNewRoom();
|
button.Action = () => OpenNewRoom();
|
||||||
}),
|
}),
|
||||||
RoomManager = CreateRoomManager(),
|
RoomManager,
|
||||||
ongoingOperationTracker = new OngoingOperationTracker()
|
ongoingOperationTracker,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
screenStack.ScreenPushed += screenPushed;
|
// a lot of the functionality in this class depends on loungeSubScreen being in a ready to go state.
|
||||||
screenStack.ScreenExited += screenExited;
|
// as such, we intentionally load this inline so it is ready alongside this screen.
|
||||||
|
LoadComponent(loungeSubScreen = CreateLounge());
|
||||||
screenStack.Push(loungeSubScreen = CreateLounge());
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
|
||||||
private void load(IdleTracker idleTracker)
|
|
||||||
{
|
|
||||||
apiState.BindTo(API.State);
|
|
||||||
apiState.BindValueChanged(onlineStateChanged, true);
|
|
||||||
|
|
||||||
if (idleTracker != null)
|
|
||||||
isIdle.BindTo(idleTracker.IsIdle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onlineStateChanged(ValueChangedEvent<APIState> state) => Schedule(() =>
|
private void onlineStateChanged(ValueChangedEvent<APIState> state) => Schedule(() =>
|
||||||
@ -179,7 +179,20 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
isIdle.BindValueChanged(idle => UpdatePollingRate(idle.NewValue), true);
|
|
||||||
|
screenStack.ScreenPushed += screenPushed;
|
||||||
|
screenStack.ScreenExited += screenExited;
|
||||||
|
|
||||||
|
screenStack.Push(loungeSubScreen);
|
||||||
|
|
||||||
|
apiState.BindTo(API.State);
|
||||||
|
apiState.BindValueChanged(onlineStateChanged, true);
|
||||||
|
|
||||||
|
if (idleTracker != null)
|
||||||
|
{
|
||||||
|
isIdle.BindTo(idleTracker.IsIdle);
|
||||||
|
isIdle.BindValueChanged(idle => UpdatePollingRate(idle.NewValue), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
Loading…
Reference in New Issue
Block a user