Fix crash from being able to perform selection after entering play mode

Closes #1757
This commit is contained in:
Dean Herbert
2017-12-28 21:07:19 +09:00
parent 8f716212a7
commit e0f23a056a
5 changed files with 31 additions and 12 deletions

View File

@ -227,13 +227,18 @@ namespace osu.Game.Screens.Select
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.
// 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();
}
/// <summary>
/// Called when a selection is made.
/// </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;
@ -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)