diff --git a/ChatTwo/Message.cs b/ChatTwo/Message.cs index 8f144c1..a02e673 100755 --- a/ChatTwo/Message.cs +++ b/ChatTwo/Message.cs @@ -135,8 +135,11 @@ internal class Message private List CheckMessageContent(List oldChunks) { var newChunks = new List(); - void AddChunkWithMessage(Chunk chunk) + void AddChunkWithMessage(TextChunk chunk) { + if (string.IsNullOrEmpty(chunk.Content)) + return; + chunk.Message = this; newChunks.Add(chunk); } @@ -198,7 +201,7 @@ internal class Message AddContentAfterURLCheck(builder.ToString(), text, chunk); builder.Clear(); - newChunks.Add(new TextChunk(chunk.Source, EmotePayload.ResolveEmote(word), word)); + AddChunkWithMessage(new TextChunk(chunk.Source, EmotePayload.ResolveEmote(word), word)); builder.Append(' '); continue; } diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index a81ffc7..aab70e2 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -1015,7 +1015,7 @@ public sealed class ChatLogWindow : Window } else { - DrawChunk(new TextChunk(ChunkSource.None, null, $"[{timestamp}]") { Foreground = 0xFFFFFFFF, }); + DrawChunk(new TextChunk(ChunkSource.None, null, $"[{timestamp}] ") { Foreground = 0xFFFFFFFF, }); ImGui.SameLine(); } } @@ -1482,13 +1482,17 @@ public sealed class ChatLogWindow : Window using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero); for (var i = 0; i < chunks.Count; i++) { - if (chunks[i] is TextChunk text && string.IsNullOrEmpty(text.Content)) - continue; - DrawChunk(chunks[i], wrap, handler, lineWidth); if (i < chunks.Count - 1) ImGui.SameLine(); + else if (chunks[i].Link is EmotePayload) { + // Emote payloads seem to not automatically put newlines, which + // is an issue when modern mode is disabled. + ImGui.SameLine(); + // Use default ImGui behavior for newlines. + ImGui.TextUnformatted(""); + } } } @@ -1517,17 +1521,17 @@ public sealed class ChatLogWindow : Window if (chunk is not TextChunk text) return; - if (chunk.Link?.Type == (PayloadType)0x53) + if (chunk.Link is EmotePayload emotePayload) { var emoteSize = ImGui.CalcTextSize("W"); emoteSize = emoteSize with { Y = emoteSize.X } * 1.5f; - var emotePayload = (EmotePayload) chunk.Link; var image = EmoteCache.GetEmote(emotePayload.Code); if (image is { IsLoaded: true }) image.Draw(emoteSize); else ImGui.Dummy(emoteSize); + ImGui.SetTooltip(emotePayload.Code); return; }