2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-05-01 14:03:11 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-21 18:23:38 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-05-01 14:03:11 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Music
|
|
|
|
|
{
|
|
|
|
|
public class PlaylistOverlay : OverlayContainer
|
|
|
|
|
{
|
|
|
|
|
private const float transition_duration = 600;
|
|
|
|
|
|
|
|
|
|
private const float playlist_height = 510;
|
|
|
|
|
|
|
|
|
|
private FilterControl filter;
|
|
|
|
|
private PlaylistList list;
|
|
|
|
|
|
2017-07-27 15:56:41 +08:00
|
|
|
|
private BeatmapManager beatmaps;
|
2017-05-01 14:03:11 +08:00
|
|
|
|
|
|
|
|
|
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
|
|
|
|
|
2017-12-03 23:41:21 +08:00
|
|
|
|
public IEnumerable<BeatmapSetInfo> BeatmapSets => list.BeatmapSets;
|
2017-05-01 14:03:11 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2017-08-15 13:30:50 +08:00
|
|
|
|
private void load(OsuGameBase game, BeatmapManager beatmaps, OsuColour colours)
|
2017-05-01 14:03:11 +08:00
|
|
|
|
{
|
|
|
|
|
this.beatmaps = beatmaps;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
CornerRadius = 5,
|
|
|
|
|
Masking = true,
|
2017-06-12 11:48:47 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2017-05-01 14:03:11 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(40),
|
|
|
|
|
Radius = 5,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = colours.Gray3,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
list = new PlaylistList
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Top = 95, Bottom = 10, Right = 10 },
|
|
|
|
|
OnSelect = itemSelected,
|
|
|
|
|
},
|
|
|
|
|
filter = new FilterControl
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-05-01 14:23:01 +08:00
|
|
|
|
ExitRequested = () => State = Visibility.Hidden,
|
2017-05-02 09:45:55 +08:00
|
|
|
|
FilterChanged = search => list.Filter(search),
|
2017-05-01 14:03:11 +08:00
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-15 11:56:22 +08:00
|
|
|
|
beatmaps.ItemAdded += list.AddBeatmapSet;
|
|
|
|
|
beatmaps.ItemRemoved += list.RemoveBeatmapSet;
|
2017-05-01 14:03:11 +08:00
|
|
|
|
|
2017-12-03 23:41:21 +08:00
|
|
|
|
list.BeatmapSets = beatmaps.GetAllUsableBeatmapSets();
|
2017-05-01 14:03:11 +08:00
|
|
|
|
|
|
|
|
|
beatmapBacking.BindTo(game.Beatmap);
|
2017-05-05 12:59:24 +08:00
|
|
|
|
|
2017-07-18 16:24:09 +08:00
|
|
|
|
filter.Search.OnCommit = (sender, newText) =>
|
|
|
|
|
{
|
2017-05-12 19:48:25 +08:00
|
|
|
|
var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault();
|
2017-05-05 12:59:24 +08:00
|
|
|
|
if (beatmap != null) playSpecified(beatmap);
|
|
|
|
|
};
|
2017-05-01 14:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2017-09-04 12:12:12 +08:00
|
|
|
|
beatmapBacking.ValueChanged += b => list.SelectedSet = b?.BeatmapSetInfo;
|
2017-05-01 14:03:11 +08:00
|
|
|
|
beatmapBacking.TriggerChange();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
filter.Search.HoldFocus = true;
|
2017-08-15 13:30:50 +08:00
|
|
|
|
Schedule(() => GetContainingInputManager().ChangeFocus(filter.Search));
|
2017-05-01 14:03:11 +08:00
|
|
|
|
|
2017-07-23 02:50:25 +08:00
|
|
|
|
this.ResizeTo(new Vector2(1, playlist_height), transition_duration, Easing.OutQuint);
|
|
|
|
|
this.FadeIn(transition_duration, Easing.OutQuint);
|
2017-05-01 14:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
filter.Search.HoldFocus = false;
|
|
|
|
|
|
2017-07-23 02:50:25 +08:00
|
|
|
|
this.ResizeTo(new Vector2(1, 0), transition_duration, Easing.OutQuint);
|
2017-07-15 00:18:12 +08:00
|
|
|
|
this.FadeOut(transition_duration);
|
2017-05-01 14:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-01 14:09:14 +08:00
|
|
|
|
private void itemSelected(BeatmapSetInfo set)
|
2017-05-01 14:03:11 +08:00
|
|
|
|
{
|
|
|
|
|
if (set.ID == (beatmapBacking.Value?.BeatmapSetInfo?.ID ?? -1))
|
|
|
|
|
{
|
|
|
|
|
beatmapBacking.Value?.Track?.Seek(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-03 23:41:21 +08:00
|
|
|
|
playSpecified(set.Beatmaps.First());
|
2017-05-01 14:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PlayPrevious()
|
|
|
|
|
{
|
2017-09-04 12:12:12 +08:00
|
|
|
|
var playable = list.PreviousSet;
|
2017-05-01 14:03:11 +08:00
|
|
|
|
|
|
|
|
|
if (playable != null)
|
2017-08-28 15:56:03 +08:00
|
|
|
|
{
|
2017-12-03 23:41:21 +08:00
|
|
|
|
playSpecified(playable.Beatmaps.First());
|
2017-09-04 12:12:12 +08:00
|
|
|
|
list.SelectedSet = playable;
|
2017-08-28 15:56:03 +08:00
|
|
|
|
}
|
2017-05-01 14:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PlayNext()
|
|
|
|
|
{
|
2017-09-04 12:12:12 +08:00
|
|
|
|
var playable = list.NextSet;
|
2017-05-01 14:03:11 +08:00
|
|
|
|
|
|
|
|
|
if (playable != null)
|
2017-08-28 15:56:03 +08:00
|
|
|
|
{
|
2017-12-03 23:41:21 +08:00
|
|
|
|
playSpecified(playable.Beatmaps.First());
|
2017-09-04 12:12:12 +08:00
|
|
|
|
list.SelectedSet = playable;
|
2017-08-28 15:56:03 +08:00
|
|
|
|
}
|
2017-05-01 14:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void playSpecified(BeatmapInfo info)
|
|
|
|
|
{
|
|
|
|
|
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking);
|
2017-12-05 08:56:24 +08:00
|
|
|
|
|
|
|
|
|
var track = beatmapBacking.Value.Track;
|
|
|
|
|
|
|
|
|
|
track.Restart();
|
2017-05-01 14:03:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo: placeholder
|
|
|
|
|
public enum PlaylistCollection
|
|
|
|
|
{
|
|
|
|
|
All
|
|
|
|
|
}
|
|
|
|
|
}
|