mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 01:22:54 +08:00
Add context menu to open in browser to rooms
This commit is contained in:
parent
e753e3ee2f
commit
2a5a2738e1
@ -12,15 +12,19 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Overlays;
|
||||
@ -31,11 +35,17 @@ using Container = osu.Framework.Graphics.Containers.Container;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public abstract partial class DrawableRoom : CompositeDrawable
|
||||
public abstract partial class DrawableRoom : CompositeDrawable, IHasContextMenu
|
||||
{
|
||||
protected const float CORNER_RADIUS = 10;
|
||||
private const float height = 100;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OsuGame? game { get; set; } = null!;
|
||||
|
||||
public readonly Room Room;
|
||||
|
||||
protected readonly Bindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
|
||||
@ -330,6 +340,29 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
}
|
||||
}
|
||||
|
||||
public MenuItem[] ContextMenuItems
|
||||
{
|
||||
get
|
||||
{
|
||||
var items = new List<MenuItem>();
|
||||
|
||||
if (Room.RoomID.HasValue)
|
||||
{
|
||||
items.AddRange([new OsuMenuItem("View in browser", MenuItemType.Standard, () =>
|
||||
{
|
||||
game?.OpenUrlExternally(formatRoomUrl(Room.RoomID.Value));
|
||||
}), new OsuMenuItem("Copy link", MenuItemType.Standard, () =>
|
||||
{
|
||||
game?.CopyUrlToClipboard(formatRoomUrl(Room.RoomID.Value));
|
||||
})]);
|
||||
}
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private string formatRoomUrl(long id) => $@"{api.WebsiteRootUrl}/multiplayer/rooms/{id}";
|
||||
|
||||
protected virtual UpdateableBeatmapBackgroundSprite CreateBackground() => new UpdateableBeatmapBackgroundSprite();
|
||||
|
||||
protected virtual IEnumerable<Drawable> CreateBottomDetails()
|
||||
|
@ -59,6 +59,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OsuGame? game { get; set; } = null!;
|
||||
|
||||
private readonly BindableWithCurrent<Room?> selectedRoom = new BindableWithCurrent<Room?>();
|
||||
private Sample? sampleSelect;
|
||||
private Sample? sampleJoin;
|
||||
@ -167,6 +170,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
})
|
||||
};
|
||||
|
||||
if (Room.RoomID.HasValue)
|
||||
{
|
||||
items.AddRange([new OsuMenuItem("View in browser", MenuItemType.Standard, () =>
|
||||
{
|
||||
game?.OpenUrlExternally(formatRoomUrl(Room.RoomID.Value));
|
||||
}), new OsuMenuItem("Copy link", MenuItemType.Standard, () =>
|
||||
{
|
||||
game?.CopyUrlToClipboard(formatRoomUrl(Room.RoomID.Value));
|
||||
})]);
|
||||
}
|
||||
|
||||
if (Room.Type == MatchType.Playlists && Room.Host?.Id == api.LocalUser.Value.Id && Room.StartDate?.AddMinutes(5) >= DateTimeOffset.Now && !Room.HasEnded)
|
||||
{
|
||||
items.Add(new OsuMenuItem("Close playlist", MenuItemType.Destructive, () =>
|
||||
@ -234,6 +248,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
Room.PropertyChanged -= onRoomPropertyChanged;
|
||||
}
|
||||
|
||||
private string formatRoomUrl(long id) => $@"{api.WebsiteRootUrl}/multiplayer/rooms/{id}";
|
||||
|
||||
public partial class PasswordEntryPopover : OsuPopover
|
||||
{
|
||||
private readonly Room room;
|
||||
|
@ -18,6 +18,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Overlays;
|
||||
@ -156,10 +157,15 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new DrawableMatchRoom(Room, allowEdit)
|
||||
new OsuContextMenuContainer
|
||||
{
|
||||
OnEdit = () => settingsOverlay.Show(),
|
||||
SelectedItem = SelectedItem
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = new DrawableMatchRoom(Room, allowEdit)
|
||||
{
|
||||
OnEdit = () => settingsOverlay.Show(),
|
||||
SelectedItem = SelectedItem
|
||||
}
|
||||
}
|
||||
},
|
||||
null,
|
||||
|
Loading…
Reference in New Issue
Block a user