protected sealed override Drawable CreateFlagContent(UserStatistics item) { var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE)) { AutoSizeAxes = Axes.Both }; username.AddUserLink(item.User); return(username); }
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)); } }
private void updateInfo() { beatmapAuthor.Clear(); var beatmap = Playlist.FirstOrDefault()?.Beatmap; if (beatmap != null) { beatmapAuthor.AddText("mapped by ", s => s.Colour = OsuColour.Gray(0.8f)); beatmapAuthor.AddUserLink(beatmap.Value.Metadata.Author); } }
protected sealed override Drawable CreateFlagContent(UserStatistics item) { var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE, italics: true)) { AutoSizeAxes = Axes.X, RelativeSizeAxes = Axes.Y, TextAnchor = Anchor.CentreLeft }; username.AddUserLink(item.User); return(username); }
private void load(OsuColour colours) { InternalChild = new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10, 0), Children = new Drawable[] { avatar = new UpdateableAvatar { Size = new Vector2(50), Masking = true, CornerRadius = 10, }, new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { new OsuSpriteText { Font = OsuFont.GetFont(size: 30), Current = { BindTarget = RoomName } }, hostText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold)) { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, } } } } }; Host.BindValueChanged(host => { avatar.User = host.NewValue; hostText.Clear(); if (host.NewValue != null) { hostText.AddText("hosted by "); hostText.AddUserLink(host.NewValue); } }, true); }
private void load() { LinkFlowContainer beatmapAuthor; InternalChild = new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, LayoutDuration = 100, Spacing = new Vector2(5, 0), Children = new Drawable[] { new ModeTypeInfo(), new Container { AutoSizeAxes = Axes.X, Height = 30, Margin = new MarginPadding { Left = 5 }, Children = new Drawable[] { new BeatmapTitle(), beatmapAuthor = new LinkFlowContainer(s => s.Font = s.Font.With(size: 14)) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, AutoSizeAxes = Axes.Both }, }, }, } }; CurrentItem.BindValueChanged(item => { beatmapAuthor.Clear(); var beatmap = item.NewValue?.Beatmap; if (beatmap != null) { beatmapAuthor.AddText("制作者 ", s => s.Colour = OsuColour.Gray(0.8f)); beatmapAuthor.AddUserLink(beatmap.Metadata.Author); } }, true); }
private void addGithubAuthorReference(LinkFlowContainer title, Color4 entryColour) { title.AddText("by ", t => { t.Font = fontMedium; t.Colour = entryColour; t.Padding = new MarginPadding { Left = 10 }; }); if (entry.GithubUser.UserId != null) { title.AddUserLink(new APIUser { Username = entry.GithubUser.OsuUsername, Id = entry.GithubUser.UserId.Value }, t => { t.Font = fontMedium; t.Colour = entryColour; }); } else if (entry.GithubUser.GithubUrl != null) { title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, t => { t.Font = fontMedium; t.Colour = entryColour; }); } else { title.AddText(entry.GithubUser.DisplayName, t => { t.Font = fontMedium; t.Colour = entryColour; }); } }
private void load(OsuColour colours, OverlayColourProvider colourProvider) { foreach (var categoryEntries in Build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key)) { ChangelogEntries.Add(new OsuSpriteText { Text = categoryEntries.Key, Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 18), Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); var fontLarge = OsuFont.GetFont(size: 16); var fontMedium = OsuFont.GetFont(size: 12); foreach (var entry in categoryEntries) { var entryColour = entry.Major ? colours.YellowLight : Color4.White; LinkFlowContainer title; var titleContainer = new Container { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Margin = new MarginPadding { Vertical = 5 }, Children = new Drawable[] { new SpriteIcon { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreRight, Size = new Vector2(10), Icon = entry.Type == ChangelogEntryType.Fix ? FontAwesome.Solid.Check : FontAwesome.Solid.Plus, Colour = entryColour.Opacity(0.5f), Margin = new MarginPadding { Right = 5 }, }, title = new LinkFlowContainer { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, } } }; title.AddText(entry.Title, t => { t.Font = fontLarge; t.Colour = entryColour; }); if (!string.IsNullOrEmpty(entry.Repository)) { title.AddText(" (", t => { t.Font = fontLarge; t.Colour = entryColour; }); title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, creationParameters: t => { t.Font = fontLarge; t.Colour = entryColour; }); title.AddText(")", t => { t.Font = fontLarge; t.Colour = entryColour; }); } title.AddText("by ", t => { t.Font = fontMedium.With(italics: true); t.Colour = entryColour; t.Padding = new MarginPadding { Left = 10 }; }); if (entry.GithubUser.UserId != null) { title.AddUserLink(new User { Username = entry.GithubUser.OsuUsername, Id = entry.GithubUser.UserId.Value }, t => { t.Font = fontMedium.With(italics: true); t.Colour = entryColour; }); } else if (entry.GithubUser.GithubUrl != null) { title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, t => { t.Font = fontMedium.With(italics: true); t.Colour = entryColour; }); } else { title.AddText(entry.GithubUser.DisplayName, t => { t.Font = fontMedium.With(italics: true); t.Colour = entryColour; }); } ChangelogEntries.Add(titleContainer); if (!string.IsNullOrEmpty(entry.MessageHtml)) { var message = new TextFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, }; // todo: use markdown parsing once API returns markdown message.AddText(WebUtility.HtmlDecode(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty)), t => { t.Font = fontMedium; t.Colour = colourProvider.Foreground1; }); ChangelogEntries.Add(message); } } } }
private Drawable[] createContent(int index, ScoreInfo score) { var content = new List <Drawable> { new OsuSpriteText { Text = $"#{index + 1}", Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold) }, new UpdateableRank(score.Rank) { Size = new Vector2(30, 20) }, new OsuSpriteText { Margin = new MarginPadding { Right = horizontal_inset }, Text = $@"{score.TotalScore:N0}", Font = OsuFont.GetFont(size: text_size, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium) }, new OsuSpriteText { Margin = new MarginPadding { Right = horizontal_inset }, Text = $@"{score.Accuracy:P2}", Font = OsuFont.GetFont(size: text_size), Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White }, }; var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: text_size)) { AutoSizeAxes = Axes.Both }; username.AddUserLink(score.User); content.AddRange(new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Margin = new MarginPadding { Right = horizontal_inset }, Spacing = new Vector2(5, 0), Children = new Drawable[] { new UpdateableFlag(score.User.Country) { Size = new Vector2(20, 13), ShowPlaceholderOnNull = false, }, username } }, new OsuSpriteText { Text = $@"{score.MaxCombo:N0}x", Font = OsuFont.GetFont(size: text_size) } }); foreach (var kvp in score.Statistics) { content.Add(new OsuSpriteText { Text = $"{kvp.Value}", Font = OsuFont.GetFont(size: text_size), Colour = kvp.Value == 0 ? Color4.Gray : Color4.White }); } content.AddRange(new Drawable[] { new OsuSpriteText { Text = $@"{score.PP:N0}", Font = OsuFont.GetFont(size: text_size) }, new FillFlowContainer { Direction = FillDirection.Horizontal, AutoSizeAxes = Axes.Both, Spacing = new Vector2(1), ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m) { AutoSizeAxes = Axes.Both, Scale = new Vector2(0.3f) }) }, }); return(content.ToArray()); }
public ChangelogBuild(APIChangelogBuild build) { Build = build; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; Padding = new MarginPadding { Horizontal = HORIZONTAL_PADDING }; Children = new Drawable[] { CreateHeader(), ChangelogEntries = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, }, }; foreach (var categoryEntries in build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key)) { ChangelogEntries.Add(new OsuSpriteText { Text = categoryEntries.Key, Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); var fontLarge = OsuFont.GetFont(size: 18); var fontMedium = OsuFont.GetFont(size: 14); var fontSmall = OsuFont.GetFont(size: 12); foreach (APIChangelogEntry entry in categoryEntries) { LinkFlowContainer title = new LinkFlowContainer { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Vertical = 5 }, }; title.AddIcon(FontAwesome.Solid.Check, t => { t.Font = fontSmall; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); title.AddText(entry.Title, t => { t.Font = fontLarge; }); if (!string.IsNullOrEmpty(entry.Repository)) { title.AddText(" (", t => t.Font = fontLarge); title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External, creationParameters: t => { t.Font = fontLarge; }); title.AddText(")", t => t.Font = fontLarge); } title.AddText(" by ", t => t.Font = fontMedium); if (entry.GithubUser.UserId != null) { title.AddUserLink(new User { Username = entry.GithubUser.OsuUsername, Id = entry.GithubUser.UserId.Value }, t => t.Font = fontMedium); } else if (entry.GithubUser.GithubUrl != null) { title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => t.Font = fontMedium); } else { title.AddText(entry.GithubUser.DisplayName, t => t.Font = fontSmall); } ChangelogEntries.Add(title); if (!string.IsNullOrEmpty(entry.MessageHtml)) { TextFlowContainer message = new TextFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, }; // todo: use markdown parsing once API returns markdown message.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t => { t.Font = fontSmall; t.Colour = new Color4(235, 184, 254, 255); }); ChangelogEntries.Add(message); } } } }
private void load(OverlayColourProvider colourProvider) { LinkFlowContainer username; FillFlowContainer info; CommentMarkdownContainer message; GridContainer content; VotePill votePill; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; InternalChildren = new Drawable[] { new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = getPadding(Comment.IsTopLevel), Child = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Children = new Drawable[] { content = new GridContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, ColumnDimensions = new[] { new Dimension(GridSizeMode.Absolute, size: avatar_size + 10), new Dimension(), }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new Drawable[] { new Container { Size = new Vector2(avatar_size), Children = new Drawable[] { new UpdateableAvatar(Comment.User) { Size = new Vector2(avatar_size), Masking = true, CornerRadius = avatar_size / 2f, CornerExponent = 2, }, votePill = new VotePill(Comment) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreRight, Margin = new MarginPadding { Right = 5 } } } }, new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 4), Margin = new MarginPadding { Vertical = 2 }, Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10, 0), Children = new[] { username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold)) { AutoSizeAxes = Axes.Both }, Comment.Pinned ? new PinnedCommentNotice() : Empty(), new ParentUsername(Comment), new OsuSpriteText { Alpha = Comment.IsDeleted ? 1 : 0, Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), Text = CommentsStrings.Deleted } } }, message = new CommentMarkdownContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, DocumentMargin = new MarginPadding(0), DocumentPadding = new MarginPadding(0), }, info = new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10, 0), Children = new Drawable[] { new DrawableDate(Comment.CreatedAt, 12, false) { Colour = colourProvider.Foreground1 } } }, new Container { AutoSizeAxes = Axes.Both, Children = new Drawable[] { showRepliesButton = new ShowRepliesButton(Comment.RepliesCount) { Expanded = { BindTarget = childrenExpanded } }, loadRepliesButton = new LoadRepliesButton { Action = () => RepliesRequested(this, ++currentPage) } } } } } } } }, childCommentsVisibilityContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Padding = new MarginPadding { Left = 20 }, Children = new Drawable[] { childCommentsContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical }, deletedCommentsCounter = new DeletedCommentsCounter { ShowDeleted = { BindTarget = ShowDeleted }, Margin = new MarginPadding { Top = 10 } }, showMoreButton = new ShowMoreRepliesButton { Action = () => RepliesRequested(this, ++currentPage) } } }, } } }, new Container { Size = new Vector2(70, 40), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Margin = new MarginPadding { Horizontal = 5 }, Child = chevronButton = new ChevronButton { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Expanded = { BindTarget = childrenExpanded }, Alpha = 0 } } }; if (Comment.UserId.HasValue) { username.AddUserLink(Comment.User); } else { username.AddText(Comment.LegacyName); } if (Comment.EditedAt.HasValue) { var font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular); var colour = colourProvider.Foreground1; info.Add(new FillFlowContainer { AutoSizeAxes = Axes.Both, Children = new Drawable[] { new OsuSpriteText { Font = font, Text = "edited ", Colour = colour }, new DrawableDate(Comment.EditedAt.Value) { Font = font, Colour = colour }, new OsuSpriteText { Font = font, Text = $@" by {Comment.EditedUser.Username}", Colour = colour }, } }); } if (Comment.HasMessage) { message.Text = Comment.Message; } if (Comment.IsDeleted) { content.FadeColour(OsuColour.Gray(0.5f)); votePill.Hide(); } if (Comment.IsTopLevel) { AddInternal(new Box { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.X, Height = 1.5f, Colour = OsuColour.Gray(0.1f) }); } if (Replies.Any()) { onRepliesAdded(Replies); } Replies.CollectionChanged += (_, args) => { switch (args.Action) { case NotifyCollectionChangedAction.Add: onRepliesAdded(args.NewItems.Cast <DrawableComment>()); break; default: throw new NotSupportedException(@"You can only add replies to this list. Other actions are not supported."); } }; }
private void load() { LinkFlowContainer username; FillFlowContainer info; LinkFlowContainer message; GridContainer content; VotePill votePill; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; InternalChildren = new Drawable[] { new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Children = new Drawable[] { new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding(margin) { Left = margin + 5, Top = Comment.IsTopLevel ? 10 : 0 }, Child = content = new GridContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize), new Dimension(), }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Horizontal = margin }, Direction = FillDirection.Horizontal, Spacing = new Vector2(5, 0), Children = new Drawable[] { new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, Width = 40, AutoSizeAxes = Axes.Y, Child = votePill = new VotePill(Comment) { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, } }, new UpdateableAvatar(Comment.User) { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(avatar_size), Masking = true, CornerRadius = avatar_size / 2f, CornerExponent = 2, }, } }, new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 3), Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(7, 0), Children = new Drawable[] { username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true)) { AutoSizeAxes = Axes.Both, }, new ParentUsername(Comment), new OsuSpriteText { Alpha = Comment.IsDeleted ? 1 : 0, Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), Text = @"deleted", } } }, message = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Right = 40 } }, new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { info = new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10, 0), Children = new Drawable[] { new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Font = OsuFont.GetFont(size: 12), Colour = OsuColour.Gray(0.7f), Text = HumanizerUtils.Humanize(Comment.CreatedAt) }, } }, showRepliesButton = new ShowRepliesButton(Comment.RepliesCount) { Expanded = { BindTarget = childrenExpanded } }, loadRepliesButton = new LoadRepliesButton { Action = () => RepliesRequested(this, ++currentPage) } } } } } } } } }, childCommentsVisibilityContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Children = new Drawable[] { childCommentsContainer = new FillFlowContainer { Padding = new MarginPadding { Left = 20 }, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical }, deletedCommentsCounter = new DeletedCommentsCounter { ShowDeleted = { BindTarget = ShowDeleted } }, showMoreButton = new ShowMoreButton { Action = () => RepliesRequested(this, ++currentPage) } } }, } }, chevronButton = new ChevronButton { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Margin = new MarginPadding { Right = 30, Top = margin }, Expanded = { BindTarget = childrenExpanded }, Alpha = 0 } }; if (Comment.UserId.HasValue) { username.AddUserLink(Comment.User); } else { username.AddText(Comment.LegacyName); } if (Comment.EditedAt.HasValue) { info.Add(new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Font = OsuFont.GetFont(size: 12), Text = $@"edited {HumanizerUtils.Humanize(Comment.EditedAt.Value)} by {Comment.EditedUser.Username}" }); } if (Comment.HasMessage) { var formattedSource = MessageFormatter.FormatText(Comment.Message); message.AddLinks(formattedSource.Text, formattedSource.Links); } if (Comment.IsDeleted) { content.FadeColour(OsuColour.Gray(0.5f)); votePill.Hide(); } if (Comment.IsTopLevel) { AddInternal(new Box { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.X, Height = 1.5f, Colour = OsuColour.Gray(0.1f) }); } if (Replies.Any()) { onRepliesAdded(Replies); } Replies.CollectionChanged += (_, args) => { switch (args.Action) { case NotifyCollectionChangedAction.Add: onRepliesAdded(args.NewItems.Cast <DrawableComment>()); break; default: throw new NotSupportedException(@"You can only add replies to this list. Other actions are not supported."); } }; }
private void load(OsuColour colours) { foreach (var categoryEntries in Build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key)) { ChangelogEntries.Add(new OsuSpriteText { Text = categoryEntries.Key, Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), Margin = new MarginPadding { Top = 35, Bottom = 15 }, }); var fontLarge = OsuFont.GetFont(size: 18); var fontMedium = OsuFont.GetFont(size: 14); var fontSmall = OsuFont.GetFont(size: 12); foreach (APIChangelogEntry entry in categoryEntries) { LinkFlowContainer title = new LinkFlowContainer { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Vertical = 5 }, }; var entryColour = entry.Major ? colours.YellowLight : Color4.White; title.AddIcon(entry.Type == ChangelogEntryType.Fix ? FontAwesome.Solid.Check : FontAwesome.Solid.Plus, t => { t.Font = fontSmall; t.Colour = entryColour; t.Padding = new MarginPadding { Left = -17, Right = 5 }; }); title.AddText(entry.Title, t => { t.Font = fontLarge; t.Colour = entryColour; }); if (!string.IsNullOrEmpty(entry.Repository)) { title.AddText(" (", t => { t.Font = fontLarge; t.Colour = entryColour; }); title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External, creationParameters: t => { t.Font = fontLarge; t.Colour = entryColour; }); title.AddText(")", t => { t.Font = fontLarge; t.Colour = entryColour; }); } title.AddText(" by ", t => { t.Font = fontMedium; t.Colour = entryColour; }); if (entry.GithubUser.UserId != null) { title.AddUserLink(new User { Username = entry.GithubUser.OsuUsername, Id = entry.GithubUser.UserId.Value }, t => { t.Font = fontMedium; t.Colour = entryColour; }); } else if (entry.GithubUser.GithubUrl != null) { title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => { t.Font = fontMedium; t.Colour = entryColour; }); } else { title.AddText(entry.GithubUser.DisplayName, t => { t.Font = fontSmall; t.Colour = entryColour; }); } ChangelogEntries.Add(title); if (!string.IsNullOrEmpty(entry.MessageHtml)) { TextFlowContainer message = new TextFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, }; // todo: use markdown parsing once API returns markdown message.AddText(WebUtility.HtmlDecode(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty)), t => { t.Font = fontSmall; t.Colour = new Color4(235, 184, 254, 255); }); ChangelogEntries.Add(message); } } } }
private Drawable[] createContent(int index, ScoreInfo score) { var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: text_size)) { AutoSizeAxes = Axes.Both }; username.AddUserLink(score.User); var content = new List <Drawable> { new OsuSpriteText { Text = $"#{index + 1}", Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold) }, new UpdateableRank(score.Rank) { Size = new Vector2(28, 14) }, new OsuSpriteText { Margin = new MarginPadding { Right = horizontal_inset }, Current = scoreManager.GetBindableTotalScoreString(score), Font = OsuFont.GetFont(size: text_size, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium) }, new OsuSpriteText { Margin = new MarginPadding { Right = horizontal_inset }, Text = score.DisplayAccuracy, Font = OsuFont.GetFont(size: text_size), Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White }, new UpdateableFlag(score.User.Country) { Size = new Vector2(19, 13), ShowPlaceholderOnNull = false, }, username, new OsuSpriteText { Text = $@"{score.MaxCombo:N0}x", Font = OsuFont.GetFont(size: text_size), Colour = score.MaxCombo == score.Beatmap?.MaxCombo ? highAccuracyColour : Color4.White } }; var availableStatistics = score.GetStatisticsForDisplay().ToDictionary(tuple => tuple.result); foreach (var result in statisticResultTypes) { if (!availableStatistics.TryGetValue(result, out var stat)) { stat = (result, 0, null); } content.Add(new OsuSpriteText { Text = stat.maxCount == null ? $"{stat.count}" : $"{stat.count}/{stat.maxCount}", Font = OsuFont.GetFont(size: text_size), Colour = stat.count == 0 ? Color4.Gray : Color4.White }); } if (showPerformancePoints) { content.Add(new OsuSpriteText { Text = $@"{score.PP:N0}", Font = OsuFont.GetFont(size: text_size) }); } content.Add(new FillFlowContainer { Direction = FillDirection.Horizontal, AutoSizeAxes = Axes.Both, Spacing = new Vector2(1), ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m) { AutoSizeAxes = Axes.Both, Scale = new Vector2(0.3f) }) }); return(content.ToArray()); }
private void load() { LinkFlowContainer username; FillFlowContainer childCommentsContainer; DeletedCommentsCounter deletedCommentsCounter; FillFlowContainer info; LinkFlowContainer message; GridContainer content; VotePill votePill; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; InternalChild = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Children = new Drawable[] { new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding(margin) { Left = margin + 5 }, Child = content = new GridContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize), new Dimension(), }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Horizontal = margin }, Direction = FillDirection.Horizontal, Spacing = new Vector2(5, 0), Children = new Drawable[] { new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, Width = 40, AutoSizeAxes = Axes.Y, Child = votePill = new VotePill(comment) { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, } }, new UpdateableAvatar(comment.User) { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(avatar_size), Masking = true, CornerRadius = avatar_size / 2f, CornerExponent = 2, }, } }, new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 3), Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(7, 0), Children = new Drawable[] { username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true)) { AutoSizeAxes = Axes.Both, }, new ParentUsername(comment), new OsuSpriteText { Alpha = comment.IsDeleted ? 1 : 0, Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), Text = @"deleted", } } }, message = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Right = 40 } }, info = new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10, 0), Colour = OsuColour.Gray(0.7f), Children = new Drawable[] { new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Font = OsuFont.GetFont(size: 12), Text = HumanizerUtils.Humanize(comment.CreatedAt) }, new RepliesButton(comment.RepliesCount) { Expanded = { BindTarget = childrenExpanded } }, } } } } } } } }, childCommentsVisibilityContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Children = new Drawable[] { childCommentsContainer = new FillFlowContainer { Padding = new MarginPadding { Left = 20 }, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical }, deletedCommentsCounter = new DeletedCommentsCounter { ShowDeleted = { BindTarget = ShowDeleted } } } } } }; deletedCommentsCounter.Count.Value = comment.DeletedChildrenCount; if (comment.UserId.HasValue) { username.AddUserLink(comment.User); } else { username.AddText(comment.LegacyName); } if (comment.EditedAt.HasValue) { info.Add(new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Font = OsuFont.GetFont(size: 12), Text = $@"edited {HumanizerUtils.Humanize(comment.EditedAt.Value)} by {comment.EditedUser.Username}" }); } if (comment.HasMessage) { var formattedSource = MessageFormatter.FormatText(comment.GetMessage); message.AddLinks(formattedSource.Text, formattedSource.Links); } if (comment.IsDeleted) { content.FadeColour(OsuColour.Gray(0.5f)); votePill.Hide(); } if (comment.IsTopLevel) { AddInternal(new Container { RelativeSizeAxes = Axes.X, Height = 1.5f, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Child = new Box { RelativeSizeAxes = Axes.Both, Colour = OsuColour.Gray(0.1f) } }); if (comment.ChildComments.Any()) { AddInternal(new ChevronButton(comment) { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Margin = new MarginPadding { Right = 30, Top = margin }, Expanded = { BindTarget = childrenExpanded } }); } } comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c) { ShowDeleted = { BindTarget = ShowDeleted } })); }
private void load(OsuColour colours) { InternalChildren = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10, 0), Children = new Drawable[] { avatar = new UpdateableAvatar { Size = new Vector2(50), Masking = true, CornerRadius = 10, }, new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { new OsuSpriteText { Font = OsuFont.GetFont(size: 30), Current = { BindTarget = RoomName } }, hostText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 20)) { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, } } } } }, openSettingsButton = new PurpleTriangleButton { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, Size = new Vector2(150, HEIGHT), Text = "Open settings", Action = () => OpenSettings?.Invoke(), Alpha = 0 } }; Host.BindValueChanged(host => { avatar.User = host.NewValue; hostText.Clear(); if (host.NewValue != null) { hostText.AddText("hosted by "); hostText.AddUserLink(host.NewValue, s => s.Font = s.Font.With(weight: FontWeight.SemiBold)); } openSettingsButton.Alpha = host.NewValue?.Equals(api.LocalUser.Value) == true ? 1 : 0; }, true); }