From c3a0549cdd1e953534df5bd2f446d12c39fd63fd Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 16:58:34 +0800 Subject: [PATCH] Move player specific stuff to derived PlaySongSelect. --- osu.Game/Screens/Select/PlaySongSelect.cs | 30 +++++++++++++++++++++++ osu.Game/Screens/Select/SongSelect.cs | 17 ++++--------- osu.Game/osu.Game.csproj | 1 + 3 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 osu.Game/Screens/Select/PlaySongSelect.cs diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs new file mode 100644 index 0000000000..13395e52c2 --- /dev/null +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -0,0 +1,30 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Screens; +using osu.Game.Beatmaps; +using osu.Game.Screens.Play; + +namespace osu.Game.Screens.Select +{ + public class PlaySongSelect : SongSelect + { + private OsuScreen player; + + protected override void OnResuming(Screen last) + { + player = null; + base.OnResuming(last); + } + + protected override void OnSelected(WorkingBeatmap beatmap) + { + if (player != null) return; + + (player = new PlayerLoader(new Player + { + Beatmap = Beatmap, //eagerly set this so it's present before push. + })).LoadAsync(Game, l => Push(player)); + } + } +} diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index a55d20145e..d289004753 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -34,7 +34,7 @@ using osu.Game.Screens.Select.Options; namespace osu.Game.Screens.Select { - public class SongSelect : OsuScreen + public abstract class SongSelect : OsuScreen { private Bindable playMode = new Bindable(); private BeatmapDatabase database; @@ -60,8 +60,6 @@ namespace osu.Game.Screens.Select private BeatmapOptionsOverlay beatmapOptions; private Footer footer; - private OsuScreen player; - private FilterControl filter; public FilterControl Filter { @@ -158,15 +156,10 @@ namespace osu.Game.Screens.Select OnBack = Exit, OnStart = () => { - if (player != null || Beatmap == null) - return; + if (Beatmap == null) return; Beatmap.PreferredPlayMode = playMode.Value; - - (player = new PlayerLoader(new Player - { - Beatmap = Beatmap, //eagerly set this so it's present before push. - })).LoadAsync(Game, l => Push(player)); + OnSelected(Beatmap); } }, }; @@ -196,6 +189,8 @@ namespace osu.Game.Screens.Select Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token); } + protected abstract void OnSelected(WorkingBeatmap beatmap); + private ScheduledDelegate filterTask; private void filterChanged(bool debounce = true, bool eagerSelection = true) @@ -268,8 +263,6 @@ namespace osu.Game.Screens.Select protected override void OnResuming(Screen last) { - player = null; - changeBackground(Beatmap); ensurePlayingSelected(); base.OnResuming(last); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 4161fd4065..402bf45977 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -184,6 +184,7 @@ +