2024-07-20 18:49:46 +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.
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Collections;
|
|
|
|
|
using osu.Game.Database;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Ranking
|
|
|
|
|
{
|
|
|
|
|
public partial class CollectionPopover : OsuPopover
|
|
|
|
|
{
|
|
|
|
|
private readonly BeatmapInfo beatmapInfo;
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private RealmAccess realm { get; set; } = null!;
|
2024-07-22 00:32:48 +00:00
|
|
|
|
|
2024-07-20 18:49:46 +00:00
|
|
|
|
[Resolved]
|
2024-07-22 00:51:30 +00:00
|
|
|
|
private ManageCollectionsDialog? manageCollectionsDialog { get; set; }
|
2024-07-20 18:49:46 +00:00
|
|
|
|
|
2024-07-22 00:32:48 +00:00
|
|
|
|
public CollectionPopover(BeatmapInfo beatmapInfo)
|
|
|
|
|
: base(false)
|
2024-07-20 18:49:46 +00:00
|
|
|
|
{
|
|
|
|
|
this.beatmapInfo = beatmapInfo;
|
2024-07-28 00:26:31 +00:00
|
|
|
|
|
|
|
|
|
Body.CornerRadius = 4;
|
2024-07-20 18:49:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2024-07-22 00:32:48 +00:00
|
|
|
|
new OsuMenu(Direction.Vertical, true)
|
2024-07-20 18:49:46 +00:00
|
|
|
|
{
|
|
|
|
|
Items = items,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnFocusLost(FocusLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnFocusLost(e);
|
|
|
|
|
Hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private OsuMenuItem[] items
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var collectionItems = realm.Realm.All<BeatmapCollection>()
|
2024-07-22 00:32:48 +00:00
|
|
|
|
.OrderBy(c => c.Name)
|
|
|
|
|
.AsEnumerable()
|
|
|
|
|
.Select(c => new CollectionToggleMenuItem(c.ToLive(realm), beatmapInfo)).Cast<OsuMenuItem>().ToList();
|
2024-07-20 18:49:46 +00:00
|
|
|
|
|
2024-08-15 18:49:15 +00:00
|
|
|
|
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, () => manageCollectionsDialog?.Show()));
|
2024-07-20 18:49:46 +00:00
|
|
|
|
|
|
|
|
|
return collectionItems.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|