mirror of
https://github.com/osukey/osukey.git
synced 2025-06-07 20:37:57 +09: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.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -46,6 +47,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private Container<DrawableChannel> currentChannelContainer;
|
private Container<DrawableChannel> currentChannelContainer;
|
||||||
|
|
||||||
|
private DrawableChannel currentDrawableChannel => currentChannelContainer.SingleOrDefault();
|
||||||
|
|
||||||
private readonly List<DrawableChannel> loadedChannels = new List<DrawableChannel>();
|
private readonly List<DrawableChannel> loadedChannels = new List<DrawableChannel>();
|
||||||
|
|
||||||
private LoadingSpinner loading;
|
private LoadingSpinner loading;
|
||||||
@ -249,6 +252,9 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private Bindable<Channel> currentChannel;
|
private Bindable<Channel> currentChannel;
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
private Message messagePendingHighlight;
|
||||||
|
|
||||||
private void currentChannelChanged(ValueChangedEvent<Channel> e)
|
private void currentChannelChanged(ValueChangedEvent<Channel> e)
|
||||||
{
|
{
|
||||||
if (e.NewValue == null)
|
if (e.NewValue == null)
|
||||||
@ -290,12 +296,24 @@ namespace osu.Game.Overlays
|
|||||||
currentChannelContainer.Clear(false);
|
currentChannelContainer.Clear(false);
|
||||||
currentChannelContainer.Add(loaded);
|
currentChannelContainer.Add(loaded);
|
||||||
currentChannelContainer.FadeIn(500, Easing.OutQuint);
|
currentChannelContainer.FadeIn(500, Easing.OutQuint);
|
||||||
|
|
||||||
|
if (messagePendingHighlight != null)
|
||||||
|
{
|
||||||
|
tryHighlightMessage(messagePendingHighlight);
|
||||||
|
messagePendingHighlight = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentChannelContainer.Clear(false);
|
currentChannelContainer.Clear(false);
|
||||||
currentChannelContainer.Add(loaded);
|
currentChannelContainer.Add(loaded);
|
||||||
|
|
||||||
|
if (messagePendingHighlight != null)
|
||||||
|
{
|
||||||
|
tryHighlightMessage(messagePendingHighlight);
|
||||||
|
messagePendingHighlight = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark channel as read when channel switched
|
// mark channel as read when channel switched
|
||||||
@ -303,6 +321,29 @@ namespace osu.Game.Overlays
|
|||||||
channelManager.MarkChannelAsRead(e.NewValue);
|
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 float startDragChatHeight;
|
||||||
private bool isDragging;
|
private bool isDragging;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user