Exemple #1
0
        private void updateHost(User host)
        {
            avatar.User = host;

            if (host != null)
            {
                linkContainer.AddText("房主: ");
                linkContainer.NewLine();
                linkContainer.AddUserLink(host, s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true));
            }
        }
Exemple #2
0
        private void updateHost(User host)
        {
            avatar.User = host;

            if (host != null)
            {
                linkContainer.AddText("hosted by");
                linkContainer.NewLine();
                linkContainer.AddLink(host.Username, null, LinkAction.OpenUserProfile, host.Id.ToString(), "View Profile", s => s.Font = "Exo2.0-BoldItalic");
            }
        }
Exemple #3
0
        private void updateHost(User host)
        {
            avatar.User = host;

            if (host != null)
            {
                linkContainer.AddText("hosted by");
                linkContainer.NewLine();
                linkContainer.AddLink(host.Username, null, LinkAction.OpenUserProfile, host.Id.ToString(), "View Profile",
                                      s => s.Font = s.Font.With(Typeface.Exo, weight: FontWeight.Bold, italics: true));
            }
        }
Exemple #4
0
        private void tryAddInfoRightLine(FontAwesome icon, string str, string url = null)
        {
            if (string.IsNullOrEmpty(str))
            {
                return;
            }

            infoTextRight.AddIcon(icon);
            if (url != null)
            {
                infoTextRight.AddLink(" " + str, url);
            }
            else
            {
                infoTextRight.AddText(" " + str);
            }

            infoTextRight.NewLine();
        }
        private void updateDisplay(User user)
        {
            topLinkContainer.Clear();
            bottomLinkContainer.Clear();

            if (user == null)
            {
                return;
            }

            if (user.JoinDate.ToUniversalTime().Year < 2008)
            {
                topLinkContainer.AddText("元老级玩家");
            }
            else
            {
                topLinkContainer.AddText("注册时间: ");
                topLinkContainer.AddText(new DrawableDate(user.JoinDate), embolden);
            }

            addSpacer(topLinkContainer);

            if (user.IsOnline)
            {
                topLinkContainer.AddText("当前在线");
                addSpacer(topLinkContainer);
            }
            else if (user.LastVisit.HasValue)
            {
                topLinkContainer.AddText("上次登入 ");
                topLinkContainer.AddText(new DrawableDate(user.LastVisit.Value), embolden);

                addSpacer(topLinkContainer);
            }

            if (user.PlayStyles?.Length > 0)
            {
                topLinkContainer.AddText("惯用 ");
                topLinkContainer.AddText(string.Join(", ", user.PlayStyles.Select(style => style.GetDescription())), embolden);

                addSpacer(topLinkContainer);
            }

            topLinkContainer.AddText("发表了 ");
            topLinkContainer.AddLink($@"{user.PostCount:#,##0} 篇论坛帖子", $"https://osu.ppy.sh/users/{user.Id}/posts", creationParameters: embolden);

            string websiteWithoutProtcol = user.Website;

            if (!string.IsNullOrEmpty(websiteWithoutProtcol))
            {
                if (Uri.TryCreate(websiteWithoutProtcol, UriKind.Absolute, out var uri))
                {
                    websiteWithoutProtcol = uri.Host + uri.PathAndQuery + uri.Fragment;
                    websiteWithoutProtcol = websiteWithoutProtcol.TrimEnd('/');
                }
            }

            tryAddInfo(FontAwesome.Solid.MapMarker, user.Location);
            tryAddInfo(OsuIcon.Heart, user.Interests);
            tryAddInfo(FontAwesome.Solid.Suitcase, user.Occupation);
            bottomLinkContainer.NewLine();
            if (!string.IsNullOrEmpty(user.Twitter))
            {
                tryAddInfo(FontAwesome.Brands.Twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}");
            }
            tryAddInfo(FontAwesome.Brands.Discord, user.Discord);
            tryAddInfo(FontAwesome.Brands.Skype, user.Skype, @"skype:" + user.Skype + @"?chat");
            tryAddInfo(FontAwesome.Brands.Lastfm, user.Lastfm, $@"https://last.fm/users/{user.Lastfm}");
            tryAddInfo(FontAwesome.Solid.Link, websiteWithoutProtcol, user.Website);
        }
