From e0f23a056ab838af5dde01e9b247bc3306779eef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 28 Dec 2017 21:07:19 +0900 Subject: [PATCH 1/2] Fix crash from being able to perform selection after entering play mode Closes #1757 --- .../Select/Carousel/DrawableCarouselBeatmap.cs | 2 +- osu.Game/Screens/Select/EditSongSelect.cs | 6 +++++- osu.Game/Screens/Select/MatchSongSelect.cs | 6 +++++- osu.Game/Screens/Select/PlaySongSelect.cs | 11 ++++++++--- osu.Game/Screens/Select/SongSelect.cs | 18 ++++++++++++------ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs index 6c0cc341fd..cea658b06c 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Select.Carousel { if (songSelect != null) { - startRequested = songSelect.Start; + startRequested = songSelect.FinaliseSelection; editRequested = songSelect.Edit; } diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index f02d25501e..37f2663d91 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -7,6 +7,10 @@ namespace osu.Game.Screens.Select { protected override bool ShowFooter => false; - protected override void Start() => Exit(); + protected override bool OnSelectionFinalised() + { + Exit(); + return true; + } } } diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index 898c195432..9143da326d 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -5,6 +5,10 @@ namespace osu.Game.Screens.Select { public class MatchSongSelect : SongSelect { - protected override void Start() => Exit(); + protected override bool OnSelectionFinalised() + { + Exit(); + return true; + } } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 727cdb9959..87b3485dc1 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -124,9 +124,9 @@ namespace osu.Game.Screens.Select return false; } - protected override void Start() + protected override bool OnSelectionFinalised() { - if (player != null) return; + if (player != null) return false; // Ctrl+Enter should start map with autoplay enabled. if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true) @@ -147,7 +147,12 @@ namespace osu.Game.Screens.Select sampleConfirm?.Play(); - LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player)); + LoadComponentAsync(player = new PlayerLoader(new Player()), l => + { + if (IsCurrentScreen) Push(player); + }); + + return true; } } } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 9e5a2fa633..b89a8a4e73 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -227,13 +227,18 @@ namespace osu.Game.Screens.Select Push(new Editor()); } - public void Start(BeatmapInfo beatmap) + /// + /// Call to make a selection and perform the default action for this SongSelect. + /// + /// An optional beatmap to override the current carousel selection. + public void FinaliseSelection(BeatmapInfo beatmap = null) { // if we have a pending filter operation, we want to run it now. // it could change selection (ie. if the ruleset has been changed). Carousel.FlushPendingFilterOperations(); - Carousel.SelectBeatmap(beatmap); + if (beatmap != null) + Carousel.SelectBeatmap(beatmap); if (selectionChangedDebounce?.Completed == false) { @@ -242,13 +247,14 @@ namespace osu.Game.Screens.Select selectionChangedDebounce = null; } - Start(); + OnSelectionFinalised(); } /// /// Called when a selection is made. /// - protected abstract void Start(); + /// If a resultant action occurred that takes the user away from SongSelect. + protected abstract bool OnSelectionFinalised(); private ScheduledDelegate selectionChangedDebounce; @@ -339,7 +345,7 @@ namespace osu.Game.Screens.Select logo.Action = () => { - Start(); + FinaliseSelection(); return false; }; } @@ -462,7 +468,7 @@ namespace osu.Game.Screens.Select { case Key.KeypadEnter: case Key.Enter: - Start(); + FinaliseSelection(); return true; case Key.Delete: if (state.Keyboard.ShiftPressed) From 379d488160c7bb3ef150e24731086d0001af9906 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 28 Dec 2017 21:54:34 +0900 Subject: [PATCH 2/2] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 10cae790c6..293b156697 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 10cae790c6f1d559c326f9438958d0b012d61dc6 +Subproject commit 293b1566971963202986d781f23df4ac1a6e8f20