1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 05:53:20 +08:00

Avoid showing timestamp in chat line when repeated

This commit is contained in:
Dean Herbert 2024-07-30 16:59:32 +09:00
parent e63080eb2e
commit a2a73232f3
No known key found for this signature in database
2 changed files with 35 additions and 2 deletions

View File

@ -71,6 +71,25 @@ namespace osu.Game.Overlays.Chat
private Drawable? background;
private bool alternatingBackground;
private bool requiresTimestamp = true;
public bool RequiresTimestamp
{
get => requiresTimestamp;
set
{
if (requiresTimestamp == value)
return;
requiresTimestamp = value;
if (!IsLoaded)
return;
updateMessageContent();
}
}
public bool AlternatingBackground
{
@ -244,9 +263,17 @@ namespace osu.Game.Overlays.Chat
private void updateMessageContent()
{
this.FadeTo(message is LocalEchoMessage ? 0.4f : 1.0f, 500, Easing.OutQuint);
drawableTimestamp.FadeTo(message is LocalEchoMessage ? 0 : 1, 500, Easing.OutQuint);
updateTimestamp();
if (requiresTimestamp && !(message is LocalEchoMessage))
{
drawableTimestamp.Show();
updateTimestamp();
}
else
{
drawableTimestamp.Hide();
}
drawableUsername.Text = $@"{message.Sender.Username}";
// remove non-existent channels from the link list

View File

@ -88,10 +88,16 @@ namespace osu.Game.Overlays.Chat
{
base.Update();
int? minute = null;
for (int i = 0; i < ChatLineFlow.Count; i++)
{
if (ChatLineFlow[i] is ChatLine chatline)
{
chatline.AlternatingBackground = i % 2 == 0;
chatline.RequiresTimestamp = chatline.Message.Timestamp.Minute != minute;
minute = chatline.Message.Timestamp.Minute;
}
}
}