mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 07:43:01 +08:00
Add dropdowns to carousel items
This commit is contained in:
parent
6d5e155106
commit
094ddecc95
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -17,6 +18,7 @@ using osu.Framework.Graphics.UserInterface;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
|
using osu.Game.Collections;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -46,6 +48,9 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapDifficultyManager difficultyManager { get; set; }
|
private BeatmapDifficultyManager difficultyManager { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private CollectionManager collectionManager { get; set; }
|
||||||
|
|
||||||
private IBindable<StarDifficulty> starDifficultyBindable;
|
private IBindable<StarDifficulty> starDifficultyBindable;
|
||||||
private CancellationTokenSource starDifficultyCancellationSource;
|
private CancellationTokenSource starDifficultyCancellationSource;
|
||||||
|
|
||||||
@ -219,10 +224,31 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
if (beatmap.OnlineBeatmapID.HasValue && beatmapOverlay != null)
|
if (beatmap.OnlineBeatmapID.HasValue && beatmapOverlay != null)
|
||||||
items.Add(new OsuMenuItem("Details", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value)));
|
items.Add(new OsuMenuItem("Details", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value)));
|
||||||
|
|
||||||
|
items.Add(new OsuMenuItem("Add to...")
|
||||||
|
{
|
||||||
|
Items = collectionManager.Collections.Take(3).Select(createCollectionMenuItem)
|
||||||
|
.Append(new OsuMenuItem("More...", MenuItemType.Standard, () => { }))
|
||||||
|
.ToArray()
|
||||||
|
});
|
||||||
|
|
||||||
return items.ToArray();
|
return items.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MenuItem createCollectionMenuItem(BeatmapCollection collection)
|
||||||
|
{
|
||||||
|
return new ToggleMenuItem(collection.Name, MenuItemType.Standard, s =>
|
||||||
|
{
|
||||||
|
if (s)
|
||||||
|
collection.Beatmaps.Add(beatmap);
|
||||||
|
else
|
||||||
|
collection.Beatmaps.Remove(beatmap);
|
||||||
|
})
|
||||||
|
{
|
||||||
|
State = { Value = collection.Beatmaps.Contains(beatmap) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
@ -16,6 +16,7 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
|
using osu.Game.Collections;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -34,6 +35,9 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private DialogOverlay dialogOverlay { get; set; }
|
private DialogOverlay dialogOverlay { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private CollectionManager collectionManager { get; set; }
|
||||||
|
|
||||||
private readonly BeatmapSetInfo beatmapSet;
|
private readonly BeatmapSetInfo beatmapSet;
|
||||||
|
|
||||||
public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
|
public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
|
||||||
@ -141,10 +145,54 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
if (dialogOverlay != null)
|
if (dialogOverlay != null)
|
||||||
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => dialogOverlay.Push(new BeatmapDeleteDialog(beatmapSet))));
|
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => dialogOverlay.Push(new BeatmapDeleteDialog(beatmapSet))));
|
||||||
|
|
||||||
|
items.Add(new OsuMenuItem("Add all to...")
|
||||||
|
{
|
||||||
|
Items = collectionManager.Collections.Take(3).Select(createCollectionMenuItem)
|
||||||
|
.Append(new OsuMenuItem("More...", MenuItemType.Standard, () => { }))
|
||||||
|
.ToArray()
|
||||||
|
});
|
||||||
|
|
||||||
return items.ToArray();
|
return items.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MenuItem createCollectionMenuItem(BeatmapCollection collection)
|
||||||
|
{
|
||||||
|
TernaryState state;
|
||||||
|
|
||||||
|
var countExisting = beatmapSet.Beatmaps.Count(b => collection.Beatmaps.Contains(b));
|
||||||
|
|
||||||
|
if (countExisting == beatmapSet.Beatmaps.Count)
|
||||||
|
state = TernaryState.True;
|
||||||
|
else if (countExisting > 0)
|
||||||
|
state = TernaryState.Indeterminate;
|
||||||
|
else
|
||||||
|
state = TernaryState.False;
|
||||||
|
|
||||||
|
return new TernaryStateMenuItem(collection.Name, MenuItemType.Standard, s =>
|
||||||
|
{
|
||||||
|
foreach (var b in beatmapSet.Beatmaps)
|
||||||
|
{
|
||||||
|
switch (s)
|
||||||
|
{
|
||||||
|
case TernaryState.True:
|
||||||
|
if (collection.Beatmaps.Contains(b))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
collection.Beatmaps.Add(b);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TernaryState.False:
|
||||||
|
collection.Beatmaps.Remove(b);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
{
|
||||||
|
State = { Value = state }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private class PanelBackground : BufferedContainer
|
private class PanelBackground : BufferedContainer
|
||||||
{
|
{
|
||||||
public PanelBackground(WorkingBeatmap working)
|
public PanelBackground(WorkingBeatmap working)
|
||||||
|
Loading…
Reference in New Issue
Block a user