From c91858183a22c5272e75ad226fa376ec356d9514 Mon Sep 17 00:00:00 2001 From: Infi Date: Wed, 22 May 2024 03:39:31 +0200 Subject: [PATCH] Add changelog tab --- ChatTwo/ChatTwo.csproj | 2 +- ChatTwo/ChatTwo.yaml | 31 +++++++++++++++ ChatTwo/Configuration.cs | 2 + ChatTwo/Message.cs | 5 ++- ChatTwo/Resources/Language.Designer.cs | 55 +++++++++++++++++++++++--- ChatTwo/Resources/Language.resx | 25 +++++++++--- ChatTwo/Ui/Settings.cs | 1 + ChatTwo/Ui/SettingsTabs/Changelog.cs | 51 ++++++++++++++++++++++++ 8 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 ChatTwo/Ui/SettingsTabs/Changelog.cs diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index 55af37d..71cea50 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -1,6 +1,6 @@ - 1.25.1 + 1.25.2 net8.0-windows enable enable diff --git a/ChatTwo/ChatTwo.yaml b/ChatTwo/ChatTwo.yaml index 08c9a6e..ee582f6 100755 --- a/ChatTwo/ChatTwo.yaml +++ b/ChatTwo/ChatTwo.yaml @@ -21,3 +21,34 @@ tags: - UI - Chat - Replacement +changelog: |- + **New** + - Changelog tab + - Shows the latest changelog + - Has an option to disable printing of changelogs to chat + + **Message Preview** + - Message preview has now its own config tab + - Added a new position: Tooltip + - Shows up while hovering the input box + - This won't support the letter selection or any of the hover features + - Added option to set a minimum length before message preview appears + - Added option to only show preview if special parameter are used (, emotes...) + - Selectable letters in message preview + - Click on any letter and the text cursor will jump to its position + - Better word wrapping in message preview + + **Fixes** + - Prevent rare null reference on plugin load + - Prevent null strings from being parsed + - Parsing of emotes works with punctuation and non latin letters surrounding it + + **Future Updates** + - Message preview will receive numerous features over the next weeks + - More parameter will be supported ( ...) + - Better customization (Position it anywhere) + - Feedback is always welcome + - If you want to disable this feature all together, visit the Preview tab in your config + - Fix for dalamuds welcome messages getting shuffled + - Message history viewer, going above the 10,000 that chat2 can display at once + diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index 766317f..9c280b4 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -25,6 +25,7 @@ internal class Configuration : IPluginConfiguration public bool HideSameTimestamps; public bool ShowNoviceNetwork; public bool SidebarTabView; + public bool PrintChangelog = true; public bool OnlyPreviewIf; public int PreviewMinimum = 1; public PreviewPosition PreviewPosition = PreviewPosition.Inside; @@ -81,6 +82,7 @@ internal class Configuration : IPluginConfiguration HideSameTimestamps = other.HideSameTimestamps; ShowNoviceNetwork = other.ShowNoviceNetwork; SidebarTabView = other.SidebarTabView; + PrintChangelog = other.PrintChangelog; OnlyPreviewIf = other.OnlyPreviewIf; PreviewMinimum = other.PreviewMinimum; PreviewPosition = other.PreviewPosition; diff --git a/ChatTwo/Message.cs b/ChatTwo/Message.cs index 42209c6..d56bec6 100755 --- a/ChatTwo/Message.cs +++ b/ChatTwo/Message.cs @@ -4,6 +4,7 @@ using ChatTwo.Util; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using System.Text.RegularExpressions; +using Dalamud.Game.Text; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using LiteDB; @@ -292,7 +293,7 @@ internal partial class Message ? Plugin.DataManager.GetExcelSheet()!.GetRow(item.ItemID)!.Name.ToString() : Plugin.DataManager.GetExcelSheet()!.GetRow(item.ItemID)!.Name.ToString(); - var link = new ItemPayload(item.ItemID, kind, name); + var link = new ItemPayload(item.ItemID, kind, $"{SeIconChar.LinkMarker.ToIconChar()}{name}"); AddChunkWithMessage(text.NewWithStyle(chunk.Source, link, link.DisplayName ?? "Unknown")); } else @@ -309,7 +310,7 @@ internal partial class Message var rawY = (int)(MathF.Round(mapCoords.YFloat, 3, MidpointRounding.AwayFromZero) * 1000); var link = new MapLinkPayload(mapCoords.TerritoryId, mapCoords.MapId, rawX, rawY); - AddChunkWithMessage(text.NewWithStyle(chunk.Source, link, $"{link.PlaceName} {link.CoordinateString}")); + AddChunkWithMessage(text.NewWithStyle(chunk.Source, link, $"{SeIconChar.LinkMarker.ToIconChar()}{link.PlaceName} {link.CoordinateString}")); } } diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index 455a60f..021c07e 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -1598,6 +1598,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Changelog:. + /// + internal static string Options_Changelog_Header { + get { + return ResourceManager.GetString("Options_Changelog_Header", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Changelog. + /// + internal static string Options_Changelog_Tab { + get { + return ResourceManager.GetString("Options_Changelog_Tab", resourceCulture); + } + } + /// /// Looks up a localized string similar to Import from game. /// @@ -2175,7 +2193,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Keeps the input focus, even if you enter battle or do other actions. + /// Looks up a localized string similar to Keeps the input focus, even if you enter battle or do other actions.. /// internal static string Options_KeepInputFocus_Description { get { @@ -2400,7 +2418,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Displays a preview with special parameter evaluated, like emotes and <item>. + /// Looks up a localized string similar to Displays a preview with special parameter evaluated, like emotes and <item>.. /// internal static string Options_Preview_Description { get { @@ -2472,7 +2490,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Only show if the text length is greater-than or equal. + /// Looks up a localized string similar to Only show if the text length is greater-than or equal.. /// internal static string Options_PreviewMinimum_Description { get { @@ -2490,7 +2508,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Only show if the text contains special parameter. + /// Looks up a localized string similar to Only show if the text contains special parameter.. /// internal static string Options_PreviewOnlyIf_Description { get { @@ -2508,7 +2526,25 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Replaces words with their emote version, currently supports BetterTTV. + /// Looks up a localized string similar to Print the changelog to chat after an update.. + /// + internal static string Options_PrintChangelog_Description { + get { + return ResourceManager.GetString("Options_PrintChangelog_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Print changelog. + /// + internal static string Options_PrintChangelog_Name { + get { + return ResourceManager.GetString("Options_PrintChangelog_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Replaces words with their emote version, currently supports BetterTTV.. /// internal static string Options_ShowEmotes_Desc { get { @@ -2840,6 +2876,15 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to This feature isn't implemented yet. + /// + internal static string Options_Warning_NotImplemented { + get { + return ResourceManager.GetString("Options_Warning_NotImplemented", resourceCulture); + } + } + /// /// Looks up a localized string similar to Window opacity. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 1208af4..41b52f3 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -1016,13 +1016,13 @@ Keep input focus - Keeps the input focus, even if you enter battle or do other actions + Keeps the input focus, even if you enter battle or do other actions. Show emotes - Replaces words with their emote version, currently supports BetterTTV + Replaces words with their emote version, currently supports BetterTTV. Emotes @@ -1052,7 +1052,7 @@ Emotes available: - Displays a preview with special parameter evaluated, like emotes and <item> + Displays a preview with special parameter evaluated, like emotes and <item>. Position (None = off) @@ -1079,15 +1079,30 @@ Must contain parameter - Only show if the text contains special parameter + Only show if the text contains special parameter. Minimum input length - Only show if the text length is greater-than or equal + Only show if the text length is greater-than or equal. Preview + + Changelog + + + Print changelog + + + Print the changelog to chat after an update. + + + This feature isn't implemented yet + + + Changelog: + diff --git a/ChatTwo/Ui/Settings.cs b/ChatTwo/Ui/Settings.cs index 95e2110..d19b17c 100755 --- a/ChatTwo/Ui/Settings.cs +++ b/ChatTwo/Ui/Settings.cs @@ -42,6 +42,7 @@ public sealed class SettingsWindow : Window new Tabs(Plugin, Mutable), new Database(Plugin, Mutable), new Miscellaneous(Mutable), + new Changelog(Mutable), new About(), }; diff --git a/ChatTwo/Ui/SettingsTabs/Changelog.cs b/ChatTwo/Ui/SettingsTabs/Changelog.cs new file mode 100644 index 0000000..adcd823 --- /dev/null +++ b/ChatTwo/Ui/SettingsTabs/Changelog.cs @@ -0,0 +1,51 @@ +using ChatTwo.Resources; +using ChatTwo.Util; +using Dalamud.Interface.Utility.Raii; +using ImGuiNET; + +namespace ChatTwo.Ui.SettingsTabs; + +internal sealed class Changelog : ISettingsTab +{ + private Configuration Mutable { get; } + + public string Name => Language.Options_Changelog_Tab + "###tabs-changelog"; + + internal Changelog(Configuration mutable) + { + Mutable = mutable; + } + + public void Draw(bool changed) + { + using var wrap = ImGuiUtil.TextWrapPos(); + + ImGui.TextUnformatted(Language.Options_Warning_NotImplemented); + ImGuiUtil.OptionCheckbox(ref Mutable.PrintChangelog, Language.Options_PrintChangelog_Name, Language.Options_PrintChangelog_Description); + + ImGui.Spacing(); + ImGui.Separator(); + ImGui.Spacing(); + + var changelog = Plugin.Interface.Manifest.Changelog; + if (changelog != null) + { + ImGui.TextUnformatted(Language.Options_Changelog_Header); + ImGui.TextUnformatted($"Version {Plugin.Interface.Manifest.AssemblyVersion.ToString(3)}"); + ImGui.Spacing(); + foreach (var sentence in changelog.Split("\n")) + { + if (sentence == string.Empty) + { + ImGui.NewLine(); + continue; + } + + var condition = sentence.StartsWith('-') || sentence.StartsWith(" -"); + using var indent = ImRaii.PushIndent(10.0f, true, condition); + ImGui.TextUnformatted(sentence); + } + } + ImGui.Spacing(); + } +}