1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-20 15:20:18 +08:00

Move room URL formatting to extension method

This commit is contained in:
Salman Alshamrani
2025-06-26 02:56:43 +03:00
Unverified
parent d888572f7f
commit 75a3cdcfe2
2 changed files with 26 additions and 5 deletions
+21
View File
@@ -0,0 +1,21 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Online.API;
namespace osu.Game.Online.Rooms
{
public static class RoomExtensions
{
/// <summary>
/// Get the room page URL, or <c>null</c> if unavailable.
/// </summary>
public static string? GetOnlineURL(this Room room, IAPIProvider api)
{
if (!room.RoomID.HasValue)
return null;
return $@"{api.Endpoints.WebsiteUrl}/multiplayer/rooms/{room.RoomID.Value}";
}
}
}
@@ -380,11 +380,13 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
var items = new List<MenuItem>();
if (Room.RoomID.HasValue)
string? url = Room.GetOnlineURL(api);
if (url != null)
{
items.AddRange([
new OsuMenuItem("View in browser", MenuItemType.Standard, () => game?.OpenUrlExternally(getRoomUrl())),
new OsuMenuItem("Copy link", MenuItemType.Standard, () => game?.CopyToClipboard(getRoomUrl()))
new OsuMenuItem("View in browser", MenuItemType.Standard, () => game?.OpenUrlExternally(url)),
new OsuMenuItem("Copy link", MenuItemType.Standard, () => game?.CopyToClipboard(url))
]);
}
@@ -392,8 +394,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
}
}
private string? getRoomUrl() => !Room.RoomID.HasValue ? null : $@"{api.Endpoints.WebsiteUrl}/multiplayer/rooms/{Room.RoomID.Value}";
protected virtual UpdateableBeatmapBackgroundSprite CreateBackground() => new UpdateableBeatmapBackgroundSprite();
protected virtual IEnumerable<Drawable> CreateBottomDetails()