feat: add an option to hide redundant timestamps

This commit is contained in:
Anna 2022-02-18 13:47:31 -05:00
parent cddbd38109
commit d5bd8f4e22
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
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 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;

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>
/// Looks up a localized string similar to Hide {0} when you are not logged in to a character..
/// </summary>

View File

@ -476,4 +476,10 @@
<data name="ChatLog_Tabs_PopOut" xml:space="preserve">
<value>Pop out</value>
</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>

View File

@ -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,

View File

@ -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();
}