mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Tidy up naming of collection dropdowns
This commit is contained in:
@ -149,7 +149,7 @@ namespace osu.Game.Tests.Visual.Collections
|
|||||||
{
|
{
|
||||||
AddStep("add dropdown", () =>
|
AddStep("add dropdown", () =>
|
||||||
{
|
{
|
||||||
Add(new CollectionFilterDropdown
|
Add(new CollectionDropdown
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
|
@ -74,14 +74,14 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
AddStep("set filter again", () => songSelect.ChildrenOfType<SearchTextBox>().Single().Current.Value = "test");
|
AddStep("set filter again", () => songSelect.ChildrenOfType<SearchTextBox>().Single().Current.Value = "test");
|
||||||
AddStep("open collections dropdown", () =>
|
AddStep("open collections dropdown", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(songSelect.ChildrenOfType<CollectionFilterDropdown>().Single());
|
InputManager.MoveMouseTo(songSelect.ChildrenOfType<CollectionDropdown>().Single());
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("press back once", () => InputManager.Click(MouseButton.Button1));
|
AddStep("press back once", () => InputManager.Click(MouseButton.Button1));
|
||||||
AddAssert("still at song select", () => Game.ScreenStack.CurrentScreen == songSelect);
|
AddAssert("still at song select", () => Game.ScreenStack.CurrentScreen == songSelect);
|
||||||
AddAssert("collections dropdown closed", () => songSelect
|
AddAssert("collections dropdown closed", () => songSelect
|
||||||
.ChildrenOfType<CollectionFilterDropdown>().Single()
|
.ChildrenOfType<CollectionDropdown>().Single()
|
||||||
.ChildrenOfType<Dropdown<CollectionFilterMenuItem>.DropdownMenu>().Single().State == MenuState.Closed);
|
.ChildrenOfType<Dropdown<CollectionFilterMenuItem>.DropdownMenu>().Single().State == MenuState.Closed);
|
||||||
|
|
||||||
AddStep("press back a second time", () => InputManager.Click(MouseButton.Button1));
|
AddStep("press back a second time", () => InputManager.Click(MouseButton.Button1));
|
||||||
|
@ -94,7 +94,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("add collection", () => Realm.Write(r => r.Add(new BeatmapCollection(name: "1"))));
|
AddStep("add collection", () => Realm.Write(r => r.Add(new BeatmapCollection(name: "1"))));
|
||||||
AddStep("select collection", () =>
|
AddStep("select collection", () =>
|
||||||
{
|
{
|
||||||
var dropdown = control.ChildrenOfType<CollectionFilterDropdown>().Single();
|
var dropdown = control.ChildrenOfType<CollectionDropdown>().Single();
|
||||||
dropdown.Current.Value = dropdown.ItemSource.ElementAt(1);
|
dropdown.Current.Value = dropdown.ItemSource.ElementAt(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
private void assertCollectionHeaderDisplays(string collectionName, bool shouldDisplay = true)
|
private void assertCollectionHeaderDisplays(string collectionName, bool shouldDisplay = true)
|
||||||
=> AddAssert($"collection dropdown header displays '{collectionName}'",
|
=> AddAssert($"collection dropdown header displays '{collectionName}'",
|
||||||
() => shouldDisplay == (control.ChildrenOfType<CollectionFilterDropdown.CollectionDropdownHeader>().Single().ChildrenOfType<SpriteText>().First().Text == collectionName));
|
() => shouldDisplay == (control.ChildrenOfType<CollectionDropdown.CollectionDropdownHeader>().Single().ChildrenOfType<SpriteText>().First().Text == collectionName));
|
||||||
|
|
||||||
private void assertCollectionDropdownContains(string collectionName, bool shouldContain = true) =>
|
private void assertCollectionDropdownContains(string collectionName, bool shouldContain = true) =>
|
||||||
AddAssert($"collection dropdown {(shouldContain ? "contains" : "does not contain")} '{collectionName}'",
|
AddAssert($"collection dropdown {(shouldContain ? "contains" : "does not contain")} '{collectionName}'",
|
||||||
@ -222,7 +222,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
private void addExpandHeaderStep() => AddStep("expand header", () =>
|
private void addExpandHeaderStep() => AddStep("expand header", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(control.ChildrenOfType<CollectionFilterDropdown.CollectionDropdownHeader>().Single());
|
InputManager.MoveMouseTo(control.ChildrenOfType<CollectionDropdown.CollectionDropdownHeader>().Single());
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -233,6 +233,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
|
|
||||||
private IEnumerable<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem> getCollectionDropdownItems()
|
private IEnumerable<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem> getCollectionDropdownItems()
|
||||||
=> control.ChildrenOfType<CollectionFilterDropdown>().Single().ChildrenOfType<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem>();
|
=> control.ChildrenOfType<CollectionDropdown>().Single().ChildrenOfType<Dropdown<CollectionFilterMenuItem>.DropdownMenu.DrawableDropdownMenuItem>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ using Realms;
|
|||||||
namespace osu.Game.Collections
|
namespace osu.Game.Collections
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dropdown to select the <see cref="CollectionFilterMenuItem"/> to filter beatmaps using.
|
/// A dropdown to select the collection to be used to filter results.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CollectionFilterDropdown : OsuDropdown<CollectionFilterMenuItem>
|
public class CollectionDropdown : OsuDropdown<CollectionFilterMenuItem>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show the "manage collections..." menu item in the dropdown.
|
/// Whether to show the "manage collections..." menu item in the dropdown.
|
||||||
@ -40,7 +40,9 @@ namespace osu.Game.Collections
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private RealmAccess realm { get; set; } = null!;
|
private RealmAccess realm { get; set; } = null!;
|
||||||
|
|
||||||
public CollectionFilterDropdown()
|
private IDisposable? realmSubscription;
|
||||||
|
|
||||||
|
public CollectionDropdown()
|
||||||
{
|
{
|
||||||
ItemSource = filters;
|
ItemSource = filters;
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ namespace osu.Game.Collections
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
realm.RegisterForNotifications(r => r.All<BeatmapCollection>(), collectionsChanged);
|
realmSubscription = realm.RegisterForNotifications(r => r.All<BeatmapCollection>(), collectionsChanged);
|
||||||
|
|
||||||
Current.BindValueChanged(selectionChanged);
|
Current.BindValueChanged(selectionChanged);
|
||||||
}
|
}
|
||||||
@ -114,6 +116,12 @@ namespace osu.Game.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
realmSubscription?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
protected override LocalisableString GenerateItemText(CollectionFilterMenuItem item) => item.CollectionName;
|
protected override LocalisableString GenerateItemText(CollectionFilterMenuItem item) => item.CollectionName;
|
||||||
|
|
||||||
protected sealed override DropdownHeader CreateHeader() => CreateCollectionHeader();
|
protected sealed override DropdownHeader CreateHeader() => CreateCollectionHeader();
|
||||||
@ -150,18 +158,19 @@ namespace osu.Game.Collections
|
|||||||
|
|
||||||
protected class CollectionDropdownDrawableMenuItem : OsuDropdownMenu.DrawableOsuDropdownMenuItem
|
protected class CollectionDropdownDrawableMenuItem : OsuDropdownMenu.DrawableOsuDropdownMenuItem
|
||||||
{
|
{
|
||||||
protected new CollectionFilterMenuItem Item => ((DropdownMenuItem<CollectionFilterMenuItem>)base.Item).Value;
|
|
||||||
|
|
||||||
private IconButton addOrRemoveButton = null!;
|
private IconButton addOrRemoveButton = null!;
|
||||||
|
|
||||||
private bool beatmapInCollection;
|
private bool beatmapInCollection;
|
||||||
|
|
||||||
|
private readonly Live<BeatmapCollection>? collection;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
||||||
|
|
||||||
public CollectionDropdownDrawableMenuItem(MenuItem item)
|
public CollectionDropdownDrawableMenuItem(MenuItem item)
|
||||||
: base(item)
|
: base(item)
|
||||||
{
|
{
|
||||||
|
collection = ((DropdownMenuItem<CollectionFilterMenuItem>)item).Value.Collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -181,13 +190,11 @@ namespace osu.Game.Collections
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
if (Item.Collection != null)
|
if (collection != null)
|
||||||
{
|
{
|
||||||
beatmap.BindValueChanged(_ =>
|
beatmap.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
Debug.Assert(Item.Collection != null);
|
beatmapInCollection = collection.PerformRead(c => c.BeatmapMD5Hashes.Contains(beatmap.Value.BeatmapInfo.MD5Hash));
|
||||||
|
|
||||||
beatmapInCollection = Item.Collection.PerformRead(c => c.BeatmapMD5Hashes.Contains(beatmap.Value.BeatmapInfo.MD5Hash));
|
|
||||||
|
|
||||||
addOrRemoveButton.Enabled.Value = !beatmap.IsDefault;
|
addOrRemoveButton.Enabled.Value = !beatmap.IsDefault;
|
||||||
addOrRemoveButton.Icon = beatmapInCollection ? FontAwesome.Solid.MinusSquare : FontAwesome.Solid.PlusSquare;
|
addOrRemoveButton.Icon = beatmapInCollection ? FontAwesome.Solid.MinusSquare : FontAwesome.Solid.PlusSquare;
|
||||||
@ -220,7 +227,7 @@ namespace osu.Game.Collections
|
|||||||
|
|
||||||
private void updateButtonVisibility()
|
private void updateButtonVisibility()
|
||||||
{
|
{
|
||||||
if (Item.Collection == null)
|
if (collection == null)
|
||||||
addOrRemoveButton.Alpha = 0;
|
addOrRemoveButton.Alpha = 0;
|
||||||
else
|
else
|
||||||
addOrRemoveButton.Alpha = IsHovered || IsPreSelected || beatmapInCollection ? 1 : 0;
|
addOrRemoveButton.Alpha = IsHovered || IsPreSelected || beatmapInCollection ? 1 : 0;
|
||||||
@ -228,9 +235,9 @@ namespace osu.Game.Collections
|
|||||||
|
|
||||||
private void addOrRemove()
|
private void addOrRemove()
|
||||||
{
|
{
|
||||||
Debug.Assert(Item.Collection != null);
|
Debug.Assert(collection != null);
|
||||||
|
|
||||||
Item.Collection.PerformWrite(c =>
|
collection.PerformWrite(c =>
|
||||||
{
|
{
|
||||||
if (!c.BeatmapMD5Hashes.Remove(beatmap.Value.BeatmapInfo.MD5Hash))
|
if (!c.BeatmapMD5Hashes.Remove(beatmap.Value.BeatmapInfo.MD5Hash))
|
||||||
c.BeatmapMD5Hashes.Add(beatmap.Value.BeatmapInfo.MD5Hash);
|
c.BeatmapMD5Hashes.Add(beatmap.Value.BeatmapInfo.MD5Hash);
|
@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
public Action<FilterCriteria> FilterChanged;
|
public Action<FilterCriteria> FilterChanged;
|
||||||
|
|
||||||
public readonly FilterTextBox Search;
|
public readonly FilterTextBox Search;
|
||||||
private readonly CollectionDropdown collectionDropdown;
|
private readonly NowPlayingCollectionDropdown collectionDropdown;
|
||||||
|
|
||||||
public FilterControl()
|
public FilterControl()
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 40,
|
Height = 40,
|
||||||
},
|
},
|
||||||
collectionDropdown = new CollectionDropdown { RelativeSizeAxes = Axes.X }
|
collectionDropdown = new NowPlayingCollectionDropdown { RelativeSizeAxes = Axes.X }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -15,9 +15,9 @@ using osu.Game.Graphics;
|
|||||||
namespace osu.Game.Overlays.Music
|
namespace osu.Game.Overlays.Music
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="CollectionFilterDropdown"/> for use in the <see cref="NowPlayingOverlay"/>.
|
/// A <see cref="CollectionDropdown"/> for use in the <see cref="NowPlayingOverlay"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CollectionDropdown : CollectionFilterDropdown
|
public class NowPlayingCollectionDropdown : CollectionDropdown
|
||||||
{
|
{
|
||||||
protected override bool ShowManageCollectionsItem => false;
|
protected override bool ShowManageCollectionsItem => false;
|
||||||
|
|
@ -41,7 +41,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private SeekLimitedSearchTextBox searchTextBox;
|
private SeekLimitedSearchTextBox searchTextBox;
|
||||||
|
|
||||||
private CollectionFilterDropdown collectionDropdown;
|
private CollectionDropdown collectionDropdown;
|
||||||
|
|
||||||
public FilterCriteria CreateCriteria()
|
public FilterCriteria CreateCriteria()
|
||||||
{
|
{
|
||||||
@ -179,7 +179,7 @@ namespace osu.Game.Screens.Select
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Width = 0.48f,
|
Width = 0.48f,
|
||||||
},
|
},
|
||||||
collectionDropdown = new CollectionFilterDropdown
|
collectionDropdown = new CollectionDropdown
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
|
Reference in New Issue
Block a user