mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 19:42:56 +08:00
Reorganise song select methods to allow for more flexibility.
This commit is contained in:
parent
847f96de94
commit
9c664e5b05
@ -352,39 +352,68 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBeatmapSet(BeatmapSetInfo beatmapSet, Framework.Game game, bool select = false)
|
private BeatmapGroup prepareBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.ID);
|
database.GetChildren(beatmapSet);
|
||||||
beatmapSet.Beatmaps.ForEach(b =>
|
beatmapSet.Beatmaps.ForEach(b => { if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; });
|
||||||
{
|
|
||||||
database.GetChildren(b);
|
|
||||||
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
|
|
||||||
});
|
|
||||||
|
|
||||||
var group = new BeatmapGroup(beatmapSet, database)
|
return new BeatmapGroup(beatmapSet, database)
|
||||||
{
|
{
|
||||||
SelectionChanged = selectionChanged,
|
SelectionChanged = selectionChanged,
|
||||||
StartRequested = b => raiseSelect()
|
StartRequested = b => raiseSelect()
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addBeatmapSet(BeatmapSetInfo beatmapSet, Framework.Game game, bool select = false)
|
||||||
|
{
|
||||||
|
var group = prepareBeatmapSet(beatmapSet);
|
||||||
|
|
||||||
//for the time being, let's completely load the difficulty panels in the background.
|
//for the time being, let's completely load the difficulty panels in the background.
|
||||||
//this likely won't scale so well, but allows us to completely async the loading flow.
|
//this likely won't scale so well, but allows us to completely async the loading flow.
|
||||||
Task.WhenAll(group.BeatmapPanels.Select(panel => panel.LoadAsync(game))).ContinueWith(task => Schedule(delegate
|
Task.WhenAll(group.BeatmapPanels.Select(panel => panel.LoadAsync(game))).ContinueWith(task => Schedule(delegate
|
||||||
{
|
{
|
||||||
beatmapGroups.Add(group);
|
addGroup(group);
|
||||||
|
|
||||||
group.State = BeatmapGroupState.Collapsed;
|
|
||||||
carousel.AddGroup(group);
|
|
||||||
|
|
||||||
filterChanged(false, false);
|
|
||||||
|
|
||||||
if (Beatmap == null || select)
|
if (Beatmap == null || select)
|
||||||
carousel.SelectBeatmap(beatmapSet.Beatmaps.First());
|
selectBeatmap(beatmapSet);
|
||||||
else
|
else
|
||||||
carousel.SelectBeatmap(Beatmap.BeatmapInfo);
|
selectBeatmap();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addGroup(BeatmapGroup group)
|
||||||
|
{
|
||||||
|
beatmapGroups.Add(group);
|
||||||
|
|
||||||
|
group.State = BeatmapGroupState.Collapsed;
|
||||||
|
carousel.AddGroup(group);
|
||||||
|
|
||||||
|
filterChanged(false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectBeatmap(BeatmapSetInfo beatmapSet = null)
|
||||||
|
{
|
||||||
|
carousel.SelectBeatmap(beatmapSet != null ? beatmapSet.Beatmaps.First() : Beatmap.BeatmapInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addBeatmapSets(Framework.Game game, CancellationToken token)
|
||||||
|
{
|
||||||
|
List<BeatmapGroup> groups = new List<BeatmapGroup>();
|
||||||
|
|
||||||
|
foreach (var beatmapSet in database.Query<BeatmapSetInfo>().Where(b => !b.DeletePending))
|
||||||
|
{
|
||||||
|
if (token.IsCancellationRequested) return;
|
||||||
|
|
||||||
|
groups.Add(prepareBeatmapSet(beatmapSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
groups.ForEach(addGroup);
|
||||||
|
selectBeatmap(Beatmap?.BeatmapSetInfo ?? groups.First().BeatmapSet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)
|
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
var group = beatmapGroups.Find(b => b.BeatmapSet.ID == beatmapSet.ID);
|
var group = beatmapGroups.Find(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||||
@ -400,15 +429,6 @@ namespace osu.Game.Screens.Select
|
|||||||
Beatmap = null;
|
Beatmap = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBeatmapSets(Framework.Game game, CancellationToken token)
|
|
||||||
{
|
|
||||||
foreach (var beatmapSet in database.Query<BeatmapSetInfo>().Where(b => !b.DeletePending))
|
|
||||||
{
|
|
||||||
if (token.IsCancellationRequested) return;
|
|
||||||
addBeatmapSet(beatmapSet, game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void promptDelete()
|
private void promptDelete()
|
||||||
{
|
{
|
||||||
if (Beatmap != null)
|
if (Beatmap != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user