mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 21:12:55 +08:00
Split out pinned comment content to only be constructed when required
This commit is contained in:
parent
4bbc98737f
commit
a5f6c287ea
@ -138,36 +138,13 @@ namespace osu.Game.Overlays.Comments
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(10, 0),
|
Spacing = new Vector2(10, 0),
|
||||||
Children = new Drawable[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold))
|
username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold))
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both
|
AutoSizeAxes = Axes.Both
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
Comment.Pinned ? new PinnedCommentNotice() : Empty(),
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(2, 0),
|
|
||||||
Alpha = Comment.Pinned ? 1 : 0,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SpriteIcon
|
|
||||||
{
|
|
||||||
Icon = FontAwesome.Solid.Thumbtack,
|
|
||||||
Size = new Vector2(14),
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
},
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold),
|
|
||||||
Text = CommentsStrings.Pinned,
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new ParentUsername(Comment),
|
new ParentUsername(Comment),
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
@ -346,9 +323,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
this.FadeTo(show.NewValue ? 1 : 0);
|
this.FadeTo(show.NewValue ? 1 : 0);
|
||||||
}, true);
|
}, true);
|
||||||
childrenExpanded.BindValueChanged(expanded => childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0), true);
|
childrenExpanded.BindValueChanged(expanded => childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0), true);
|
||||||
|
|
||||||
updateButtonsState();
|
updateButtonsState();
|
||||||
|
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,6 +392,33 @@ namespace osu.Game.Overlays.Comments
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class PinnedCommentNotice : FillFlowContainer
|
||||||
|
{
|
||||||
|
public PinnedCommentNotice()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Direction = FillDirection.Horizontal;
|
||||||
|
Spacing = new Vector2(2, 0);
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new SpriteIcon
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Solid.Thumbtack,
|
||||||
|
Size = new Vector2(14),
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold),
|
||||||
|
Text = CommentsStrings.Pinned,
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class ParentUsername : FillFlowContainer, IHasTooltip
|
private class ParentUsername : FillFlowContainer, IHasTooltip
|
||||||
{
|
{
|
||||||
public LocalisableString TooltipText => getParentMessage();
|
public LocalisableString TooltipText => getParentMessage();
|
||||||
|
Loading…
Reference in New Issue
Block a user