1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 16:25:32 +08:00

Implement chatline background altering

This commit is contained in:
normalid 2024-07-27 17:25:44 +08:00
parent 565107205c
commit c2711d0c4e
2 changed files with 31 additions and 0 deletions

View File

@ -69,6 +69,29 @@ namespace osu.Game.Overlays.Chat
private Container? highlight;
private Drawable? background;
private bool alteringBackground;
public bool AlteringBackground
{
get => alteringBackground;
set
{
alteringBackground = value;
if (background == null)
AddInternal(background = new Box
{
BypassAutoSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
});
background.Alpha = value ? 0.04f : 0f;
}
}
/// <summary>
/// The colour used to paint the author's username.
/// </summary>

View File

@ -104,6 +104,13 @@ namespace osu.Game.Overlays.Chat
highlightedMessage.Value = null;
});
private void processMessageBackgroundAltering()
{
for (int i = 0; i < ChatLineFlow.Count(); i++)
if (ChatLineFlow[i] is ChatLine chatline)
chatline.AlteringBackground = i % 2 == 0;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
@ -158,6 +165,7 @@ namespace osu.Game.Overlays.Chat
scroll.ScrollToEnd();
processMessageHighlighting();
processMessageBackgroundAltering();
});
private void pendingMessageResolved(Message existing, Message updated) => Schedule(() =>