diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index a630c91..b799ab7 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -201,6 +201,9 @@ internal class Tab [NonSerialized] public InputChannel? PreviousChannel; + [NonSerialized] + public Guid Identifier = Guid.NewGuid(); + ~Tab() { MessagesMutex.Dispose(); } internal bool Contains(Message message) { diff --git a/ChatTwo/Message.cs b/ChatTwo/Message.cs index 8424321..ef1f858 100755 --- a/ChatTwo/Message.cs +++ b/ChatTwo/Message.cs @@ -67,8 +67,8 @@ internal class Message { // Not stored in the database: internal int Hash { get; } - internal float? Height { get; set; } - internal bool IsVisible { get; set; } + internal Dictionary Height { get; } = new(); + internal Dictionary IsVisible { get; } = new(); internal Message(ulong receiver, ChatCode code, List sender, List content, SeString senderSource, SeString contentSource) { Receiver = receiver; diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index f8c7c4a..a1a77cd 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -895,8 +895,8 @@ public sealed class ChatLogWindow : Window var message = tab.Messages[i]; if (reset) { - message.Height = null; - message.IsVisible = false; + message.Height[tab.Identifier] = null; + message.IsVisible[tab.Identifier] = false; } if (Plugin.Config.CollapseDuplicateMessages) @@ -933,7 +933,9 @@ public sealed class ChatLogWindow : Window // message has rendered once // message isn't visible, so render dummy - if (message is { Height: not null, IsVisible: false }) + message.Height.TryGetValue(tab.Identifier, out var height); + message.IsVisible.TryGetValue(tab.Identifier, out var visible); + if (height != null && !visible) { var beforeDummy = ImGui.GetCursorPos(); @@ -941,10 +943,10 @@ public sealed class ChatLogWindow : Window if (isTable) ImGui.TableNextColumn(); - ImGui.Dummy(new Vector2(10f, message.Height.Value)); - message.IsVisible = ImGui.IsItemVisible(); + ImGui.Dummy(new Vector2(10f, height.Value)); + message.IsVisible[tab.Identifier] = ImGui.IsItemVisible(); - if (message.IsVisible) + if (message.IsVisible[tab.Identifier]) { if (isTable) ImGui.TableSetColumnIndex(0); @@ -993,16 +995,16 @@ public sealed class ChatLogWindow : Window DrawChunks(message.Content, true, handler, lineWidth); var afterDraw = ImGui.GetCursorScreenPos(); - message.Height = ImGui.GetCursorPosY() - lastPos; + message.Height[tab.Identifier] = ImGui.GetCursorPosY() - lastPos; if (isTable && !moreCompact) { - message.Height -= oldCellPaddingY * 2; + message.Height[tab.Identifier] -= oldCellPaddingY * 2; beforeDraw.Y += oldCellPaddingY; afterDraw.Y -= oldCellPaddingY; } lastPos = ImGui.GetCursorPosY(); - message.IsVisible = ImGui.IsRectVisible(beforeDraw, afterDraw); + message.IsVisible[tab.Identifier] = ImGui.IsRectVisible(beforeDraw, afterDraw); } } finally