2022-07-07 22:59:27 +00:00
|
|
|
// 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.
|
|
|
|
|
2022-07-07 22:39:43 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2022-07-27 08:17:43 +00:00
|
|
|
using osu.Game.Database;
|
2022-07-07 22:39:43 +00:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
namespace osu.Game.Collections
|
|
|
|
{
|
|
|
|
public class CollectionToggleMenuItem : ToggleMenuItem
|
|
|
|
{
|
2022-07-27 08:17:43 +00:00
|
|
|
public CollectionToggleMenuItem(Live<BeatmapCollection> collection, IBeatmapInfo beatmap)
|
|
|
|
: base(collection.PerformRead(c => c.Name), MenuItemType.Standard, state =>
|
2022-07-07 22:39:43 +00:00
|
|
|
{
|
2022-07-27 08:17:43 +00:00
|
|
|
collection.PerformWrite(c =>
|
|
|
|
{
|
|
|
|
if (state)
|
|
|
|
c.BeatmapMD5Hashes.Add(beatmap.MD5Hash);
|
|
|
|
else
|
|
|
|
c.BeatmapMD5Hashes.Remove(beatmap.MD5Hash);
|
|
|
|
});
|
2022-07-07 22:39:43 +00:00
|
|
|
})
|
|
|
|
{
|
2022-07-27 08:17:43 +00:00
|
|
|
State.Value = collection.PerformRead(c => c.BeatmapMD5Hashes.Contains(beatmap.MD5Hash));
|
2022-07-07 22:39:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|