mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +08:00
Add notification and another menuitem
This commit is contained in:
parent
f1534da683
commit
46c4e78477
@ -13,6 +13,8 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -22,6 +24,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public string Link { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private INotificationOverlay notificationOverlay { get; set; }
|
||||
|
||||
private Color4 hoverColour;
|
||||
|
||||
[Resolved]
|
||||
@ -44,14 +49,26 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
private void copyUrl()
|
||||
{
|
||||
host.GetClipboard()?.SetText(Link);
|
||||
notificationOverlay.Post(new SimpleNotification
|
||||
{
|
||||
Text = "Copied URL!"
|
||||
});
|
||||
}
|
||||
|
||||
public MenuItem[] ContextMenuItems
|
||||
{
|
||||
get
|
||||
{
|
||||
List<MenuItem> items = new List<MenuItem>
|
||||
List<MenuItem> items = new List<MenuItem>();
|
||||
|
||||
if (Link != null)
|
||||
{
|
||||
new OsuMenuItem("Copy URL", MenuItemType.Standard, () => host.GetClipboard()?.SetText(Link))
|
||||
};
|
||||
items.Add(new OsuMenuItem("Open", MenuItemType.Standard, () => host.OpenUrlExternally(Link)));
|
||||
items.Add(new OsuMenuItem("Copy URL", MenuItemType.Standard, () => copyUrl()));
|
||||
}
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user