From 5812395c75fe25ad3e4261b6a3a0e5f30be30923 Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 15 Apr 2021 12:25:56 -0400 Subject: [PATCH] feat: add option to for timestamp visibility --- Peeping Tom/Configuration.cs | 3 ++- Peeping Tom/PluginUi.cs | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Peeping Tom/Configuration.cs b/Peeping Tom/Configuration.cs index d8eaf61..d4826e1 100644 --- a/Peeping Tom/Configuration.cs +++ b/Peeping Tom/Configuration.cs @@ -24,6 +24,7 @@ namespace PeepingTom { public bool KeepHistory { get; set; } = true; public bool HistoryWhenClosed { get; set; } = true; public int NumHistory { get; set; } = 5; + public bool ShowTimestamps { get; set; } = true; public bool LogParty { get; set; } = true; public bool LogAlliance { get; set; } @@ -31,7 +32,7 @@ namespace PeepingTom { public bool LogSelf { get; set; } public bool FocusTargetOnHover { get; set; } = true; - public bool OpenExamine { get; set; } = false; + public bool OpenExamine { get; set; } public bool PlaySoundOnTarget { get; set; } public string? SoundPath { get; set; } diff --git a/Peeping Tom/PluginUi.cs b/Peeping Tom/PluginUi.cs index a86ca01..f2ffe02 100644 --- a/Peeping Tom/PluginUi.cs +++ b/Peeping Tom/PluginUi.cs @@ -346,6 +346,12 @@ namespace PeepingTom { this.Plugin.Config.Save(); } + var showTimestamps = this.Plugin.Config.ShowTimestamps; + if (ImGui.Checkbox("Show timestamps", ref showTimestamps)) { + this.Plugin.Config.ShowTimestamps = showTimestamps; + this.Plugin.Config.Save(); + } + ImGui.EndTabItem(); } @@ -508,19 +514,21 @@ namespace PeepingTom { ImGui.Selectable(targeter.Name, false, flags); - var time = DateTime.UtcNow - targeter.When >= TimeSpan.FromDays(1) - ? targeter.When.ToLocalTime().ToString("dd/MM") - : targeter.When.ToLocalTime().ToString("t"); - ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize(time).X); + if (this.Plugin.Config.ShowTimestamps) { + var time = DateTime.UtcNow - targeter.When >= TimeSpan.FromDays(1) + ? targeter.When.ToLocalTime().ToString("dd/MM") + : targeter.When.ToLocalTime().ToString("t"); + ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize(time).X); - if (flags.HasFlag(ImGuiSelectableFlags.Disabled)) { - ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled]); - } + if (flags.HasFlag(ImGuiSelectableFlags.Disabled)) { + ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled]); + } - ImGui.TextUnformatted(time); + ImGui.TextUnformatted(time); - if (flags.HasFlag(ImGuiSelectableFlags.Disabled)) { - ImGui.PopStyleColor(); + if (flags.HasFlag(ImGuiSelectableFlags.Disabled)) { + ImGui.PopStyleColor(); + } } ImGui.EndGroup();