diff --git a/osu-framework b/osu-framework index a7edf9bb3b..2d2e2fe698 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a7edf9bb3bae6908f316ba0ee9dacdbbb66e8c19 +Subproject commit 2d2e2fe698ab32d80d5e856f52c8c398ceb35540 diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 6bec2cb184..4e99a44a07 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -175,11 +175,11 @@ namespace osu.Game LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); - LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add); + LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); LoadComponentAsync(musicController = new MusicController { - Depth = -2, + Depth = -3, Position = new Vector2(0, Toolbar.HEIGHT), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -187,14 +187,14 @@ namespace osu.Game LoadComponentAsync(notificationManager = new NotificationManager { - Depth = -2, + Depth = -3, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, overlayContent.Add); LoadComponentAsync(dialogOverlay = new DialogOverlay { - Depth = -4, + Depth = -5, }, overlayContent.Add); Logger.NewEntry += entry => @@ -221,7 +221,7 @@ namespace osu.Game LoadComponentAsync(Toolbar = new Toolbar { - Depth = -3, + Depth = -4, OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, }, overlayContent.Add); diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index 198a2a9419..c08e62428b 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -11,6 +12,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics.Effects; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Allocation; +using osu.Game.Users; namespace osu.Game.Overlays.Chat { @@ -62,6 +64,8 @@ namespace osu.Game.Overlays.Chat private const float message_padding = 200; private const float text_size = 20; + private Action loadProfile; + private Color4 customUsernameColour; public ChatLine(Message message) @@ -75,9 +79,10 @@ namespace osu.Game.Overlays.Chat } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, UserProfileOverlay profile) { customUsernameColour = colours.ChatBlue; + loadProfile = u => profile?.ShowUser(u); } protected override void LoadComplete() @@ -87,8 +92,6 @@ namespace osu.Game.Overlays.Chat bool hasBackground = !string.IsNullOrEmpty(Message.Sender.Colour); Drawable username = new OsuSpriteText { - Origin = Anchor.TopRight, - Anchor = Anchor.TopRight, Font = @"Exo2.0-BoldItalic", Text = $@"{Message.Sender.Username}" + (hasBackground ? "" : ":"), Colour = hasBackground ? customUsernameColour : username_colours[Message.UserId % username_colours.Length], @@ -132,7 +135,7 @@ namespace osu.Game.Overlays.Chat new Container { Size = new Vector2(message_padding, text_size), - Children = new[] + Children = new Drawable[] { new OsuSpriteText { @@ -144,7 +147,14 @@ namespace osu.Game.Overlays.Chat TextSize = text_size * 0.75f, Alpha = 0.4f, }, - username + new ClickableContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.TopRight, + Anchor = Anchor.TopRight, + Child = username, + Action = () => loadProfile(Message.Sender), + }, } }, new Container diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 17493d5078..21bfd5afd6 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -12,16 +12,20 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Users; +using System.Diagnostics; +using System.Globalization; namespace osu.Game.Overlays.Profile { public class ProfileHeader : Container { - private readonly OsuTextFlowContainer infoTextLeft, infoTextRight; + private readonly OsuTextFlowContainer infoTextLeft; + private readonly LinkFlowContainer infoTextRight; private readonly FillFlowContainer scoreText, scoreNumberText; private readonly Container coverContainer, chartContainer, supporterTag; @@ -29,6 +33,7 @@ namespace osu.Game.Overlays.Profile private readonly SpriteText levelText; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private readonly Box colourBar; + private readonly DrawableFlag countryFlag; private const float cover_height = 350; private const float info_height = 150; @@ -114,16 +119,17 @@ namespace osu.Game.Overlays.Profile } } }, - new OsuSpriteText + new LinkFlowContainer.LinkText { Text = user.Username, + Url = $@"https://osu.ppy.sh/users/{user.Id}", TextSize = 30, Font = @"Exo2.0-RegularItalic", Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Y = -48 }, - new DrawableFlag(user.Country?.FlagName ?? "__") + countryFlag = new DrawableFlag(user.Country?.FlagName ?? "__") { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -158,7 +164,7 @@ namespace osu.Game.Overlays.Profile ParagraphSpacing = 0.8f, LineSpacing = 0.2f }, - infoTextRight = new OsuTextFlowContainer(t => + infoTextRight = new LinkFlowContainer(t => { t.TextSize = 14; t.Font = @"Exo2.0-RegularItalic"; @@ -350,6 +356,7 @@ namespace osu.Game.Overlays.Profile { infoTextLeft.AddText("from "); infoTextLeft.AddText(user.Country.FullName, boldItalic); + countryFlag.FlagName = user.Country.FlagName; } infoTextLeft.NewParagraph(); @@ -373,14 +380,22 @@ namespace osu.Game.Overlays.Profile infoTextLeft.AddText(string.Join(", ", user.PlayStyle), boldItalic); } + string websiteWithoutProtcol = user.Website; + if (!string.IsNullOrEmpty(websiteWithoutProtcol)) + { + int protocolIndex = websiteWithoutProtcol.IndexOf("//", StringComparison.Ordinal); + if (protocolIndex >= 0) + websiteWithoutProtcol = websiteWithoutProtcol.Substring(protocolIndex + 2); + } + tryAddInfoRightLine(FontAwesome.fa_map_marker, user.Location); tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Intrerests); tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation); infoTextRight.NewParagraph(); if (!string.IsNullOrEmpty(user.Twitter)) - tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter); - tryAddInfoRightLine(FontAwesome.fa_globe, user.Website); - tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype); + tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}"); + tryAddInfoRightLine(FontAwesome.fa_globe, websiteWithoutProtcol, user.Website); + tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype, @"skype:" + user.Skype + @"?chat"); if (user.Statistics != null) { @@ -390,7 +405,7 @@ namespace osu.Game.Overlays.Profile scoreText.Add(createScoreText("Ranked Score")); scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); scoreText.Add(createScoreText("Accuracy")); - scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%")); + scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##", CultureInfo.CurrentCulture)}%")); scoreText.Add(createScoreText("Play Count")); scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); scoreText.Add(createScoreText("Total Score")); @@ -433,12 +448,12 @@ namespace osu.Game.Overlays.Profile Text = text }; - private void tryAddInfoRightLine(FontAwesome icon, string str) + private void tryAddInfoRightLine(FontAwesome icon, string str, string url = null) { if (string.IsNullOrEmpty(str)) return; infoTextRight.AddIcon(icon); - infoTextRight.AddText(" " + str); + infoTextRight.AddLink(" " + str, url); infoTextRight.NewLine(); } @@ -479,5 +494,51 @@ namespace osu.Game.Overlays.Profile badge.Texture = textures.Get($"Grades/{grade}"); } } + + private class LinkFlowContainer : OsuTextFlowContainer + { + public override bool HandleInput => true; + + public LinkFlowContainer(Action defaultCreationParameters = null) : base(defaultCreationParameters) + { + } + + protected override SpriteText CreateSpriteText() => new LinkText(); + + public void AddLink(string text, string url) => AddText(text, link => ((LinkText)link).Url = url); + + public class LinkText : OsuSpriteText + { + public override bool HandleInput => Url != null; + + public string Url; + + private Color4 hoverColour; + + protected override bool OnHover(InputState state) + { + FadeColour(hoverColour, 500, EasingTypes.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + FadeColour(Color4.White, 500, EasingTypes.OutQuint); + base.OnHoverLost(state); + } + + protected override bool OnClick(InputState state) + { + Process.Start(Url); + return true; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + hoverColour = colours.Yellow; + } + } + } } }