From 15100632f16d66f6b2066e26d0d8e0eca6acb006 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 25 Jan 2019 17:44:33 +0900 Subject: [PATCH] Remove MultiplayerSubScreen and fix multiplayer crashes --- .../UserInterface/ScreenBreadcrumbControl.cs | 4 +- .../Screens/Multi/IMultiplayerSubScreen.cs | 2 + .../Screens/Multi/Lounge/LoungeSubScreen.cs | 47 ++++++++++++---- .../Screens/Multi/Match/MatchSubScreen.cs | 53 ++++++++++++++++--- .../Screens/Multi/MultiplayerSubScreen.cs | 49 ----------------- 5 files changed, 86 insertions(+), 69 deletions(-) delete mode 100644 osu.Game/Screens/Multi/MultiplayerSubScreen.cs diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs index ed8f5e3b34..a327b401ee 100644 --- a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs @@ -17,13 +17,15 @@ namespace osu.Game.Graphics.UserInterface stack.ScreenPushed += onPushed; stack.ScreenExited += onExited; + onPushed(null, stack.CurrentScreen); + Current.ValueChanged += newScreen => newScreen.MakeCurrent(); } private void onPushed(IScreen lastScreen, IScreen newScreen) { - Current.Value = newScreen; AddItem(newScreen); + Current.Value = newScreen; } private void onExited(IScreen lastScreen, IScreen newScreen) diff --git a/osu.Game/Screens/Multi/IMultiplayerSubScreen.cs b/osu.Game/Screens/Multi/IMultiplayerSubScreen.cs index e3267b01ab..021892ff7d 100644 --- a/osu.Game/Screens/Multi/IMultiplayerSubScreen.cs +++ b/osu.Game/Screens/Multi/IMultiplayerSubScreen.cs @@ -5,6 +5,8 @@ namespace osu.Game.Screens.Multi { public interface IMultiplayerSubScreen : IOsuScreen { + string Title { get; } + string ShortTitle { get; } } } diff --git a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs index 8b0a6b15c3..5b5f4d6d70 100644 --- a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs +++ b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Framework.Screens; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Overlays.SearchableList; @@ -15,8 +16,20 @@ using osu.Game.Screens.Multi.Match; namespace osu.Game.Screens.Multi.Lounge { - public class LoungeSubScreen : MultiplayerSubScreen + public class LoungeSubScreen : CompositeDrawable, IMultiplayerSubScreen { + public bool AllowBeatmapRulesetChange => true; + public bool AllowExternalScreenChange => true; + public bool CursorVisible => true; + + public string Title => "Lounge"; + public string ShortTitle => Title; + + public bool ValidForResume { get; set; } = true; + public bool ValidForPush { get; set; } = true; + + public override bool RemoveWhenNotAlive => false; + protected readonly FilterControl Filter; private readonly Container content; @@ -27,14 +40,12 @@ namespace osu.Game.Screens.Multi.Lounge [Resolved(CanBeNull = true)] private IRoomManager roomManager { get; set; } - public override string Title => "Lounge"; - - protected override Drawable TransitionContent => content; - public LoungeSubScreen(Action pushGameplayScreen) { this.pushGameplayScreen = pushGameplayScreen; + RelativeSizeAxes = Axes.Both; + RoomInspector inspector; InternalChildren = new Drawable[] @@ -101,22 +112,36 @@ namespace osu.Game.Screens.Multi.Lounge GetContainingInputManager().ChangeFocus(Filter.Search); } - public override void OnEntering(IScreen last) + public void OnEntering(IScreen last) { - base.OnEntering(last); + this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); + Filter.Search.HoldFocus = true; } - public override bool OnExiting(IScreen next) + public bool OnExiting(IScreen next) { + this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + Filter.Search.HoldFocus = false; - // no base call; don't animate + return false; } - public override void OnSuspending(IScreen next) + public void OnResuming(IScreen last) { - base.OnSuspending(next); + this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); + } + + public void OnSuspending(IScreen next) + { + this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + Filter.Search.HoldFocus = false; } diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index 58ca42e293..2bf67690e2 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Screens; using osu.Game.Beatmaps; +using osu.Game.Graphics.Containers; using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer.GameTypes; using osu.Game.Rulesets; @@ -18,11 +19,19 @@ using osu.Game.Screens.Select; namespace osu.Game.Screens.Multi.Match { - public class MatchSubScreen : MultiplayerSubScreen + public class MatchSubScreen : CompositeDrawable, IMultiplayerSubScreen { - public override bool AllowBeatmapRulesetChange => false; - public override string Title => room.RoomID.Value == null ? "New room" : room.Name.Value; - public override string ShortTitle => "room"; + public bool AllowBeatmapRulesetChange => false; + public bool AllowExternalScreenChange => true; + public bool CursorVisible => true; + + public string Title => room.RoomID.Value == null ? "New room" : room.Name.Value; + public string ShortTitle => "room"; + + public bool ValidForResume { get; set; } = true; + public bool ValidForPush { get; set; } = true; + + public override bool RemoveWhenNotAlive => false; private readonly RoomBindings bindings = new RoomBindings(); @@ -33,6 +42,9 @@ namespace osu.Game.Screens.Multi.Match [Cached] private readonly Room room; + [Resolved] + private IBindableBeatmap beatmap { get; set; } + [Resolved] private BeatmapManager beatmapManager { get; set; } @@ -47,6 +59,8 @@ namespace osu.Game.Screens.Multi.Match this.room = room; this.pushGameplayScreen = pushGameplayScreen; + RelativeSizeAxes = Axes.Both; + bindings.Room = room; MatchChatDisplay chat; @@ -135,10 +149,33 @@ namespace osu.Game.Screens.Multi.Match beatmapManager.ItemAdded += beatmapAdded; } - public override bool OnExiting(IScreen next) + public void OnEntering(IScreen last) + { + this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); + } + + public bool OnExiting(IScreen next) { manager?.PartRoom(); - return base.OnExiting(next); + + this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + + return false; + } + + public void OnResuming(IScreen last) + { + this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); + } + + public void OnSuspending(IScreen next) + { + this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); } protected override void LoadComplete() @@ -167,7 +204,7 @@ namespace osu.Game.Screens.Multi.Match private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() => { - if (Beatmap.Value != beatmapManager.DefaultBeatmap) + if (beatmap.Value != beatmapManager.DefaultBeatmap) return; if (bindings.CurrentBeatmap.Value == null) @@ -188,7 +225,7 @@ namespace osu.Game.Screens.Multi.Match private void onStart() { - Beatmap.Value.Mods.Value = bindings.CurrentMods.Value.ToArray(); + beatmap.Value.Mods.Value = bindings.CurrentMods.Value.ToArray(); switch (bindings.Type.Value) { diff --git a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs b/osu.Game/Screens/Multi/MultiplayerSubScreen.cs deleted file mode 100644 index 6549408482..0000000000 --- a/osu.Game/Screens/Multi/MultiplayerSubScreen.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Screens; -using osu.Game.Graphics.Containers; - -namespace osu.Game.Screens.Multi -{ - public abstract class MultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen - { - protected virtual Drawable TransitionContent => this; - - public virtual string ShortTitle => Title; - - public override void OnEntering(IScreen last) - { - base.OnEntering(last); - - this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); - TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); - TransitionContent.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); - } - - public override bool OnExiting(IScreen next) - { - this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); - TransitionContent.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); - - return base.OnExiting(next); - } - - public override void OnResuming(IScreen last) - { - base.OnResuming(last); - - this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); - TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); - } - - public override void OnSuspending(IScreen next) - { - base.OnSuspending(next); - - this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); - TransitionContent.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); - } - } -}