mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Merge pull request #24022 from frenzibyte/fix-open-user-profile-argument
Fix `OpenUserProfile` links having multiple argument types
This commit is contained in:
commit
55ab27c5b6
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Online.Chat
|
||||
{
|
||||
@ -172,7 +173,7 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
case "u":
|
||||
case "users":
|
||||
return new LinkDetails(LinkAction.OpenUserProfile, mainArg);
|
||||
return getUserLink(mainArg);
|
||||
|
||||
case "wiki":
|
||||
return new LinkDetails(LinkAction.OpenWiki, string.Join('/', args.Skip(3)));
|
||||
@ -230,8 +231,7 @@ namespace osu.Game.Online.Chat
|
||||
break;
|
||||
|
||||
case "u":
|
||||
linkType = LinkAction.OpenUserProfile;
|
||||
break;
|
||||
return getUserLink(args[2]);
|
||||
|
||||
default:
|
||||
return new LinkDetails(LinkAction.External, url);
|
||||
@ -246,6 +246,14 @@ namespace osu.Game.Online.Chat
|
||||
return new LinkDetails(LinkAction.External, url);
|
||||
}
|
||||
|
||||
private static LinkDetails getUserLink(string argument)
|
||||
{
|
||||
if (int.TryParse(argument, out int userId))
|
||||
return new LinkDetails(LinkAction.OpenUserProfile, new APIUser { Id = userId });
|
||||
|
||||
return new LinkDetails(LinkAction.OpenUserProfile, new APIUser { Username = argument });
|
||||
}
|
||||
|
||||
private static MessageFormatterResult format(string toFormat, int startIndex = 0, int space = 3)
|
||||
{
|
||||
var result = new MessageFormatterResult(toFormat);
|
||||
|
@ -45,7 +45,6 @@ using osu.Game.Input.Bindings;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.BeatmapListing;
|
||||
@ -446,15 +445,7 @@ namespace osu.Game
|
||||
break;
|
||||
|
||||
case LinkAction.OpenUserProfile:
|
||||
if (!(link.Argument is IUser user))
|
||||
{
|
||||
user = int.TryParse(argString, out int userId)
|
||||
? new APIUser { Id = userId }
|
||||
: new APIUser { Username = argString };
|
||||
}
|
||||
|
||||
ShowUser(user);
|
||||
|
||||
ShowUser((IUser)link.Argument);
|
||||
break;
|
||||
|
||||
case LinkAction.OpenWiki:
|
||||
|
@ -223,7 +223,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
private void addBeatmapsetLink()
|
||||
=> content.AddLink(activity.Beatmapset.AsNonNull().Title, LinkAction.OpenBeatmapSet, getLinkArgument(activity.Beatmapset.AsNonNull().Url), creationParameters: t => t.Font = getLinkFont());
|
||||
|
||||
private string getLinkArgument(string url) => MessageFormatter.GetLinkDetails($"{api.WebsiteRootUrl}{url}").Argument.ToString().AsNonNull();
|
||||
private object getLinkArgument(string url) => MessageFormatter.GetLinkDetails($"{api.WebsiteRootUrl}{url}").Argument.AsNonNull();
|
||||
|
||||
private FontUsage getLinkFont(FontWeight fontWeight = FontWeight.Regular)
|
||||
=> OsuFont.GetFont(size: font_size, weight: fontWeight, italics: true);
|
||||
|
Loading…
Reference in New Issue
Block a user