Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button in playlists/multiplayer to access the osu-web page #31006

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions osu.Game.Tests/Visual/Multiplayer/TestSceneRoomLinkButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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,
}
};
}
}
}
36 changes: 33 additions & 3 deletions osu.Game/Screens/OnlinePlay/Lounge/Components/DrawableRoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down
34 changes: 34 additions & 0 deletions osu.Game/Screens/OnlinePlay/Lounge/Components/RoomLinkButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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}";
}
}
}
Loading