1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 22:42:57 +08:00

Move player specific stuff to derived PlaySongSelect.

This commit is contained in:
Huo Yaoyuan 2017-03-14 16:58:34 +08:00
parent fae6afa9e3
commit c3a0549cdd
3 changed files with 36 additions and 12 deletions

View File

@ -0,0 +1,30 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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));
}
}
}

View File

@ -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> playMode = new Bindable<PlayMode>();
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);

View File

@ -184,6 +184,7 @@
<Compile Include="Modes\Ruleset.cs" />
<Compile Include="Screens\Ranking\Results.cs" />
<Compile Include="Screens\Direct\OnlineListing.cs" />
<Compile Include="Screens\Select\PlaySongSelect.cs" />
<Compile Include="Screens\Select\SongSelect.cs" />
<Compile Include="Modes\UI\HitRenderer.cs" />
<Compile Include="Modes\UI\Playfield.cs" />