mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 23:53:51 +09:00
Rename to CollectionMenuItem
This commit is contained in:
@ -231,7 +231,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
private IEnumerable<Dropdown<CollectionFilter>.DropdownMenu.DrawableDropdownMenuItem> getCollectionDropdownItems()
|
private IEnumerable<Dropdown<CollectionMenuItem>.DropdownMenu.DrawableDropdownMenuItem> getCollectionDropdownItems()
|
||||||
=> control.ChildrenOfType<CollectionFilterDropdown>().Single().ChildrenOfType<Dropdown<CollectionFilter>.DropdownMenu.DrawableDropdownMenuItem>();
|
=> control.ChildrenOfType<CollectionFilterDropdown>().Single().ChildrenOfType<Dropdown<CollectionMenuItem>.DropdownMenu.DrawableDropdownMenuItem>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ using osuTK;
|
|||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dropdown to select the <see cref="CollectionFilter"/> to filter beatmaps using.
|
/// A dropdown to select the <see cref="CollectionMenuItem"/> to filter beatmaps using.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CollectionFilterDropdown : OsuDropdown<CollectionFilter>
|
public class CollectionFilterDropdown : OsuDropdown<CollectionMenuItem>
|
||||||
{
|
{
|
||||||
private readonly IBindableList<BeatmapCollection> collections = new BindableList<BeatmapCollection>();
|
private readonly IBindableList<BeatmapCollection> collections = new BindableList<BeatmapCollection>();
|
||||||
private readonly IBindableList<BeatmapInfo> beatmaps = new BindableList<BeatmapInfo>();
|
private readonly IBindableList<BeatmapInfo> beatmaps = new BindableList<BeatmapInfo>();
|
||||||
private readonly BindableList<CollectionFilter> filters = new BindableList<CollectionFilter>();
|
private readonly BindableList<CollectionMenuItem> filters = new BindableList<CollectionMenuItem>();
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
||||||
@ -62,17 +62,17 @@ namespace osu.Game.Screens.Select
|
|||||||
var selectedItem = SelectedItem?.Value?.Collection;
|
var selectedItem = SelectedItem?.Value?.Collection;
|
||||||
|
|
||||||
filters.Clear();
|
filters.Clear();
|
||||||
filters.Add(new AllBeatmapCollectionFilter());
|
filters.Add(new AllBeatmapsCollectionMenuItem());
|
||||||
filters.AddRange(collections.Select(c => new CollectionFilter(c)));
|
filters.AddRange(collections.Select(c => new CollectionMenuItem(c)));
|
||||||
filters.Add(new ManageCollectionsFilter());
|
filters.Add(new ManageCollectionsMenuItem());
|
||||||
|
|
||||||
Current.Value = filters.SingleOrDefault(f => f.Collection != null && f.Collection == selectedItem) ?? filters[0];
|
Current.Value = filters.SingleOrDefault(f => f.Collection != null && f.Collection == selectedItem) ?? filters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when the <see cref="CollectionFilter"/> selection has changed.
|
/// Occurs when the <see cref="CollectionMenuItem"/> selection has changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void filterChanged(ValueChangedEvent<CollectionFilter> filter)
|
private void filterChanged(ValueChangedEvent<CollectionMenuItem> filter)
|
||||||
{
|
{
|
||||||
// Binding the beatmaps will trigger a collection change event, which results in an infinite-loop. This is rebound later, when it's safe to do so.
|
// Binding the beatmaps will trigger a collection change event, which results in an infinite-loop. This is rebound later, when it's safe to do so.
|
||||||
beatmaps.CollectionChanged -= filterBeatmapsChanged;
|
beatmaps.CollectionChanged -= filterBeatmapsChanged;
|
||||||
@ -87,7 +87,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
// Never select the manage collection filter - rollback to the previous filter.
|
// Never select the manage collection filter - rollback to the previous filter.
|
||||||
// This is done after the above since it is important that bindable is unbound from OldValue, which is lost after forcing it back to the old value.
|
// This is done after the above since it is important that bindable is unbound from OldValue, which is lost after forcing it back to the old value.
|
||||||
if (filter.NewValue is ManageCollectionsFilter)
|
if (filter.NewValue is ManageCollectionsMenuItem)
|
||||||
{
|
{
|
||||||
Current.Value = filter.OldValue;
|
Current.Value = filter.OldValue;
|
||||||
manageCollectionsDialog?.Show();
|
manageCollectionsDialog?.Show();
|
||||||
@ -104,7 +104,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Current.TriggerChange();
|
Current.TriggerChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GenerateItemText(CollectionFilter item) => item.CollectionName.Value;
|
protected override string GenerateItemText(CollectionMenuItem item) => item.CollectionName.Value;
|
||||||
|
|
||||||
protected override DropdownHeader CreateHeader() => new CollectionDropdownHeader
|
protected override DropdownHeader CreateHeader() => new CollectionDropdownHeader
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public class CollectionDropdownHeader : OsuDropdownHeader
|
public class CollectionDropdownHeader : OsuDropdownHeader
|
||||||
{
|
{
|
||||||
public readonly Bindable<CollectionFilter> SelectedItem = new Bindable<CollectionFilter>();
|
public readonly Bindable<CollectionMenuItem> SelectedItem = new Bindable<CollectionMenuItem>();
|
||||||
private readonly Bindable<string> collectionName = new Bindable<string>();
|
private readonly Bindable<string> collectionName = new Bindable<string>();
|
||||||
|
|
||||||
protected override string Label
|
protected override string Label
|
||||||
@ -165,7 +165,7 @@ namespace osu.Game.Screens.Select
|
|||||||
private class CollectionDropdownMenuItem : OsuDropdownMenu.DrawableOsuDropdownMenuItem
|
private class CollectionDropdownMenuItem : OsuDropdownMenu.DrawableOsuDropdownMenuItem
|
||||||
{
|
{
|
||||||
[NotNull]
|
[NotNull]
|
||||||
protected new CollectionFilter Item => ((DropdownMenuItem<CollectionFilter>)base.Item).Value;
|
protected new CollectionMenuItem Item => ((DropdownMenuItem<CollectionMenuItem>)base.Item).Value;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Collections;
|
using osu.Game.Collections;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
@ -12,7 +10,7 @@ namespace osu.Game.Screens.Select
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="BeatmapCollection"/> filter.
|
/// A <see cref="BeatmapCollection"/> filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CollectionFilter
|
public class CollectionMenuItem
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The collection to filter beatmaps from.
|
/// The collection to filter beatmaps from.
|
||||||
@ -28,35 +26,27 @@ namespace osu.Game.Screens.Select
|
|||||||
public readonly Bindable<string> CollectionName;
|
public readonly Bindable<string> CollectionName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="CollectionFilter"/>.
|
/// Creates a new <see cref="CollectionMenuItem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="collection">The collection to filter beatmaps from.</param>
|
/// <param name="collection">The collection to filter beatmaps from.</param>
|
||||||
public CollectionFilter([CanBeNull] BeatmapCollection collection)
|
public CollectionMenuItem([CanBeNull] BeatmapCollection collection)
|
||||||
{
|
{
|
||||||
Collection = collection;
|
Collection = collection;
|
||||||
CollectionName = Collection?.Name.GetBoundCopy() ?? new Bindable<string>("All beatmaps");
|
CollectionName = Collection?.Name.GetBoundCopy() ?? new Bindable<string>("All beatmaps");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the collection contains a given beatmap.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="beatmap">The beatmap to check.</param>
|
|
||||||
/// <returns>Whether <see cref="Collection"/> contains <paramref name="beatmap"/>.</returns>
|
|
||||||
public virtual bool ContainsBeatmap(BeatmapInfo beatmap)
|
|
||||||
=> Collection?.Beatmaps.Any(b => b.Equals(beatmap)) ?? true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AllBeatmapCollectionFilter : CollectionFilter
|
public class AllBeatmapsCollectionMenuItem : CollectionMenuItem
|
||||||
{
|
{
|
||||||
public AllBeatmapCollectionFilter()
|
public AllBeatmapsCollectionMenuItem()
|
||||||
: base(null)
|
: base(null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ManageCollectionsFilter : CollectionFilter
|
public class ManageCollectionsMenuItem : CollectionMenuItem
|
||||||
{
|
{
|
||||||
public ManageCollectionsFilter()
|
public ManageCollectionsMenuItem()
|
||||||
: base(null)
|
: base(null)
|
||||||
{
|
{
|
||||||
CollectionName.Value = "Manage collections...";
|
CollectionName.Value = "Manage collections...";
|
Reference in New Issue
Block a user