Exemple #6
0
        private void loadUser()
        {
            LoadComponentAsync(new UserCoverBackground(user)
            {
                RelativeSizeAxes = Axes.Both,
                Anchor           = Anchor.Centre,
                Origin           = Anchor.Centre,
                FillMode         = FillMode.Fill,
                OnLoadComplete   = d => d.FadeInFromZero(200),
                Depth            = float.MaxValue,
            }, coverContainer.Add);

            if (user.IsSupporter)
            {
                SupporterTag.Show();
            }

            if (!string.IsNullOrEmpty(user.Colour))
            {
                colourBar.Colour = OsuColour.FromHex(user.Colour);
                colourBar.Show();
            }

            void boldItalic(SpriteText t) => t.Font = @"Exo2.0-BoldItalic";
            void lightText(SpriteText t) => t.Alpha = 0.8f;

            OsuSpriteText createScoreText(string text) => new OsuSpriteText
            {
                TextSize = 14,
                Text     = text
            };

            OsuSpriteText createScoreNumberText(string text) => new OsuSpriteText
            {
                TextSize = 14,
                Font     = @"Exo2.0-Bold",
                Anchor   = Anchor.TopRight,
                Origin   = Anchor.TopRight,
                Text     = text
            };

            if (user.Country != null)
            {
                infoTextLeft.AddText("From ", lightText);
                infoTextLeft.AddText(user.Country.FullName, boldItalic);
                countryFlag.Country = user.Country;
            }

            infoTextLeft.NewParagraph();

            if (user.JoinDate.ToUniversalTime().Year < 2008)
            {
                infoTextLeft.AddText(new DrawableJoinDate(user.JoinDate), lightText);
            }
            else
            {
                infoTextLeft.AddText("Joined ", lightText);
                infoTextLeft.AddText(new DrawableJoinDate(user.JoinDate), boldItalic);
            }

            infoTextLeft.NewLine();
            infoTextLeft.AddText("Last seen ", lightText);
            infoTextLeft.AddText(new DrawableDate(user.LastVisit), boldItalic);
            infoTextLeft.NewParagraph();

            if (user.PlayStyle?.Length > 0)
            {
                infoTextLeft.AddText("Plays with ", lightText);
                infoTextLeft.AddText(string.Join(", ", user.PlayStyle), boldItalic);
            }

            infoTextLeft.NewLine();
            infoTextLeft.AddText("Contributed ", lightText);
            infoTextLeft.AddLink($@"{user.PostCount} forum posts", url: $"https://osu.ppy.sh/users/{user.Id}/posts", creationParameters: 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.Interests);
            tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation);
            infoTextRight.NewParagraph();
            if (!string.IsNullOrEmpty(user.Twitter))
            {
                tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}");
            }
            tryAddInfoRightLine(FontAwesome.fa_gamepad, user.Discord);
            tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype, @"skype:" + user.Skype + @"?chat");
            tryAddInfoRightLine(FontAwesome.fa_lastfm, user.Lastfm, $@"https://last.fm/users/{user.Lastfm}");
            tryAddInfoRightLine(FontAwesome.fa_globe, websiteWithoutProtcol, user.Website);

            if (user.Statistics != null)
            {
                levelBadge.Show();
                levelText.Text = user.Statistics.Level.Current.ToString();

                scoreText.Add(createScoreText("Ranked Score"));
                scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0")));
                scoreText.Add(createScoreText("Accuracy"));
                scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy:0.##}%"));
                scoreText.Add(createScoreText("Play Count"));
                scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0")));
                scoreText.Add(createScoreText("Total Score"));
                scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalScore.ToString(@"#,0")));
                scoreText.Add(createScoreText("Total Hits"));
                scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalHits.ToString(@"#,0")));
                scoreText.Add(createScoreText("Max Combo"));
                scoreNumberText.Add(createScoreNumberText(user.Statistics.MaxCombo.ToString(@"#,0")));
                scoreText.Add(createScoreText("Replays Watched by Others"));
                scoreNumberText.Add(createScoreNumberText(user.Statistics.ReplaysWatched.ToString(@"#,0")));

                gradeSSPlus.DisplayCount = user.Statistics.GradesCount.SSPlus;
                gradeSSPlus.Show();
                gradeSS.DisplayCount = user.Statistics.GradesCount.SS;
                gradeSS.Show();
                gradeSPlus.DisplayCount = user.Statistics.GradesCount.SPlus;
                gradeSPlus.Show();
                gradeS.DisplayCount = user.Statistics.GradesCount.S;
                gradeS.Show();
                gradeA.DisplayCount = user.Statistics.GradesCount.A;
                gradeA.Show();

                rankGraph.User.Value = user;
            }

            badgeContainer.ShowBadges(user.Badges);
        }
        private void updateDisplay(User user)
        {
            topLinkContainer.Clear();
            bottomLinkContainer.Clear();

            if (user == null)
            {
                return;
            }

            if (user.JoinDate.ToUniversalTime().Year < 2008)
            {
                topLinkContainer.AddText("Here since the beginning");
            }
            else
            {
                topLinkContainer.AddText("Joined ");
                topLinkContainer.AddText(new DrawableDate(user.JoinDate, italic: false), embolden);
            }

            addSpacer(topLinkContainer);

            if (user.IsOnline)
            {
                topLinkContainer.AddText("Currently online");
                addSpacer(topLinkContainer);
            }
            else if (user.LastVisit.HasValue)
            {
                topLinkContainer.AddText("Last seen ");
                topLinkContainer.AddText(new DrawableDate(user.LastVisit.Value, italic: false), embolden);

                addSpacer(topLinkContainer);
            }

            if (user.PlayStyles?.Length > 0)
            {
                topLinkContainer.AddText("Plays with ");
                topLinkContainer.AddText(string.Join(", ", user.PlayStyles.Select(style => style.GetDescription())), embolden);

                addSpacer(topLinkContainer);
            }

            topLinkContainer.AddText("Contributed ");
            topLinkContainer.AddLink($@"{user.PostCount:#,##0} forum posts", $"https://osu.ppy.sh/users/{user.Id}/posts", creationParameters: embolden);

            string websiteWithoutProtocol = user.Website;

            if (!string.IsNullOrEmpty(websiteWithoutProtocol))
            {
                if (Uri.TryCreate(websiteWithoutProtocol, UriKind.Absolute, out var uri))
                {
                    websiteWithoutProtocol = uri.Host + uri.PathAndQuery + uri.Fragment;
                    websiteWithoutProtocol = websiteWithoutProtocol.TrimEnd('/');
                }
            }

            bool anyInfoAdded = false;

            anyInfoAdded |= tryAddInfo(FontAwesome.Solid.MapMarker, user.Location);
            anyInfoAdded |= tryAddInfo(OsuIcon.Heart, user.Interests);
            anyInfoAdded |= tryAddInfo(FontAwesome.Solid.Suitcase, user.Occupation);

            if (anyInfoAdded)
            {
                bottomLinkContainer.NewLine();
            }

            if (!string.IsNullOrEmpty(user.Twitter))
            {
                anyInfoAdded |= tryAddInfo(FontAwesome.Brands.Twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}");
            }
            anyInfoAdded |= tryAddInfo(FontAwesome.Brands.Discord, user.Discord);
            anyInfoAdded |= tryAddInfo(FontAwesome.Brands.Skype, user.Skype, @"skype:" + user.Skype + @"?chat");
            anyInfoAdded |= tryAddInfo(FontAwesome.Solid.Link, websiteWithoutProtocol, user.Website);

            // If no information was added to the bottomLinkContainer, hide it to avoid unwanted padding
            bottomLinkContainer.Alpha = anyInfoAdded ? 1 : 0;
        }
