mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 11:25:37 +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;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -31,11 +35,17 @@ using Container = osu.Framework.Graphics.Containers.Container;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
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;
|
protected const float CORNER_RADIUS = 10;
|
||||||
private const float height = 100;
|
private const float height = 100;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuGame? game { get; set; } = null!;
|
||||||
|
|
||||||
public readonly Room Room;
|
public readonly Room Room;
|
||||||
|
|
||||||
protected readonly Bindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();
|
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 UpdateableBeatmapBackgroundSprite CreateBackground() => new UpdateableBeatmapBackgroundSprite();
|
||||||
|
|
||||||
protected virtual IEnumerable<Drawable> CreateBottomDetails()
|
protected virtual IEnumerable<Drawable> CreateBottomDetails()
|
||||||
|
@ -59,6 +59,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; } = null!;
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuGame? game { get; set; } = null!;
|
||||||
|
|
||||||
private readonly BindableWithCurrent<Room?> selectedRoom = new BindableWithCurrent<Room?>();
|
private readonly BindableWithCurrent<Room?> selectedRoom = new BindableWithCurrent<Room?>();
|
||||||
private Sample? sampleSelect;
|
private Sample? sampleSelect;
|
||||||
private Sample? sampleJoin;
|
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)
|
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, () =>
|
items.Add(new OsuMenuItem("Close playlist", MenuItemType.Destructive, () =>
|
||||||
@ -234,6 +248,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
Room.PropertyChanged -= onRoomPropertyChanged;
|
Room.PropertyChanged -= onRoomPropertyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string formatRoomUrl(long id) => $@"{api.WebsiteRootUrl}/multiplayer/rooms/{id}";
|
||||||
|
|
||||||
public partial class PasswordEntryPopover : OsuPopover
|
public partial class PasswordEntryPopover : OsuPopover
|
||||||
{
|
{
|
||||||
private readonly Room room;
|
private readonly Room room;
|
||||||
|
@ -18,6 +18,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -156,10 +157,15 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
new DrawableMatchRoom(Room, allowEdit)
|
new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
OnEdit = () => settingsOverlay.Show(),
|
RelativeSizeAxes = Axes.X,
|
||||||
SelectedItem = SelectedItem
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = new DrawableMatchRoom(Room, allowEdit)
|
||||||
|
{
|
||||||
|
OnEdit = () => settingsOverlay.Show(),
|
||||||
|
SelectedItem = SelectedItem
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
|
Loading…
Reference in New Issue
Block a user