public TestCaseBadgeContainer() { BadgeContainer badgeContainer; Child = badgeContainer = new BadgeContainer { RelativeSizeAxes = Axes.Both }; AddStep("Show 1 badge", () => badgeContainer.ShowBadges(new[] { new Badge { AwardedAt = DateTimeOffset.Now, Description = "Appreciates compasses", ImageUrl = "https://assets.ppy.sh/profile-badges/mg2018-1star.png", } })); AddStep("Show 2 badges", () => badgeContainer.ShowBadges(new[] { new Badge { AwardedAt = DateTimeOffset.Now, Description = "Contributed to osu!lazer testing", ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.png", }, new Badge { AwardedAt = DateTimeOffset.Now, Description = "Appreciates compasses", ImageUrl = "https://assets.ppy.sh/profile-badges/mg2018-1star.png", } })); AddStep("Show many badges", () => badgeContainer.ShowBadges(Enumerable.Range(1, 20).Select(i => new Badge { AwardedAt = DateTimeOffset.Now, Description = $"Contributed to osu!lazer testing {i} times", ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg", }).ToArray())); }
/// <summary> /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object, which writes the content to be rendered on the client. /// </summary> /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the server control content.</param> protected override void Render(HtmlTextWriter writer) { if (!string.IsNullOrWhiteSpace(BadgeEntityTypeName)) { var badgeComponent = BadgeContainer.GetComponent(BadgeEntityTypeName); if (badgeComponent != null) { var personBlock = ParentPersonBlock; if (personBlock != null) { badgeComponent.ParentPersonBlock = personBlock; badgeComponent.Person = personBlock.Person; badgeComponent.Render(writer); } } } string script = "$('.badge').tooltip({html: true});"; ScriptManager.RegisterStartupScript(this, this.GetType(), "badge-popover", script, true); }
public ProfileHeader(User user) { RelativeSizeAxes = Axes.X; Height = cover_height + info_height; Children = new Drawable[] { coverContainer = new Container { RelativeSizeAxes = Axes.X, Height = cover_height, Masking = true, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f)) }, new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN, Bottom = 20, Right = stats_width + UserProfileOverlay.CONTENT_X_MARGIN }, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Children = new Drawable[] { new UpdateableAvatar { User = user, Size = new Vector2(avatar_size), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Masking = true, CornerRadius = 5, EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.25f), Radius = 4, }, }, new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, X = avatar_size + 10, AutoSizeAxes = Axes.Both, Children = new Drawable[] { SupporterTag = new SupporterIcon { Alpha = 0, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Y = -75, Size = new Vector2(25, 25) }, new FillFlowContainer { Direction = FillDirection.Horizontal, AutoSizeAxes = Axes.Both, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Y = -48, Children = new Drawable[] { new OsuSpriteText { Text = user.Username, Font = @"Exo2.0-RegularItalic", TextSize = 30, }, new ExternalLinkButton($@"https://osu.ppy.sh/users/{user.Id}") { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Margin = new MarginPadding { Left = 3, Bottom = 3 }, //To better lineup with the font }, } }, countryFlag = new DrawableFlag(user.Country) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Width = 30, Height = 20 } } }, badgeContainer = new BadgeContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Origin = Anchor.BottomLeft, Margin = new MarginPadding { Bottom = 5 }, Alpha = 0, }, } }, colourBar = new Box { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, X = UserProfileOverlay.CONTENT_X_MARGIN, Height = 5, Width = info_width, Alpha = 0 } } }, new Box // this is a temporary workaround for incorrect masking behaviour of FillMode.Fill used in UserCoverBackground (see https://github.com/ppy/osu-framework/issues/1675) { RelativeSizeAxes = Axes.X, Height = 1, Y = cover_height, Colour = OsuColour.Gray(34), }, infoTextLeft = new LinkFlowContainer(t => t.TextSize = 14) { X = UserProfileOverlay.CONTENT_X_MARGIN, Y = cover_height + 20, Width = info_width, AutoSizeAxes = Axes.Y, ParagraphSpacing = 0.8f, LineSpacing = 0.2f }, infoTextRight = new LinkFlowContainer(t => { t.TextSize = 14; t.Font = @"Exo2.0-RegularItalic"; }) { X = UserProfileOverlay.CONTENT_X_MARGIN + info_width + 20, Y = cover_height + 20, Width = info_width, AutoSizeAxes = Axes.Y, ParagraphSpacing = 0.8f, LineSpacing = 0.2f }, new Container { X = -UserProfileOverlay.CONTENT_X_MARGIN, RelativeSizeAxes = Axes.Y, Width = stats_width, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Children = new Drawable[] { new Container { RelativeSizeAxes = Axes.X, Y = level_position, Height = level_height, Children = new Drawable[] { new Box { Colour = Color4.Black.Opacity(0.5f), RelativeSizeAxes = Axes.Both }, levelBadge = new Sprite { Anchor = Anchor.Centre, Origin = Anchor.Centre, Height = 50, Width = 50, Alpha = 0 }, levelText = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Y = 11, TextSize = 20 } } }, new Container { RelativeSizeAxes = Axes.X, Y = cover_height, Anchor = Anchor.TopCentre, Origin = Anchor.BottomCentre, Height = cover_height - level_height - level_position - 5, Children = new Drawable[] { new Box { Colour = Color4.Black.Opacity(0.5f), RelativeSizeAxes = Axes.Both }, scoreText = new FillFlowContainer <SpriteText> { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Padding = new MarginPadding { Horizontal = 20, Vertical = 18 }, Spacing = new Vector2(0, 2) }, scoreNumberText = new FillFlowContainer <SpriteText> { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Padding = new MarginPadding { Horizontal = 20, Vertical = 18 }, Spacing = new Vector2(0, 2) }, new FillFlowContainer <GradeBadge> { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Y = -64, Spacing = new Vector2(20, 0), Children = new[] { gradeSSPlus = new GradeBadge("SSPlus") { Alpha = 0 }, gradeSS = new GradeBadge("SS") { Alpha = 0 }, } }, new FillFlowContainer <GradeBadge> { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Y = -18, Spacing = new Vector2(20, 0), Children = new[] { gradeSPlus = new GradeBadge("SPlus") { Alpha = 0 }, gradeS = new GradeBadge("S") { Alpha = 0 }, gradeA = new GradeBadge("A") { Alpha = 0 }, } } } }, new Container { RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Height = info_height - 15, Children = new Drawable[] { new Box { Colour = Color4.Black.Opacity(0.25f), RelativeSizeAxes = Axes.Both }, rankGraph = new RankGraph { RelativeSizeAxes = Axes.Both } } } } } }; }
public ProfileHeader(User user) { RelativeSizeAxes = Axes.X; Height = cover_height + info_height; Children = new Drawable[] { coverContainer = new Container { RelativeSizeAxes = Axes.X, Height = cover_height, Masking = true, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f)) }, new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN, Bottom = 20, Right = stats_width + UserProfileOverlay.CONTENT_X_MARGIN }, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Children = new Drawable[] { new UpdateableAvatar { User = user, Size = new Vector2(avatar_size), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Masking = true, CornerRadius = 5, EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.25f), Radius = 4, }, }, new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, X = avatar_size + 10, AutoSizeAxes = Axes.Both, Children = new Drawable[] { SupporterTag = new SupporterIcon { Alpha = 0, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Y = -75, Size = new Vector2(25, 25) }, new ProfileLink(user) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Y = -48, }, countryFlag = new DrawableFlag(user.Country) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Width = 30, Height = 20 } } }, badgeContainer = new BadgeContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Origin = Anchor.BottomLeft, Margin = new MarginPadding { Bottom = 5 }, Alpha = 0, }, } }, colourBar = new Box { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, X = UserProfileOverlay.CONTENT_X_MARGIN, Height = 5, Width = info_width, Alpha = 0 } } }, infoTextLeft = new OsuTextFlowContainer(t => t.TextSize = 14) { X = UserProfileOverlay.CONTENT_X_MARGIN, Y = cover_height + 20, Width = info_width, AutoSizeAxes = Axes.Y, ParagraphSpacing = 0.8f, LineSpacing = 0.2f }, infoTextRight = new LinkFlowContainer(t => { t.TextSize = 14; t.Font = @"Exo2.0-RegularItalic"; }) { X = UserProfileOverlay.CONTENT_X_MARGIN + info_width + 20, Y = cover_height + 20, Width = info_width, AutoSizeAxes = Axes.Y, ParagraphSpacing = 0.8f, LineSpacing = 0.2f }, new Container { X = -UserProfileOverlay.CONTENT_X_MARGIN, RelativeSizeAxes = Axes.Y, Width = stats_width, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Children = new Drawable[] { new Container { RelativeSizeAxes = Axes.X, Y = level_position, Height = level_height, Children = new Drawable[] { new Box { Colour = Color4.Black.Opacity(0.5f), RelativeSizeAxes = Axes.Both }, levelBadge = new Sprite { Anchor = Anchor.Centre, Origin = Anchor.Centre, Height = 50, Width = 50, Alpha = 0 }, levelText = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Y = 11, TextSize = 20 } } }, new Container { RelativeSizeAxes = Axes.X, Y = cover_height, Anchor = Anchor.TopCentre, Origin = Anchor.BottomCentre, Height = cover_height - level_height - level_position - 5, Children = new Drawable[] { new Box { Colour = Color4.Black.Opacity(0.5f), RelativeSizeAxes = Axes.Both }, scoreText = new FillFlowContainer <SpriteText> { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Padding = new MarginPadding { Horizontal = 20, Vertical = 18 }, Spacing = new Vector2(0, 2) }, scoreNumberText = new FillFlowContainer <SpriteText> { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Padding = new MarginPadding { Horizontal = 20, Vertical = 18 }, Spacing = new Vector2(0, 2) }, new FillFlowContainer <GradeBadge> { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Y = -64, Spacing = new Vector2(20, 0), Children = new[] { gradeSSPlus = new GradeBadge("SSPlus") { Alpha = 0 }, gradeSS = new GradeBadge("SS") { Alpha = 0 }, } }, new FillFlowContainer <GradeBadge> { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Y = -18, Spacing = new Vector2(20, 0), Children = new[] { gradeSPlus = new GradeBadge("SPlus") { Alpha = 0 }, gradeS = new GradeBadge("S") { Alpha = 0 }, gradeA = new GradeBadge("A") { Alpha = 0 }, } } } }, new Container { RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Height = info_height - 15, Children = new Drawable[] { new Box { Colour = Color4.Black.Opacity(0.25f), RelativeSizeAxes = Axes.Both }, rankGraph = new RankGraph { RelativeSizeAxes = Axes.Both } } } } } }; }