1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:20:04 +08:00

Rename menu item

This commit is contained in:
smoogipoo 2020-09-11 16:02:46 +09:00
parent 5b80a7db5f
commit 4061480419
3 changed files with 21 additions and 21 deletions

View File

@ -231,7 +231,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.Click(MouseButton.Left);
});
private IEnumerable<Dropdown<CollectionMenuItem>.DropdownMenu.DrawableDropdownMenuItem> getCollectionDropdownItems()
=> control.ChildrenOfType<CollectionFilterDropdown>().Single().ChildrenOfType<Dropdown<CollectionMenuItem>.DropdownMenu.DrawableDropdownMenuItem>();
private IEnumerable<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem> getCollectionDropdownItems()
=> control.ChildrenOfType<CollectionFilterDropdown>().Single().ChildrenOfType<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem>();
}
}

View File

@ -20,13 +20,13 @@ using osuTK;
namespace osu.Game.Collections
{
/// <summary>
/// A dropdown to select the <see cref="CollectionMenuItem"/> to filter beatmaps using.
/// A dropdown to select the <see cref="CollectionFilterMenuItem"/> to filter beatmaps using.
/// </summary>
public class CollectionFilterDropdown : OsuDropdown<CollectionMenuItem>
public class CollectionFilterDropdown : OsuDropdown<CollectionFilterMenuItem>
{
private readonly IBindableList<BeatmapCollection> collections = new BindableList<BeatmapCollection>();
private readonly IBindableList<BeatmapInfo> beatmaps = new BindableList<BeatmapInfo>();
private readonly BindableList<CollectionMenuItem> filters = new BindableList<CollectionMenuItem>();
private readonly BindableList<CollectionFilterMenuItem> filters = new BindableList<CollectionFilterMenuItem>();
[Resolved(CanBeNull = true)]
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
@ -61,17 +61,17 @@ namespace osu.Game.Collections
var selectedItem = SelectedItem?.Value?.Collection;
filters.Clear();
filters.Add(new AllBeatmapsCollectionMenuItem());
filters.AddRange(collections.Select(c => new CollectionMenuItem(c)));
filters.Add(new ManageCollectionsMenuItem());
filters.Add(new AllBeatmapsCollectionFilterMenuItem());
filters.AddRange(collections.Select(c => new CollectionFilterMenuItem(c)));
filters.Add(new ManageCollectionsFilterMenuItem());
Current.Value = filters.SingleOrDefault(f => f.Collection != null && f.Collection == selectedItem) ?? filters[0];
}
/// <summary>
/// Occurs when the <see cref="CollectionMenuItem"/> selection has changed.
/// Occurs when the <see cref="CollectionFilterMenuItem"/> selection has changed.
/// </summary>
private void filterChanged(ValueChangedEvent<CollectionMenuItem> filter)
private void filterChanged(ValueChangedEvent<CollectionFilterMenuItem> 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.
beatmaps.CollectionChanged -= filterBeatmapsChanged;
@ -86,7 +86,7 @@ namespace osu.Game.Collections
// 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.
if (filter.NewValue is ManageCollectionsMenuItem)
if (filter.NewValue is ManageCollectionsFilterMenuItem)
{
Current.Value = filter.OldValue;
manageCollectionsDialog?.Show();
@ -103,7 +103,7 @@ namespace osu.Game.Collections
Current.TriggerChange();
}
protected override string GenerateItemText(CollectionMenuItem item) => item.CollectionName.Value;
protected override string GenerateItemText(CollectionFilterMenuItem item) => item.CollectionName.Value;
protected override DropdownHeader CreateHeader() => new CollectionDropdownHeader
{
@ -114,7 +114,7 @@ namespace osu.Game.Collections
public class CollectionDropdownHeader : OsuDropdownHeader
{
public readonly Bindable<CollectionMenuItem> SelectedItem = new Bindable<CollectionMenuItem>();
public readonly Bindable<CollectionFilterMenuItem> SelectedItem = new Bindable<CollectionFilterMenuItem>();
private readonly Bindable<string> collectionName = new Bindable<string>();
protected override string Label
@ -164,7 +164,7 @@ namespace osu.Game.Collections
protected class CollectionDropdownMenuItem : OsuDropdownMenu.DrawableOsuDropdownMenuItem
{
[NotNull]
protected new CollectionMenuItem Item => ((DropdownMenuItem<CollectionMenuItem>)base.Item).Value;
protected new CollectionFilterMenuItem Item => ((DropdownMenuItem<CollectionFilterMenuItem>)base.Item).Value;
[Resolved]
private OsuColour colours { get; set; }

View File

@ -9,7 +9,7 @@ namespace osu.Game.Collections
/// <summary>
/// A <see cref="BeatmapCollection"/> filter.
/// </summary>
public class CollectionMenuItem
public class CollectionFilterMenuItem
{
/// <summary>
/// The collection to filter beatmaps from.
@ -25,27 +25,27 @@ namespace osu.Game.Collections
public readonly Bindable<string> CollectionName;
/// <summary>
/// Creates a new <see cref="CollectionMenuItem"/>.
/// Creates a new <see cref="CollectionFilterMenuItem"/>.
/// </summary>
/// <param name="collection">The collection to filter beatmaps from.</param>
public CollectionMenuItem([CanBeNull] BeatmapCollection collection)
public CollectionFilterMenuItem([CanBeNull] BeatmapCollection collection)
{
Collection = collection;
CollectionName = Collection?.Name.GetBoundCopy() ?? new Bindable<string>("All beatmaps");
}
}
public class AllBeatmapsCollectionMenuItem : CollectionMenuItem
public class AllBeatmapsCollectionFilterMenuItem : CollectionFilterMenuItem
{
public AllBeatmapsCollectionMenuItem()
public AllBeatmapsCollectionFilterMenuItem()
: base(null)
{
}
}
public class ManageCollectionsMenuItem : CollectionMenuItem
public class ManageCollectionsFilterMenuItem : CollectionFilterMenuItem
{
public ManageCollectionsMenuItem()
public ManageCollectionsFilterMenuItem()
: base(null)
{
CollectionName.Value = "Manage collections...";