1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Fix OpenUserProfile links having multiple argument types

This commit is contained in:
Salman Ahmed 2023-06-23 22:37:44 +03:00
parent d86424467e
commit ff17685bc3
2 changed files with 10 additions and 8 deletions

View File

@ -74,7 +74,13 @@ namespace osu.Game.Graphics.Containers
} }
public void AddUserLink(IUser user, Action<SpriteText> creationParameters = null) public void AddUserLink(IUser user, Action<SpriteText> creationParameters = null)
=> createLink(CreateChunkFor(user.Username, true, CreateSpriteText, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, user), "view profile"); {
string argument = user.OnlineID > 1
? user.OnlineID.ToString()
: user.Username;
createLink(CreateChunkFor(user.Username, true, CreateSpriteText, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, argument), "view profile");
}
private void createLink(ITextPart textPart, LinkDetails link, LocalisableString tooltipText, Action action = null) private void createLink(ITextPart textPart, LinkDetails link, LocalisableString tooltipText, Action action = null)
{ {

View File

@ -446,15 +446,11 @@ namespace osu.Game
break; break;
case LinkAction.OpenUserProfile: case LinkAction.OpenUserProfile:
if (!(link.Argument is IUser user)) var user = int.TryParse(argString, out int userId)
{ ? new APIUser { Id = userId }
user = int.TryParse(argString, out int userId) : new APIUser { Username = argString };
? new APIUser { Id = userId }
: new APIUser { Username = argString };
}
ShowUser(user); ShowUser(user);
break; break;
case LinkAction.OpenWiki: case LinkAction.OpenWiki: