From d5bd8f4e2240045c2b806710ca961d1745235ff0 Mon Sep 17 00:00:00 2001 From: Anna Clemens Date: Fri, 18 Feb 2022 13:47:31 -0500 Subject: [PATCH] feat: add an option to hide redundant timestamps --- ChatTwo/Configuration.cs | 2 ++ ChatTwo/Resources/Language.Designer.cs | 18 ++++++++++++++++++ ChatTwo/Resources/Language.resx | 6 ++++++ ChatTwo/Ui/ChatLog.cs | 6 +++++- ChatTwo/Ui/SettingsTabs/Display.cs | 1 + 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index 00d441b..419d590 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -19,6 +19,7 @@ internal class Configuration : IPluginConfiguration { public bool NativeItemTooltips = true; public bool PrettierTimestamps = true; public bool MoreCompactPretty; + public bool HideSameTimestamps; public bool ShowNoviceNetwork; public bool SidebarTabView; public CommandHelpSide CommandHelpSide = CommandHelpSide.None; @@ -50,6 +51,7 @@ internal class Configuration : IPluginConfiguration { this.NativeItemTooltips = other.NativeItemTooltips; this.PrettierTimestamps = other.PrettierTimestamps; this.MoreCompactPretty = other.MoreCompactPretty; + this.HideSameTimestamps = other.HideSameTimestamps; this.ShowNoviceNetwork = other.ShowNoviceNetwork; this.SidebarTabView = other.SidebarTabView; this.CommandHelpSide = other.CommandHelpSide; diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index 04c26aa..10e7363 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -564,6 +564,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Hide timestamps when previous messages have the same timestamp.. + /// + internal static string Options_HideSameTimestamps_Description { + get { + return ResourceManager.GetString("Options_HideSameTimestamps_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide timestamps when redundant. + /// + internal static string Options_HideSameTimestamps_Name { + get { + return ResourceManager.GetString("Options_HideSameTimestamps_Name", resourceCulture); + } + } + /// /// Looks up a localized string similar to Hide {0} when you are not logged in to a character.. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 4a7c25a..0ef6b7f 100755 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -476,4 +476,10 @@ Pop out + + Hide timestamps when redundant + + + Hide timestamps when previous messages have the same timestamp. + diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index b90c134..239eb27 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -623,6 +623,7 @@ internal sealed class ChatLog : IUiComponent { } var lastPos = ImGui.GetCursorPosY(); + var lastTimestamp = string.Empty; foreach (var message in tab.Messages) { if (reset) { message.Height = null; @@ -663,7 +664,10 @@ internal sealed class ChatLog : IUiComponent { if (tab.DisplayTimestamp) { var timestamp = message.Date.ToLocalTime().ToString("t"); if (table) { - ImGui.TextUnformatted(timestamp); + if (!this.Ui.Plugin.Config.HideSameTimestamps || timestamp != lastTimestamp) { + ImGui.TextUnformatted(timestamp); + lastTimestamp = timestamp; + } } else { this.DrawChunk(new TextChunk(ChunkSource.None, null, $"[{timestamp}]") { Foreground = 0xFFFFFFFF, diff --git a/ChatTwo/Ui/SettingsTabs/Display.cs b/ChatTwo/Ui/SettingsTabs/Display.cs index 830691d..f246f17 100755 --- a/ChatTwo/Ui/SettingsTabs/Display.cs +++ b/ChatTwo/Ui/SettingsTabs/Display.cs @@ -59,6 +59,7 @@ internal sealed class Display : ISettingsTab { if (this.Mutable.PrettierTimestamps) { ImGui.TreePush(); ImGuiUtil.OptionCheckbox(ref this.Mutable.MoreCompactPretty, Language.Options_MoreCompactPretty_Name, Language.Options_MoreCompactPretty_Description); + ImGuiUtil.OptionCheckbox(ref this.Mutable.HideSameTimestamps, Language.Options_HideSameTimestamps_Name, Language.Options_HideSameTimestamps_Description); ImGui.TreePop(); }