1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 04:53:12 +08:00

Merge branch 'master' into ui-login-spacing-fix

This commit is contained in:
Dean Herbert 2023-06-26 13:24:26 +09:00
commit 372cef3c0a
3 changed files with 13 additions and 14 deletions

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.Chat namespace osu.Game.Online.Chat
{ {
@ -172,7 +173,7 @@ namespace osu.Game.Online.Chat
case "u": case "u":
case "users": case "users":
return new LinkDetails(LinkAction.OpenUserProfile, mainArg); return getUserLink(mainArg);
case "wiki": case "wiki":
return new LinkDetails(LinkAction.OpenWiki, string.Join('/', args.Skip(3))); return new LinkDetails(LinkAction.OpenWiki, string.Join('/', args.Skip(3)));
@ -230,8 +231,7 @@ namespace osu.Game.Online.Chat
break; break;
case "u": case "u":
linkType = LinkAction.OpenUserProfile; return getUserLink(args[2]);
break;
default: default:
return new LinkDetails(LinkAction.External, url); return new LinkDetails(LinkAction.External, url);
@ -246,6 +246,14 @@ namespace osu.Game.Online.Chat
return new LinkDetails(LinkAction.External, url); 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) private static MessageFormatterResult format(string toFormat, int startIndex = 0, int space = 3)
{ {
var result = new MessageFormatterResult(toFormat); var result = new MessageFormatterResult(toFormat);

View File

@ -45,7 +45,6 @@ using osu.Game.Input.Bindings;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapListing; using osu.Game.Overlays.BeatmapListing;
@ -446,15 +445,7 @@ namespace osu.Game
break; break;
case LinkAction.OpenUserProfile: case LinkAction.OpenUserProfile:
if (!(link.Argument is IUser user)) ShowUser((IUser)link.Argument);
{
user = int.TryParse(argString, out int userId)
? new APIUser { Id = userId }
: new APIUser { Username = argString };
}
ShowUser(user);
break; break;
case LinkAction.OpenWiki: case LinkAction.OpenWiki:

View File

@ -223,7 +223,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
private void addBeatmapsetLink() private void addBeatmapsetLink()
=> content.AddLink(activity.Beatmapset.AsNonNull().Title, LinkAction.OpenBeatmapSet, getLinkArgument(activity.Beatmapset.AsNonNull().Url), creationParameters: t => t.Font = getLinkFont()); => 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) private FontUsage getLinkFont(FontWeight fontWeight = FontWeight.Regular)
=> OsuFont.GetFont(size: font_size, weight: fontWeight, italics: true); => OsuFont.GetFont(size: font_size, weight: fontWeight, italics: true);