1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:07: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)
{
startRequested = songSelect.Start;
startRequested = songSelect.FinaliseSelection;
editRequested = songSelect.Edit;
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

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)