Exemple #8
0
        private void updateDisplay(APIUser user)
        {
            topLinkContainer.Clear();
            bottomLinkContainer.Clear();

            if (user == null)
            {
                return;
            }

            if (user.JoinDate.ToUniversalTime().Year < 2008)
            {
                topLinkContainer.AddText(UsersStrings.ShowFirstMembers);
            }
            else
            {
                topLinkContainer.AddText("Joined ");
                topLinkContainer.AddText(new DrawableDate(user.JoinDate, italic: false), embolden);
            }

            addSpacer(topLinkContainer);

            if (user.IsOnline)
            {
                topLinkContainer.AddText(UsersStrings.ShowLastvisitOnline);
                addSpacer(topLinkContainer);
            }
            else if (user.LastVisit.HasValue)
            {
                topLinkContainer.AddText("Last seen ");
                topLinkContainer.AddText(new DrawableDate(user.LastVisit.Value, italic: false), embolden);

                addSpacer(topLinkContainer);
            }

            if (user.PlayStyles?.Length > 0)
            {
                topLinkContainer.AddText("Plays with ");

                LocalisableString playStylesString = user.PlayStyles[0].GetLocalisableDescription();

                for (int i = 1; i < user.PlayStyles.Length; i++)
                {
                    playStylesString = new TranslatableString(@"_", @"{0}{1}", playStylesString, CommonStrings.ArrayAndWordsConnector);
                    playStylesString = new TranslatableString(@"_", @"{0}{1}", playStylesString, user.PlayStyles[i].GetLocalisableDescription());
                }

                topLinkContainer.AddText(playStylesString, embolden);

                addSpacer(topLinkContainer);
            }

            topLinkContainer.AddText("Contributed ");
            topLinkContainer.AddLink("forum post".ToQuantity(user.PostCount, "#,##0"), $"{api.WebsiteRootUrl}/users/{user.Id}/posts", creationParameters: embolden);

            addSpacer(topLinkContainer);

            topLinkContainer.AddText("Posted ");
            topLinkContainer.AddLink("comment".ToQuantity(user.CommentsCount, "#,##0"), $"{api.WebsiteRootUrl}/comments?user_id={user.Id}", creationParameters: embolden);

            string websiteWithoutProtocol = user.Website;

            if (!string.IsNullOrEmpty(websiteWithoutProtocol))
            {
                if (Uri.TryCreate(websiteWithoutProtocol, UriKind.Absolute, out var uri))
                {
                    websiteWithoutProtocol = uri.Host + uri.PathAndQuery + uri.Fragment;
                    websiteWithoutProtocol = websiteWithoutProtocol.TrimEnd('/');
                }
            }

            bool anyInfoAdded = false;

            anyInfoAdded |= tryAddInfo(FontAwesome.Solid.MapMarker, user.Location);
            anyInfoAdded |= tryAddInfo(OsuIcon.Heart, user.Interests);
            anyInfoAdded |= tryAddInfo(FontAwesome.Solid.Suitcase, user.Occupation);

            if (anyInfoAdded)
            {
                bottomLinkContainer.NewLine();
            }

            if (!string.IsNullOrEmpty(user.Twitter))
            {
                anyInfoAdded |= tryAddInfo(FontAwesome.Brands.Twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}");
            }
            anyInfoAdded |= tryAddInfo(FontAwesome.Brands.Discord, user.Discord);
            anyInfoAdded |= tryAddInfo(FontAwesome.Solid.Link, websiteWithoutProtocol, user.Website);

            // If no information was added to the bottomLinkContainer, hide it to avoid unwanted padding
            bottomLinkContainer.Alpha = anyInfoAdded ? 1 : 0;
        }