mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 02:52:54 +08:00
Exit daily challenge screen when going offline
This sort of thing is bound to happen when rewriting screens from scratch without invoking abstract eldritch entities sometimes. Damned if you do, damned if you don't...
This commit is contained in:
parent
aded31bd07
commit
788b70469d
@ -21,6 +21,7 @@ using osu.Game.Database;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Metadata;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
@ -48,6 +49,8 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
||||
/// </summary>
|
||||
private readonly Bindable<IReadOnlyList<Mod>> userMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
||||
|
||||
private OnlinePlayScreenWaveContainer waves = null!;
|
||||
private DailyChallengeLeaderboard leaderboard = null!;
|
||||
private RoomModSelectOverlay userModsSelectOverlay = null!;
|
||||
@ -84,6 +87,9 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
||||
[Resolved]
|
||||
private UserLookupCache userLookupCache { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
protected IAPIProvider API { get; private set; } = null!;
|
||||
|
||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||
|
||||
public DailyChallenge(Room room)
|
||||
@ -358,6 +364,9 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
||||
userModsSelectOverlayRegistration = overlayManager?.RegisterBlockingOverlay(userModsSelectOverlay);
|
||||
userModsSelectOverlay.SelectedItem.Value = playlistItem;
|
||||
userMods.BindValueChanged(_ => Scheduler.AddOnce(updateMods), true);
|
||||
|
||||
apiState.BindTo(API.State);
|
||||
apiState.BindValueChanged(onlineStateChanged, true);
|
||||
}
|
||||
|
||||
private void trySetDailyChallengeBeatmap()
|
||||
@ -368,6 +377,25 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
||||
applyLoopingToTrack();
|
||||
}
|
||||
|
||||
private void onlineStateChanged(ValueChangedEvent<APIState> state) => Schedule(() =>
|
||||
{
|
||||
if (state.NewValue != APIState.Online)
|
||||
Schedule(forcefullyExit);
|
||||
});
|
||||
|
||||
private void forcefullyExit()
|
||||
{
|
||||
Logger.Log($"{this} forcefully exiting due to loss of API connection");
|
||||
|
||||
// This is temporary since we don't currently have a way to force screens to be exited
|
||||
// See also: `OnlinePlayScreen.forcefullyExit()`
|
||||
if (this.IsCurrentScreen())
|
||||
{
|
||||
while (this.IsCurrentScreen())
|
||||
this.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEntering(ScreenTransitionEvent e)
|
||||
{
|
||||
base.OnEntering(e);
|
||||
|
@ -99,6 +99,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
Logger.Log($"{this} forcefully exiting due to loss of API connection");
|
||||
|
||||
// This is temporary since we don't currently have a way to force screens to be exited
|
||||
// See also: `DailyChallenge.forcefullyExit()`
|
||||
if (this.IsCurrentScreen())
|
||||
{
|
||||
while (this.IsCurrentScreen())
|
||||
|
Loading…
Reference in New Issue
Block a user