Merge pull request #2679 from peppy/fix-player-life-management

Fix player life management
This commit is contained in:
Dan Balasescu 2018-05-31 14:42:47 +09:00 committed by GitHub
commit e7c35d7541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 10 deletions

View File

@ -209,8 +209,11 @@ protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
// if the player never got pushed, we should explicitly dispose it.
loadTask?.ContinueWith(_ => player.Dispose());
if (isDisposing)
{
// if the player never got pushed, we should explicitly dispose it.
loadTask?.ContinueWith(_ => player.Dispose());
}
}
private class BeatmapMetadataDisplay : Container

View File

@ -51,7 +51,7 @@ private void load(SongSelect songSelect, BeatmapManager manager, BeatmapSetOverl
if (songSelect != null)
{
startRequested = songSelect.FinaliseSelection;
startRequested = b => songSelect.FinaliseSelection(b);
editRequested = songSelect.Edit;
}

View File

@ -7,7 +7,7 @@ public class EditSongSelect : SongSelect
{
protected override bool ShowFooter => false;
protected override bool OnSelectionFinalised()
protected override bool OnStart()
{
Exit();
return true;

View File

@ -5,7 +5,7 @@ namespace osu.Game.Screens.Select
{
public class MatchSongSelect : SongSelect
{
protected override bool OnSelectionFinalised()
protected override bool OnStart()
{
Schedule(() =>
{

View File

@ -137,7 +137,7 @@ protected override bool OnExiting(Screen next)
return false;
}
protected override bool OnSelectionFinalised()
protected override bool OnStart()
{
if (player != null) return false;

View File

@ -227,7 +227,8 @@ public void Edit(BeatmapInfo beatmap)
/// 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)
/// <param name="performStartAction">Whether to trigger <see cref="OnStart"/>.</param>
public void FinaliseSelection(BeatmapInfo beatmap = null, bool performStartAction = true)
{
// if we have a pending filter operation, we want to run it now.
// it could change selection (ie. if the ruleset has been changed).
@ -243,14 +244,15 @@ public void FinaliseSelection(BeatmapInfo beatmap = null)
selectionChangedDebounce = null;
}
OnSelectionFinalised();
if (performStartAction)
OnStart();
}
/// <summary>
/// Called when a selection is made.
/// </summary>
/// <returns>If a resultant action occurred that takes the user away from SongSelect.</returns>
protected abstract bool OnSelectionFinalised();
protected abstract bool OnStart();
private ScheduledDelegate selectionChangedDebounce;
@ -395,7 +397,7 @@ protected override void OnSuspending(Screen next)
protected override bool OnExiting(Screen next)
{
FinaliseSelection();
FinaliseSelection(performStartAction: false);
beatmapInfoWedge.State = Visibility.Hidden;