feat: add duplicate message collapsing
This commit is contained in:
+41
-3
@@ -671,12 +671,50 @@ internal sealed class ChatLog : IUiComponent {
|
||||
|
||||
var lastPos = ImGui.GetCursorPosY();
|
||||
var lastTimestamp = string.Empty;
|
||||
foreach (var message in tab.Messages) {
|
||||
int? lastMessageHash = null;
|
||||
var sameCount = 0;
|
||||
for (var i = 0; i < tab.Messages.Count; i++) {
|
||||
var message = tab.Messages[i];
|
||||
|
||||
if (reset) {
|
||||
message.Height = null;
|
||||
message.IsVisible = false;
|
||||
}
|
||||
|
||||
if (this.Ui.Plugin.Config.CollapseDuplicateMessages) {
|
||||
var messageHash = message.Hash;
|
||||
var same = lastMessageHash == messageHash;
|
||||
if (same) {
|
||||
sameCount += 1;
|
||||
|
||||
if (i != tab.Messages.Count - 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (sameCount > 0) {
|
||||
ImGui.SameLine();
|
||||
this.DrawChunks(
|
||||
new[] {
|
||||
new TextChunk(ChunkSource.None, null, $" ({sameCount + 1}x)") {
|
||||
FallbackColour = ChatType.System,
|
||||
Italic = true,
|
||||
},
|
||||
},
|
||||
true,
|
||||
handler,
|
||||
ImGui.GetContentRegionAvail().X
|
||||
);
|
||||
sameCount = 0;
|
||||
}
|
||||
|
||||
lastMessageHash = messageHash;
|
||||
|
||||
if (same && i == tab.Messages.Count - 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// go to next row
|
||||
if (table) {
|
||||
ImGui.TableNextColumn();
|
||||
@@ -924,13 +962,13 @@ internal sealed class ChatLog : IUiComponent {
|
||||
this._popOutDocked.Clear();
|
||||
this._popOutDocked.AddRange(Enumerable.Repeat(false, this.Ui.Plugin.Config.Tabs.Count));
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < this.Ui.Plugin.Config.Tabs.Count; i++) {
|
||||
var tab = this.Ui.Plugin.Config.Tabs[i];
|
||||
if (!tab.PopOut) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
this.DrawPopOut(tab, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ internal sealed class Display : ISettingsTab {
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref this.Mutable.CollapseDuplicateMessages, Language.Options_CollapseDuplicateMessages_Name, Language.Options_CollapseDuplicateMessages_Description);
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref this.Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description);
|
||||
ImGui.Spacing();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user