mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +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.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
@ -28,6 +29,7 @@ namespace osu.Game.Overlays.Music
|
||||
private IEnumerable<SpriteText> titleSprites;
|
||||
private UnicodeBindableString titleBind;
|
||||
private UnicodeBindableString artistBind;
|
||||
private FillFlowContainer<PlaylistItem> Playlist;
|
||||
|
||||
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;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -132,6 +135,44 @@ namespace osu.Game.Overlays.Music
|
||||
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; }
|
||||
|
||||
private bool matching = true;
|
||||
|
Reference in New Issue
Block a user