mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Split collection toggle menu item to own class
This commit is contained in:
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)
|
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)
|
if (manageCollectionsDialog != null)
|
||||||
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
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)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
Reference in New Issue
Block a user