diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomLinkButton.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomLinkButton.cs new file mode 100644 index 000000000000..43e9513b64bf --- /dev/null +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomLinkButton.cs @@ -0,0 +1,27 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Game.Graphics.Cursor; +using osu.Game.Screens.OnlinePlay.Lounge.Components; +using osuTK; + +namespace osu.Game.Tests.Visual.Multiplayer +{ + public partial class TestSceneRoomLinkButton : OsuTestScene + { + public TestSceneRoomLinkButton() + { + Child = new OsuContextMenuContainer + { + RelativeSizeAxes = Axes.Both, + Child = new RoomLinkButton(1) + { + Size = new Vector2(50), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + } + }; + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/DrawableRoom.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/DrawableRoom.cs index c39ca347c79c..15f5136129dc 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/Components/DrawableRoom.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/DrawableRoom.cs @@ -20,6 +20,7 @@ using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; using osu.Game.Online.Rooms; @@ -94,7 +95,7 @@ private void load(OverlayColourProvider colours) d.RelativeSizeAxes = Axes.Both; }), wrapper = new DelayedLoadWrapper(() => - new Container + new OsuContextMenuContainer { Name = @"Room content", RelativeSizeAxes = Axes.Both, @@ -184,10 +185,39 @@ private void load(OverlayColourProvider colours) Direction = FillDirection.Vertical, Children = new Drawable[] { - roomName = new TruncatingSpriteText + new GridContainer { RelativeSizeAxes = Axes.X, - Font = OsuFont.GetFont(size: 28) + AutoSizeAxes = Axes.Y, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), + }, + RowDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize) + }, + Content = new[] + { + new Drawable[] + { + roomName = new TruncatingSpriteText + { + Font = OsuFont.GetFont(size: 28), + }, + new RoomLinkButton(Room.RoomID) + { + Margin = new MarginPadding + { + Left = 3, + }, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Size = new Vector2(12) + } + }, + } }, new RoomStatusText(Room) { diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomLinkButton.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomLinkButton.cs new file mode 100644 index 000000000000..7c1c2e1d7252 --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomLinkButton.cs @@ -0,0 +1,34 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; + +namespace osu.Game.Screens.OnlinePlay.Lounge.Components +{ + public partial class RoomLinkButton : ExternalLinkButton + { + [Resolved] + private IAPIProvider api { get; set; } = null!; + + private readonly long? roomID; + + public RoomLinkButton(long? roomID) + { + this.roomID = roomID; + } + + [BackgroundDependencyLoader] + private void load() + { + if (roomID.HasValue) + Link = formatLink(roomID.Value); + } + + private string formatLink(long id) + { + return $@"{api.WebsiteRootUrl}/multiplayer/rooms/{id}"; + } + } +}