mirror of
https://github.com/ppy/osu
synced 2025-01-25 23:32:58 +00:00
Instantiate highlight background container on animation
Also removes the necessity of scheduling as it actually never worked as intended, `Scheduler` will still update even when the chat line is masked away, and the animation will never be held anyways. The new duration of the animation should be enough for long scrolls either way.
This commit is contained in:
parent
d4de435eb2
commit
b25c37ce62
@ -42,8 +42,6 @@ namespace osu.Game.Overlays.Chat
|
||||
|
||||
protected virtual float TextSize => 20;
|
||||
|
||||
private Container lineHighlightBackground;
|
||||
|
||||
private Color4 usernameColour;
|
||||
|
||||
private OsuSpriteText timestamp;
|
||||
@ -146,15 +144,6 @@ namespace osu.Game.Overlays.Chat
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
lineHighlightBackground = new Container
|
||||
{
|
||||
Alpha = 0f,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = usernameColour.Darken(1f),
|
||||
CornerRadius = 2f,
|
||||
Masking = true,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Size = new Vector2(MessagePadding, TextSize),
|
||||
@ -214,13 +203,29 @@ namespace osu.Game.Overlays.Chat
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private Container highlight;
|
||||
|
||||
/// <summary>
|
||||
/// Schedules a message highlight animation.
|
||||
/// Performs a highlight animation on this <see cref="ChatLine"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Scheduling is required to ensure the animation doesn't play until the chat line is in view and not scrolled away.
|
||||
/// </remarks>
|
||||
public void ScheduleHighlight() => Schedule(() => lineHighlightBackground.FadeTo(0.5f).FadeOut(1500, Easing.InQuint));
|
||||
public void Highlight()
|
||||
{
|
||||
if (highlight?.IsAlive != true)
|
||||
{
|
||||
AddInternal(highlight = new Container
|
||||
{
|
||||
CornerRadius = 2f,
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = usernameColour.Darken(1f),
|
||||
Depth = float.MaxValue,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
});
|
||||
}
|
||||
|
||||
highlight.FadeTo(0.5f).FadeOut(1500, Easing.InQuint);
|
||||
highlight.Expire();
|
||||
}
|
||||
|
||||
private void updateMessageContent()
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ namespace osu.Game.Overlays.Chat
|
||||
{
|
||||
float center = scroll.GetChildPosInContent(chatLine, chatLine.DrawSize / 2) - scroll.DisplayableContent / 2;
|
||||
scroll.ScrollTo(Math.Clamp(center, 0, scroll.ScrollableExtent));
|
||||
chatLine.ScheduleHighlight();
|
||||
chatLine.Highlight();
|
||||
}
|
||||
|
||||
highlightedMessage.Value = null;
|
||||
|
Loading…
Reference in New Issue
Block a user