From 16a16b1f12c5ab2509e32955de00acd7c6a07c37 Mon Sep 17 00:00:00 2001 From: Infi Date: Wed, 14 Aug 2024 14:46:00 +0200 Subject: [PATCH] Implement #101 --- ChatTwo/ChatTwo.csproj | 2 +- ChatTwo/ChatTwo.yaml | 22 ++++------------------ ChatTwo/Configuration.cs | 2 ++ ChatTwo/Resources/Language.Designer.cs | 18 ++++++++++++++++++ ChatTwo/Resources/Language.resx | 6 ++++++ ChatTwo/Ui/ChatLogWindow.cs | 4 +++- ChatTwo/Ui/SettingsTabs/Display.cs | 2 ++ 7 files changed, 36 insertions(+), 20 deletions(-) diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index d84b9fb..fa990e4 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -1,6 +1,6 @@ - 1.28.1 + 1.28.2 net8.0-windows enable enable diff --git a/ChatTwo/ChatTwo.yaml b/ChatTwo/ChatTwo.yaml index 43e9969..1509b29 100755 --- a/ChatTwo/ChatTwo.yaml +++ b/ChatTwo/ChatTwo.yaml @@ -22,21 +22,7 @@ tags: - Chat - Replacement changelog: |- - **Fonts** - - Uses dalamud font chooser - - Italic font version can be chosen - - Config options related to fonts have been reset - - Old font names and sizes used are displayed for up to a month - - **LiteDB** - - Migration option removed - - Old files can still be deleted in the database tab - - **Keybinds** - - Avoids overriding modifiers after leaving a vanilla text box [thanks dean] - - This would prevent you from holding e.g. Ctrl between multiple vanilla text boxes - - Reworks linkshell rotation code to fix issues with LS number gaps causing linkshell rotation to not function [thanks dean] - - **Textures** - - Switch to dalamuds internal texture cache - - Role icons are now compatible with penumbra [thanks mopi] + **Misc** + - Implement 24-hour clock timestamp option [default false] + - Fix hide activity channels not being saved across sessions + - Loc updates diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index c03d9f8..257d81d 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -75,6 +75,7 @@ internal class Configuration : IPluginConfiguration public bool PlaySounds = true; public bool KeepInputFocus = true; public int MaxLinesToRender = 10_000; + public bool Use24HourClock; public bool ShowEmotes = true; public HashSet BlockedEmotes = []; @@ -163,6 +164,7 @@ internal class Configuration : IPluginConfiguration PlaySounds = other.PlaySounds; KeepInputFocus = other.KeepInputFocus; MaxLinesToRender = other.MaxLinesToRender; + Use24HourClock = other.Use24HourClock; ShowEmotes = other.ShowEmotes; BlockedEmotes = other.BlockedEmotes; FontsEnabled = other.FontsEnabled; diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index ef0a905..398cba5 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -3380,6 +3380,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Display timestamps as their 24-hour clock version.. + /// + internal static string Options_Use24HourClock_Description { + get { + return ResourceManager.GetString("Options_Use24HourClock_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 24-hour clock. + /// + internal static string Options_Use24HourClock_Name { + get { + return ResourceManager.GetString("Options_Use24HourClock_Name", resourceCulture); + } + } + /// /// Looks up a localized string similar to This feature isn't implemented yet. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 6b2f386..985171c 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -151,6 +151,12 @@ Display messages in a more modern style. + + 24-hour clock + + + Display timestamps as their 24-hour clock version. + More compact modern layout diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index d656613..6ea271a 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Globalization; using System.Numerics; using System.Runtime.InteropServices; using System.Text; @@ -1074,13 +1075,14 @@ public sealed class ChatLogWindow : Window if (tab.DisplayTimestamp) { - var timestamp = message.Date.ToLocalTime().ToString("t"); + var timestamp = message.Date.ToLocalTime().ToString("t", !Plugin.Config.Use24HourClock ? null : CultureInfo.CreateSpecificCulture("es-ES")); if (isTable) { if (!Plugin.Config.HideSameTimestamps || timestamp != lastTimestamp) { lastTimestamp = timestamp; ImGui.TextUnformatted(timestamp); + // We use an IsItemHovered() check here instead of // just calling SetTooltip() to avoid computing the // tooltip string for all visible items on every diff --git a/ChatTwo/Ui/SettingsTabs/Display.cs b/ChatTwo/Ui/SettingsTabs/Display.cs index 4446578..b0fe899 100755 --- a/ChatTwo/Ui/SettingsTabs/Display.cs +++ b/ChatTwo/Ui/SettingsTabs/Display.cs @@ -96,6 +96,8 @@ internal sealed class Display : ISettingsTab ImGui.Separator(); ImGui.Spacing(); + ImGuiUtil.OptionCheckbox(ref Mutable.Use24HourClock, Language.Options_Use24HourClock_Name, Language.Options_Use24HourClock_Description); + ImGuiUtil.OptionCheckbox(ref Mutable.PrettierTimestamps, Language.Options_PrettierTimestamps_Name, Language.Options_PrettierTimestamps_Description); if (Mutable.PrettierTimestamps)