mirror of
https://github.com/ppy/osu
synced 2025-02-17 10:57:03 +00:00
Split collection toggle menu item to own class
This commit is contained in:
parent
b9acdcdbe2
commit
a94fb62be3
20
osu.Game/Collections/CollectionToggleMenuItem.cs
Normal file
20
osu.Game/Collections/CollectionToggleMenuItem.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Collections
|
||||
{
|
||||
public class CollectionToggleMenuItem : ToggleMenuItem
|
||||
{
|
||||
public CollectionToggleMenuItem(BeatmapCollection collection, IBeatmapInfo beatmap)
|
||||
: base(collection.Name.Value, MenuItemType.Standard, s =>
|
||||
{
|
||||
if (s)
|
||||
collection.BeatmapHashes.Add(beatmap.MD5Hash);
|
||||
else
|
||||
collection.BeatmapHashes.Remove(beatmap.MD5Hash);
|
||||
})
|
||||
{
|
||||
State.Value = collection.BeatmapHashes.Contains(beatmap.MD5Hash);
|
||||
}
|
||||
}
|
||||
}
|
@ -244,7 +244,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
if (collectionManager != null)
|
||||
{
|
||||
var collectionItems = collectionManager.Collections.Select(createCollectionMenuItem).ToList();
|
||||
var collectionItems = collectionManager.Collections.Select(c => new CollectionToggleMenuItem(c, beatmapInfo)).Cast<OsuMenuItem>().ToList();
|
||||
if (manageCollectionsDialog != null)
|
||||
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
||||
|
||||
@ -258,20 +258,6 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItem createCollectionMenuItem(BeatmapCollection collection)
|
||||
{
|
||||
return new ToggleMenuItem(collection.Name.Value, MenuItemType.Standard, s =>
|
||||
{
|
||||
if (s)
|
||||
collection.BeatmapHashes.Add(beatmapInfo.MD5Hash);
|
||||
else
|
||||
collection.BeatmapHashes.Remove(beatmapInfo.MD5Hash);
|
||||
})
|
||||
{
|
||||
State = { Value = collection.BeatmapHashes.Contains(beatmapInfo.MD5Hash) }
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
Loading…
Reference in New Issue
Block a user