2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-05-14 16:41:35 +08:00
|
|
|
|
using System;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Music
|
|
|
|
|
{
|
|
|
|
|
public class PlaylistOverlay : OverlayContainer
|
|
|
|
|
{
|
|
|
|
|
private const float transition_duration = 600;
|
|
|
|
|
private const float playlist_height = 510;
|
|
|
|
|
|
2018-05-23 16:37:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Invoked when the order of an item in the list has changed.
|
|
|
|
|
/// The second parameter indicates the new index of the item.
|
|
|
|
|
/// </summary>
|
2018-05-14 16:41:35 +08:00
|
|
|
|
public Action<BeatmapSetInfo, int> OrderChanged;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-06 19:19:30 +08:00
|
|
|
|
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private BeatmapManager beatmaps;
|
2018-05-23 16:37:39 +08:00
|
|
|
|
|
2018-05-14 16:41:35 +08:00
|
|
|
|
private FilterControl filter;
|
|
|
|
|
private PlaylistList list;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-02-01 14:42:15 +08:00
|
|
|
|
private void load(OsuColour colours, Bindable<WorkingBeatmap> beatmap, BeatmapManager beatmaps)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-06-06 19:19:30 +08:00
|
|
|
|
this.beatmap.BindTo(beatmap);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
this.beatmaps = beatmaps;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
CornerRadius = 5,
|
|
|
|
|
Masking = true,
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
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 },
|
2018-05-14 16:41:35 +08:00
|
|
|
|
Selected = itemSelected,
|
|
|
|
|
OrderChanged = (s, i) => OrderChanged?.Invoke(s, i)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
filter = new FilterControl
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
ExitRequested = () => State = Visibility.Hidden,
|
|
|
|
|
FilterChanged = search => list.Filter(search),
|
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
filter.Search.OnCommit = (sender, newText) =>
|
|
|
|
|
{
|
2018-05-23 16:37:39 +08:00
|
|
|
|
BeatmapInfo toSelect = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault();
|
|
|
|
|
if (toSelect != null)
|
2018-05-23 18:41:13 +08:00
|
|
|
|
{
|
2018-05-23 16:37:39 +08:00
|
|
|
|
beatmap.Value = beatmaps.GetWorkingBeatmap(toSelect);
|
2018-05-28 17:01:15 +08:00
|
|
|
|
beatmap.Value.Track.Restart();
|
2018-05-23 18:41:13 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
filter.Search.HoldFocus = true;
|
2019-01-25 18:20:08 +08:00
|
|
|
|
Schedule(() => filter.Search.TakeFocus());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
this.ResizeTo(new Vector2(1, playlist_height), transition_duration, Easing.OutQuint);
|
|
|
|
|
this.FadeIn(transition_duration, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
filter.Search.HoldFocus = false;
|
|
|
|
|
|
|
|
|
|
this.ResizeTo(new Vector2(1, 0), transition_duration, Easing.OutQuint);
|
|
|
|
|
this.FadeOut(transition_duration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void itemSelected(BeatmapSetInfo set)
|
|
|
|
|
{
|
2018-05-23 16:37:39 +08:00
|
|
|
|
if (set.ID == (beatmap.Value?.BeatmapSetInfo?.ID ?? -1))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-05-23 16:37:39 +08:00
|
|
|
|
beatmap.Value?.Track?.Seek(0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 16:37:39 +08:00
|
|
|
|
beatmap.Value = beatmaps.GetWorkingBeatmap(set.Beatmaps.First());
|
2018-05-28 17:01:15 +08:00
|
|
|
|
beatmap.Value.Track.Restart();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo: placeholder
|
|
|
|
|
public enum PlaylistCollection
|
|
|
|
|
{
|
|
|
|
|
All
|
|
|
|
|
}
|
|
|
|
|
}
|