1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 17:57:38 +08:00

Merge pull request #1788 from peppy/fix-push-disabled-crash

Fix crash from being able to perform selection after entering play mode
This commit is contained in:
Dean Herbert 2017-12-31 03:07:38 +09:00 committed by GitHub
commit d18b6aada9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 12 deletions

View File

@ -46,7 +46,7 @@ namespace osu.Game.Screens.Select.Carousel
{ {
if (songSelect != null) if (songSelect != null)
{ {
startRequested = songSelect.Start; startRequested = songSelect.FinaliseSelection;
editRequested = songSelect.Edit; editRequested = songSelect.Edit;
} }

View File

@ -7,6 +7,10 @@ namespace osu.Game.Screens.Select
{ {
protected override bool ShowFooter => false; protected override bool ShowFooter => false;
protected override void Start() => Exit(); protected override bool OnSelectionFinalised()
{
Exit();
return true;
}
} }
} }

View File

@ -5,6 +5,10 @@ namespace osu.Game.Screens.Select
{ {
public class MatchSongSelect : SongSelect public class MatchSongSelect : SongSelect
{ {
protected override void Start() => Exit(); protected override bool OnSelectionFinalised()
{
Exit();
return true;
}
} }
} }

View File

@ -124,9 +124,9 @@ namespace osu.Game.Screens.Select
return false; 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. // Ctrl+Enter should start map with autoplay enabled.
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true) if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
@ -147,7 +147,12 @@ namespace osu.Game.Screens.Select
sampleConfirm?.Play(); sampleConfirm?.Play();
LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player)); LoadComponentAsync(player = new PlayerLoader(new Player()), l =>
{
if (IsCurrentScreen) Push(player);
});
return true;
} }
} }
} }

View File

@ -227,12 +227,17 @@ namespace osu.Game.Screens.Select
Push(new Editor()); Push(new Editor());
} }
public void Start(BeatmapInfo beatmap) /// <summary>
/// Call to make a selection and perform the default action for this SongSelect.
/// </summary>
/// <param name="beatmap">An optional beatmap to override the current carousel selection.</param>
public void FinaliseSelection(BeatmapInfo beatmap = null)
{ {
// if we have a pending filter operation, we want to run it now. // if we have a pending filter operation, we want to run it now.
// it could change selection (ie. if the ruleset has been changed). // it could change selection (ie. if the ruleset has been changed).
Carousel.FlushPendingFilterOperations(); Carousel.FlushPendingFilterOperations();
if (beatmap != null)
Carousel.SelectBeatmap(beatmap); Carousel.SelectBeatmap(beatmap);
if (selectionChangedDebounce?.Completed == false) if (selectionChangedDebounce?.Completed == false)
@ -242,13 +247,14 @@ namespace osu.Game.Screens.Select
selectionChangedDebounce = null; selectionChangedDebounce = null;
} }
Start(); OnSelectionFinalised();
} }
/// <summary> /// <summary>
/// Called when a selection is made. /// Called when a selection is made.
/// </summary> /// </summary>
protected abstract void Start(); /// <returns>If a resultant action occurred that takes the user away from SongSelect.</returns>
protected abstract bool OnSelectionFinalised();
private ScheduledDelegate selectionChangedDebounce; private ScheduledDelegate selectionChangedDebounce;
@ -339,7 +345,7 @@ namespace osu.Game.Screens.Select
logo.Action = () => logo.Action = () =>
{ {
Start(); FinaliseSelection();
return false; return false;
}; };
} }
@ -462,7 +468,7 @@ namespace osu.Game.Screens.Select
{ {
case Key.KeypadEnter: case Key.KeypadEnter:
case Key.Enter: case Key.Enter:
Start(); FinaliseSelection();
return true; return true;
case Key.Delete: case Key.Delete:
if (state.Keyboard.ShiftPressed) if (state.Keyboard.ShiftPressed)