mirror of
https://github.com/osukey/osukey.git
synced 2025-05-21 21:47:31 +09:00
Merge pull request #19375 from novialriptide/contextmenu-external-beatmap
Add ContextMenu to beatmap external link
This commit is contained in:
commit
c30e8047ab
@ -3,11 +3,13 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
@ -16,7 +18,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class ExternalLinkButton : CompositeDrawable, IHasTooltip
|
public class ExternalLinkButton : CompositeDrawable, IHasTooltip, IHasContextMenu
|
||||||
{
|
{
|
||||||
public string Link { get; set; }
|
public string Link { get; set; }
|
||||||
|
|
||||||
@ -42,6 +44,22 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MenuItem[] ContextMenuItems
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<MenuItem> items = new List<MenuItem>();
|
||||||
|
|
||||||
|
if (Link != null)
|
||||||
|
{
|
||||||
|
items.Add(new OsuMenuItem("Open", MenuItemType.Standard, () => host.OpenUrlExternally(Link)));
|
||||||
|
items.Add(new OsuMenuItem("Copy URL", MenuItemType.Standard, () => host.GetClipboard()?.SetText(Link)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return items.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -90,113 +91,118 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new Container
|
new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding
|
Child = new Container
|
||||||
{
|
{
|
||||||
Vertical = BeatmapSetOverlay.Y_PADDING,
|
RelativeSizeAxes = Axes.X,
|
||||||
Left = BeatmapSetOverlay.X_PADDING,
|
AutoSizeAxes = Axes.Y,
|
||||||
Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH,
|
Padding = new MarginPadding
|
||||||
},
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
fadeContent = new FillFlowContainer
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
Vertical = BeatmapSetOverlay.Y_PADDING,
|
||||||
AutoSizeAxes = Axes.Y,
|
Left = BeatmapSetOverlay.X_PADDING,
|
||||||
Direction = FillDirection.Vertical,
|
Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH,
|
||||||
Children = new Drawable[]
|
},
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
fadeContent = new FillFlowContainer
|
||||||
{
|
{
|
||||||
new Container
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
new Container
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Child = Picker = new BeatmapPicker(),
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Margin = new MarginPadding { Top = 15 },
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
title = new OsuSpriteText
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = Picker = new BeatmapPicker(),
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Margin = new MarginPadding { Top = 15 },
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true)
|
title = new OsuSpriteText
|
||||||
},
|
{
|
||||||
externalLink = new ExternalLinkButton
|
Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true)
|
||||||
{
|
},
|
||||||
Anchor = Anchor.BottomLeft,
|
externalLink = new ExternalLinkButton
|
||||||
Origin = Anchor.BottomLeft,
|
{
|
||||||
Margin = new MarginPadding { Left = 5, Bottom = 4 }, // To better lineup with the font
|
Anchor = Anchor.BottomLeft,
|
||||||
},
|
Origin = Anchor.BottomLeft,
|
||||||
explicitContent = new ExplicitContentBeatmapBadge
|
Margin = new MarginPadding { Left = 5, Bottom = 4 }, // To better lineup with the font
|
||||||
{
|
},
|
||||||
Alpha = 0f,
|
explicitContent = new ExplicitContentBeatmapBadge
|
||||||
Anchor = Anchor.BottomLeft,
|
{
|
||||||
Origin = Anchor.BottomLeft,
|
Alpha = 0f,
|
||||||
Margin = new MarginPadding { Left = 10, Bottom = 4 },
|
Anchor = Anchor.BottomLeft,
|
||||||
},
|
Origin = Anchor.BottomLeft,
|
||||||
spotlight = new SpotlightBeatmapBadge
|
Margin = new MarginPadding { Left = 10, Bottom = 4 },
|
||||||
{
|
},
|
||||||
Alpha = 0f,
|
spotlight = new SpotlightBeatmapBadge
|
||||||
Anchor = Anchor.BottomLeft,
|
{
|
||||||
Origin = Anchor.BottomLeft,
|
Alpha = 0f,
|
||||||
Margin = new MarginPadding { Left = 10, Bottom = 4 },
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Margin = new MarginPadding { Left = 10, Bottom = 4 },
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
new FillFlowContainer
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Margin = new MarginPadding { Bottom = 20 },
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
artist = new OsuSpriteText
|
Direction = FillDirection.Horizontal,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Margin = new MarginPadding { Bottom = 20 },
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true),
|
artist = new OsuSpriteText
|
||||||
},
|
{
|
||||||
featuredArtist = new FeaturedArtistBeatmapBadge
|
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true),
|
||||||
{
|
},
|
||||||
Alpha = 0f,
|
featuredArtist = new FeaturedArtistBeatmapBadge
|
||||||
Anchor = Anchor.BottomLeft,
|
{
|
||||||
Origin = Anchor.BottomLeft,
|
Alpha = 0f,
|
||||||
Margin = new MarginPadding { Left = 10 }
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Margin = new MarginPadding { Left = 10 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
new Container
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Child = author = new AuthorInfo(),
|
|
||||||
},
|
|
||||||
beatmapAvailability = new BeatmapAvailability(),
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = buttons_height,
|
|
||||||
Margin = new MarginPadding { Top = 10 },
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
favouriteButton = new FavouriteButton
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = author = new AuthorInfo(),
|
||||||
|
},
|
||||||
|
beatmapAvailability = new BeatmapAvailability(),
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = buttons_height,
|
||||||
|
Margin = new MarginPadding { Top = 10 },
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
BeatmapSet = { BindTarget = BeatmapSet }
|
favouriteButton = new FavouriteButton
|
||||||
},
|
{
|
||||||
downloadButtonsContainer = new FillFlowContainer
|
BeatmapSet = { BindTarget = BeatmapSet }
|
||||||
{
|
},
|
||||||
RelativeSizeAxes = Axes.Both,
|
downloadButtonsContainer = new FillFlowContainer
|
||||||
Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
|
{
|
||||||
Spacing = new Vector2(buttons_spacing),
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
|
||||||
|
Spacing = new Vector2(buttons_spacing),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
loading = new LoadingSpinner
|
loading = new LoadingSpinner
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user