mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 08:03:52 +09:00
Allow rearranging playlist tracks
This commit is contained in:
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -28,6 +29,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
private IEnumerable<SpriteText> titleSprites;
|
private IEnumerable<SpriteText> titleSprites;
|
||||||
private UnicodeBindableString titleBind;
|
private UnicodeBindableString titleBind;
|
||||||
private UnicodeBindableString artistBind;
|
private UnicodeBindableString artistBind;
|
||||||
|
private FillFlowContainer<PlaylistItem> Playlist;
|
||||||
|
|
||||||
public readonly BeatmapSetInfo BeatmapSetInfo;
|
public readonly BeatmapSetInfo BeatmapSetInfo;
|
||||||
|
|
||||||
@ -48,8 +50,9 @@ namespace osu.Game.Overlays.Music
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaylistItem(BeatmapSetInfo setInfo)
|
public PlaylistItem(FillFlowContainer<PlaylistItem> playlist, BeatmapSetInfo setInfo)
|
||||||
{
|
{
|
||||||
|
Playlist = playlist;
|
||||||
BeatmapSetInfo = setInfo;
|
BeatmapSetInfo = setInfo;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -132,6 +135,44 @@ namespace osu.Game.Overlays.Music
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnDragStart(InputState state)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maybe render some ghost text
|
||||||
|
protected override bool OnDrag(InputState state)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int clamp(int value, int min, int max)
|
||||||
|
{
|
||||||
|
return (value <= min) ? min : (value >= max) ? max : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnDragEnd(InputState state)
|
||||||
|
{
|
||||||
|
int src = (int) Depth;
|
||||||
|
int dst = clamp((int) ((state.Mouse.Position.Y - Parent.DrawPosition.Y) / Height), 0, Playlist.Count - 1);
|
||||||
|
|
||||||
|
if (src == dst)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (src < dst)
|
||||||
|
{
|
||||||
|
for (int i = src + 1; i <= dst; i++)
|
||||||
|
Playlist.ChangeChildDepth(Playlist[i], i - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = dst; i < src; i++)
|
||||||
|
Playlist.ChangeChildDepth(Playlist[i], i + 1);
|
||||||
|
}
|
||||||
|
Playlist.ChangeChildDepth(this, dst);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public string[] FilterTerms { get; private set; }
|
public string[] FilterTerms { get; private set; }
|
||||||
|
|
||||||
private bool matching = true;
|
private bool matching = true;
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
items.Children = value.Select(item => new PlaylistItem(item) { OnSelect = itemSelected }).ToList();
|
items.Children = value.Select((item, index) => new PlaylistItem(items, item) { OnSelect = itemSelected, Depth = index }).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
|
|
||||||
public void AddBeatmapSet(BeatmapSetInfo beatmapSet)
|
public void AddBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
items.Add(new PlaylistItem(beatmapSet) { OnSelect = itemSelected });
|
items.Add(new PlaylistItem(items, beatmapSet) { OnSelect = itemSelected, Depth = items.Count });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||||
@ -96,6 +96,9 @@ namespace osu.Game.Overlays.Music
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compare with reversed ChildID and Depth
|
||||||
|
protected override int Compare(Drawable x, Drawable y) => base.Compare(y, x);
|
||||||
|
|
||||||
public IEnumerable<IFilterable> FilterableChildren => Children;
|
public IEnumerable<IFilterable> FilterableChildren => Children;
|
||||||
|
|
||||||
public ItemSearchContainer()
|
public ItemSearchContainer()
|
||||||
|
Reference in New Issue
Block a user