1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:42:54 +08:00

Fix background alternating not updating on message removal

This commit is contained in:
Dean Herbert 2024-07-29 20:25:02 +09:00
parent 997b3eb498
commit 5bc02cc1c6
No known key found for this signature in database
2 changed files with 15 additions and 12 deletions

View File

@ -77,6 +77,9 @@ namespace osu.Game.Overlays.Chat
get => alternatingBackground;
set
{
if (alternatingBackground == value)
return;
alternatingBackground = value;
updateBackground();
}
@ -122,6 +125,7 @@ namespace osu.Game.Overlays.Chat
Masking = true,
Blending = BlendingParameters.Additive,
CornerRadius = 4,
Alpha = 0,
RelativeSizeAxes = Axes.Both,
Child = new Box
{

View File

@ -84,6 +84,17 @@ namespace osu.Game.Overlays.Chat
highlightedMessage.BindValueChanged(_ => processMessageHighlighting(), true);
}
protected override void Update()
{
base.Update();
for (int i = 0; i < ChatLineFlow.Count; i++)
{
if (ChatLineFlow[i] is ChatLine chatline)
chatline.AlternatingBackground = i % 2 == 0;
}
}
/// <summary>
/// Processes any pending message in <see cref="highlightedMessage"/>.
/// </summary>
@ -104,17 +115,6 @@ namespace osu.Game.Overlays.Chat
highlightedMessage.Value = null;
});
private void updateBackgroundAlternating()
{
for (int i = 0; i < ChatLineFlow.Count; i++)
{
if (ChatLineFlow[i] is ChatLine chatline)
{
chatline.AlternatingBackground = i % 2 == 0;
}
}
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
@ -169,7 +169,6 @@ namespace osu.Game.Overlays.Chat
scroll.ScrollToEnd();
processMessageHighlighting();
updateBackgroundAlternating();
});
private void pendingMessageResolved(Message existing, Message updated) => Schedule(() =>