feat: add an option to hide redundant timestamps

This commit is contained in:
Anna 2022-02-18 13:47:31 -05:00
parent 04783fcf02
commit 048826baed
5 changed files with 32 additions and 1 deletions

View File

@ -19,6 +19,7 @@ internal class Configuration : IPluginConfiguration {
public bool NativeItemTooltips = true; public bool NativeItemTooltips = true;
public bool PrettierTimestamps = true; public bool PrettierTimestamps = true;
public bool MoreCompactPretty; public bool MoreCompactPretty;
public bool HideSameTimestamps;
public bool ShowNoviceNetwork; public bool ShowNoviceNetwork;
public bool SidebarTabView; public bool SidebarTabView;
public CommandHelpSide CommandHelpSide = CommandHelpSide.None; public CommandHelpSide CommandHelpSide = CommandHelpSide.None;
@ -50,6 +51,7 @@ internal class Configuration : IPluginConfiguration {
this.NativeItemTooltips = other.NativeItemTooltips; this.NativeItemTooltips = other.NativeItemTooltips;
this.PrettierTimestamps = other.PrettierTimestamps; this.PrettierTimestamps = other.PrettierTimestamps;
this.MoreCompactPretty = other.MoreCompactPretty; this.MoreCompactPretty = other.MoreCompactPretty;
this.HideSameTimestamps = other.HideSameTimestamps;
this.ShowNoviceNetwork = other.ShowNoviceNetwork; this.ShowNoviceNetwork = other.ShowNoviceNetwork;
this.SidebarTabView = other.SidebarTabView; this.SidebarTabView = other.SidebarTabView;
this.CommandHelpSide = other.CommandHelpSide; this.CommandHelpSide = other.CommandHelpSide;

View File

@ -564,6 +564,24 @@ namespace ChatTwo.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Hide timestamps when previous messages have the same timestamp..
/// </summary>
internal static string Options_HideSameTimestamps_Description {
get {
return ResourceManager.GetString("Options_HideSameTimestamps_Description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hide timestamps when redundant.
/// </summary>
internal static string Options_HideSameTimestamps_Name {
get {
return ResourceManager.GetString("Options_HideSameTimestamps_Name", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Hide {0} when you are not logged in to a character.. /// Looks up a localized string similar to Hide {0} when you are not logged in to a character..
/// </summary> /// </summary>

View File

@ -476,4 +476,10 @@
<data name="ChatLog_Tabs_PopOut" xml:space="preserve"> <data name="ChatLog_Tabs_PopOut" xml:space="preserve">
<value>Pop out</value> <value>Pop out</value>
</data> </data>
<data name="Options_HideSameTimestamps_Name" xml:space="preserve">
<value>Hide timestamps when redundant</value>
</data>
<data name="Options_HideSameTimestamps_Description" xml:space="preserve">
<value>Hide timestamps when previous messages have the same timestamp.</value>
</data>
</root> </root>

View File

@ -623,6 +623,7 @@ internal sealed class ChatLog : IUiComponent {
} }
var lastPos = ImGui.GetCursorPosY(); var lastPos = ImGui.GetCursorPosY();
var lastTimestamp = string.Empty;
foreach (var message in tab.Messages) { foreach (var message in tab.Messages) {
if (reset) { if (reset) {
message.Height = null; message.Height = null;
@ -663,7 +664,10 @@ internal sealed class ChatLog : IUiComponent {
if (tab.DisplayTimestamp) { if (tab.DisplayTimestamp) {
var timestamp = message.Date.ToLocalTime().ToString("t"); var timestamp = message.Date.ToLocalTime().ToString("t");
if (table) { if (table) {
ImGui.TextUnformatted(timestamp); if (!this.Ui.Plugin.Config.HideSameTimestamps || timestamp != lastTimestamp) {
ImGui.TextUnformatted(timestamp);
lastTimestamp = timestamp;
}
} else { } else {
this.DrawChunk(new TextChunk(ChunkSource.None, null, $"[{timestamp}]") { this.DrawChunk(new TextChunk(ChunkSource.None, null, $"[{timestamp}]") {
Foreground = 0xFFFFFFFF, Foreground = 0xFFFFFFFF,

View File

@ -59,6 +59,7 @@ internal sealed class Display : ISettingsTab {
if (this.Mutable.PrettierTimestamps) { if (this.Mutable.PrettierTimestamps) {
ImGui.TreePush(); ImGui.TreePush();
ImGuiUtil.OptionCheckbox(ref this.Mutable.MoreCompactPretty, Language.Options_MoreCompactPretty_Name, Language.Options_MoreCompactPretty_Description); 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(); ImGui.TreePop();
} }