mirror of
https://github.com/ppy/osu.git
synced 2025-03-22 22:17:46 +08:00
Add support to highlight messages in chat overlay
This commit is contained in:
parent
cb2133944d
commit
f4fa80c1e3
@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
@ -46,6 +47,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
private Container<DrawableChannel> currentChannelContainer;
|
||||
|
||||
private DrawableChannel currentDrawableChannel => currentChannelContainer.SingleOrDefault();
|
||||
|
||||
private readonly List<DrawableChannel> loadedChannels = new List<DrawableChannel>();
|
||||
|
||||
private LoadingSpinner loading;
|
||||
@ -249,6 +252,9 @@ namespace osu.Game.Overlays
|
||||
|
||||
private Bindable<Channel> currentChannel;
|
||||
|
||||
[CanBeNull]
|
||||
private Message messagePendingHighlight;
|
||||
|
||||
private void currentChannelChanged(ValueChangedEvent<Channel> e)
|
||||
{
|
||||
if (e.NewValue == null)
|
||||
@ -290,12 +296,24 @@ namespace osu.Game.Overlays
|
||||
currentChannelContainer.Clear(false);
|
||||
currentChannelContainer.Add(loaded);
|
||||
currentChannelContainer.FadeIn(500, Easing.OutQuint);
|
||||
|
||||
if (messagePendingHighlight != null)
|
||||
{
|
||||
tryHighlightMessage(messagePendingHighlight);
|
||||
messagePendingHighlight = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
currentChannelContainer.Clear(false);
|
||||
currentChannelContainer.Add(loaded);
|
||||
|
||||
if (messagePendingHighlight != null)
|
||||
{
|
||||
tryHighlightMessage(messagePendingHighlight);
|
||||
messagePendingHighlight = null;
|
||||
}
|
||||
}
|
||||
|
||||
// mark channel as read when channel switched
|
||||
@ -303,6 +321,29 @@ namespace osu.Game.Overlays
|
||||
channelManager.MarkChannelAsRead(e.NewValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Highlights a certain message in the specified channel.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to highlight.</param>
|
||||
public void HighlightMessage(Message message)
|
||||
{
|
||||
if (currentDrawableChannel?.Channel.Id == message.ChannelId)
|
||||
tryHighlightMessage(message);
|
||||
else
|
||||
{
|
||||
messagePendingHighlight = message;
|
||||
currentChannel.Value = channelManager.JoinedChannels.Single(c => c.Id == message.ChannelId);
|
||||
}
|
||||
}
|
||||
|
||||
private void tryHighlightMessage(Message message)
|
||||
{
|
||||
if (message.ChannelId != currentChannel.Value.Id)
|
||||
return;
|
||||
|
||||
currentDrawableChannel.HighlightMessage(message);
|
||||
}
|
||||
|
||||
private float startDragChatHeight;
|
||||
private bool isDragging;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user