Merge pull request #44

* fix: various bug fixes
This commit is contained in:
Dean Sheather
2024-05-12 17:56:53 -07:00
committed by GitHub
parent 23ba24314b
commit dba01de388
2 changed files with 20 additions and 3 deletions
+6 -2
View File
@@ -72,7 +72,9 @@ public class TextChunk : Chunk
internal TextChunk(ChunkSource source, Payload? link, string content) : base(source, link) internal TextChunk(ChunkSource source, Payload? link, string content) : base(source, link)
{ {
Content = content; // This has been null in the past, and it broke rendering code.
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
Content = content ?? "";
} }
// ReSharper disable once UnusedMember.Global // Used by MessagePack // ReSharper disable once UnusedMember.Global // Used by MessagePack
@@ -82,7 +84,9 @@ public class TextChunk : Chunk
Foreground = foreground; Foreground = foreground;
Glow = glow; Glow = glow;
Italic = italic; Italic = italic;
Content = content; // See above.
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
Content = content ?? "";
} }
/// <summary> /// <summary>
+14 -1
View File
@@ -1012,6 +1012,10 @@ public sealed class ChatLogWindow : Window
ImGui.TextUnformatted(timestamp); ImGui.TextUnformatted(timestamp);
lastTimestamp = timestamp; lastTimestamp = timestamp;
} }
else
// Avoids rendering issues caused by emojis in
// message content.
ImGui.TextUnformatted("");
} }
else else
{ {
@@ -1480,8 +1484,12 @@ public sealed class ChatLogWindow : Window
internal void DrawChunks(IReadOnlyList<Chunk> chunks, bool wrap = true, PayloadHandler? handler = null, float lineWidth = 0f) internal void DrawChunks(IReadOnlyList<Chunk> chunks, bool wrap = true, PayloadHandler? handler = null, float lineWidth = 0f)
{ {
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero); using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
for (var i = 0; i < chunks.Count; i++) 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); DrawChunk(chunks[i], wrap, handler, lineWidth);
if (i < chunks.Count - 1) if (i < chunks.Count - 1)
@@ -1556,7 +1564,12 @@ public sealed class ChatLogWindow : Window
// Check for contains here as sometimes there are multiple // Check for contains here as sometimes there are multiple
// TextChunks with the same PlayerPayload but only one has the name. // TextChunks with the same PlayerPayload but only one has the name.
// E.g. party chat with cross world players adds extra chunks. // E.g. party chat with cross world players adds extra chunks.
var content = text.Content; //
// Note: This has been null before, I'm guessing due to some issues with
// other plugins. New TextChunks will now enforce empty string in ctor,
// but old ones may still be null.
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
var content = text.Content ?? "";
if (ScreenshotMode) if (ScreenshotMode)
{ {
if (chunk.Link is PlayerPayload playerPayload && content.Contains(playerPayload.PlayerName)) if (chunk.Link is PlayerPayload playerPayload && content.Contains(playerPayload.PlayerName))