mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
@ -44,6 +45,8 @@ namespace osu.Game.Overlays.Music
|
|||||||
|
|
||||||
private class ItemsScrollContainer : OsuScrollContainer
|
private class ItemsScrollContainer : OsuScrollContainer
|
||||||
{
|
{
|
||||||
|
private BindableList<BeatmapSetInfo> beatmaps;
|
||||||
|
|
||||||
public Action<BeatmapSetInfo> Selected;
|
public Action<BeatmapSetInfo> Selected;
|
||||||
public Action<BeatmapSetInfo, int> OrderChanged;
|
public Action<BeatmapSetInfo, int> OrderChanged;
|
||||||
|
|
||||||
@ -73,20 +76,19 @@ namespace osu.Game.Overlays.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(BeatmapManager beatmaps, IBindable<WorkingBeatmap> beatmap)
|
private void load(MusicController musicController, IBindable<WorkingBeatmap> beatmap)
|
||||||
{
|
{
|
||||||
beatmaps.GetAllUsableBeatmapSets().ForEach(addBeatmapSet);
|
beatmaps = musicController.BeatmapSets.GetBoundCopy();
|
||||||
beatmaps.ItemAdded += addBeatmapSet;
|
|
||||||
beatmaps.ItemRemoved += removeBeatmapSet;
|
beatmaps.ItemsAdded += i => i.ForEach(addBeatmapSet);
|
||||||
|
beatmaps.ItemsRemoved += i => i.ForEach(removeBeatmapSet);
|
||||||
|
beatmaps.ForEach(addBeatmapSet);
|
||||||
|
|
||||||
beatmapBacking.BindTo(beatmap);
|
beatmapBacking.BindTo(beatmap);
|
||||||
beatmapBacking.ValueChanged += _ => updateSelectedSet();
|
beatmapBacking.ValueChanged += _ => updateSelectedSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBeatmapSet(BeatmapSetInfo obj) => Schedule(() =>
|
private void addBeatmapSet(BeatmapSetInfo obj) => Schedule(() => { items.Insert(items.Count - 1, new PlaylistItem(obj) { OnSelect = set => Selected?.Invoke(set) }); });
|
||||||
{
|
|
||||||
items.Insert(items.Count - 1, new PlaylistItem(obj) { OnSelect = set => Selected?.Invoke(set) });
|
|
||||||
});
|
|
||||||
|
|
||||||
private void removeBeatmapSet(BeatmapSetInfo obj) => Schedule(() =>
|
private void removeBeatmapSet(BeatmapSetInfo obj) => Schedule(() =>
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
@ -24,7 +25,7 @@ namespace osu.Game.Overlays
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; }
|
||||||
|
|
||||||
private List<BeatmapSetInfo> beatmapSets;
|
public readonly BindableList<BeatmapSetInfo> BeatmapSets = new BindableList<BeatmapSetInfo>();
|
||||||
|
|
||||||
public bool IsUserPaused { get; private set; }
|
public bool IsUserPaused { get; private set; }
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ namespace osu.Game.Overlays
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
beatmapSets = beatmaps.GetAllUsableBeatmapSets();
|
BeatmapSets.AddRange(beatmaps.GetAllUsableBeatmapSets().OrderBy(_ => RNG.Next()));
|
||||||
beatmaps.ItemAdded += handleBeatmapAdded;
|
beatmaps.ItemAdded += handleBeatmapAdded;
|
||||||
beatmaps.ItemRemoved += handleBeatmapRemoved;
|
beatmaps.ItemRemoved += handleBeatmapRemoved;
|
||||||
}
|
}
|
||||||
@ -65,8 +66,8 @@ namespace osu.Game.Overlays
|
|||||||
/// <param name="index">The new position.</param>
|
/// <param name="index">The new position.</param>
|
||||||
public void ChangeBeatmapSetPosition(BeatmapSetInfo beatmapSetInfo, int index)
|
public void ChangeBeatmapSetPosition(BeatmapSetInfo beatmapSetInfo, int index)
|
||||||
{
|
{
|
||||||
beatmapSets.Remove(beatmapSetInfo);
|
BeatmapSets.Remove(beatmapSetInfo);
|
||||||
beatmapSets.Insert(index, beatmapSetInfo);
|
BeatmapSets.Insert(index, beatmapSetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -75,10 +76,10 @@ namespace osu.Game.Overlays
|
|||||||
public bool IsPlaying => beatmap.Value.Track.IsRunning;
|
public bool IsPlaying => beatmap.Value.Track.IsRunning;
|
||||||
|
|
||||||
private void handleBeatmapAdded(BeatmapSetInfo set) =>
|
private void handleBeatmapAdded(BeatmapSetInfo set) =>
|
||||||
Schedule(() => beatmapSets.Add(set));
|
Schedule(() => BeatmapSets.Add(set));
|
||||||
|
|
||||||
private void handleBeatmapRemoved(BeatmapSetInfo set) =>
|
private void handleBeatmapRemoved(BeatmapSetInfo set) =>
|
||||||
Schedule(() => beatmapSets.RemoveAll(s => s.ID == set.ID));
|
Schedule(() => BeatmapSets.RemoveAll(s => s.ID == set.ID));
|
||||||
|
|
||||||
private ScheduledDelegate seekDelegate;
|
private ScheduledDelegate seekDelegate;
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
queuedDirection = TrackChangeDirection.Prev;
|
queuedDirection = TrackChangeDirection.Prev;
|
||||||
|
|
||||||
var playable = beatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? beatmapSets.LastOrDefault();
|
var playable = BeatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? BeatmapSets.LastOrDefault();
|
||||||
|
|
||||||
if (playable != null)
|
if (playable != null)
|
||||||
{
|
{
|
||||||
@ -165,7 +166,7 @@ namespace osu.Game.Overlays
|
|||||||
if (!instant)
|
if (!instant)
|
||||||
queuedDirection = TrackChangeDirection.Next;
|
queuedDirection = TrackChangeDirection.Next;
|
||||||
|
|
||||||
var playable = beatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).Skip(1).FirstOrDefault() ?? beatmapSets.FirstOrDefault();
|
var playable = BeatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).Skip(1).FirstOrDefault() ?? BeatmapSets.FirstOrDefault();
|
||||||
|
|
||||||
if (playable != null)
|
if (playable != null)
|
||||||
{
|
{
|
||||||
@ -200,8 +201,8 @@ namespace osu.Game.Overlays
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//figure out the best direction based on order in playlist.
|
//figure out the best direction based on order in playlist.
|
||||||
var last = beatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count();
|
var last = BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count();
|
||||||
var next = beatmap.NewValue == null ? -1 : beatmapSets.TakeWhile(b => b.ID != beatmap.NewValue.BeatmapSetInfo?.ID).Count();
|
var next = beatmap.NewValue == null ? -1 : BeatmapSets.TakeWhile(b => b.ID != beatmap.NewValue.BeatmapSetInfo?.ID).Count();
|
||||||
|
|
||||||
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
|
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user