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:
parent
e63080eb2e
commit
a2a73232f3
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user