From 6daa0bb9e2bfd2f284faa57fb7eb97cfc96467a8 Mon Sep 17 00:00:00 2001 From: Infi Date: Tue, 21 May 2024 10:53:37 +0200 Subject: [PATCH] Move preview config to its own tab --- ChatTwo/Resources/Language.Designer.cs | 13 +++++-- ChatTwo/Resources/Language.resx | 7 ++-- ChatTwo/Ui/Settings.cs | 1 + ChatTwo/Ui/SettingsTabs/Miscellaneous.cs | 27 --------------- ChatTwo/Ui/SettingsTabs/Preview.cs | 43 ++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 31 deletions(-) create mode 100644 ChatTwo/Ui/SettingsTabs/Preview.cs diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index e668d90..915d9d5 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -1689,7 +1689,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Command help side. + /// Looks up a localized string similar to Command help side (None = off). /// internal static string Options_CommandHelpSide_Name { get { @@ -2427,7 +2427,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Message preview. + /// Looks up a localized string similar to Position (None = off). /// internal static string Options_Preview_Name { get { @@ -2444,6 +2444,15 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Preview. + /// + internal static string Options_Preview_Tab { + get { + return ResourceManager.GetString("Options_Preview_Tab", resourceCulture); + } + } + /// /// Looks up a localized string similar to Tooltip. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 2f450a8..59f1ff6 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -389,7 +389,7 @@ Right - Command help side + Command help side (None = off) The side of {0} to display help for commands on. @@ -1055,7 +1055,7 @@ Displays a preview with special parameter evaluated, like emotes and <item> - Message preview + Position (None = off) None @@ -1087,4 +1087,7 @@ Show only if the text length is greater-than or equal + + Preview + diff --git a/ChatTwo/Ui/Settings.cs b/ChatTwo/Ui/Settings.cs index 877fe7d..95e2110 100755 --- a/ChatTwo/Ui/Settings.cs +++ b/ChatTwo/Ui/Settings.cs @@ -36,6 +36,7 @@ public sealed class SettingsWindow : Window new Display(Mutable), new ChatLog(Plugin, Mutable), new Emote(Plugin, Mutable), + new Preview(Plugin, Mutable), new Ui.SettingsTabs.Fonts(Mutable), new ChatColours(Plugin, Mutable), new Tabs(Plugin, Mutable), diff --git a/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs b/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs index f9e3d1b..2fee8d6 100755 --- a/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs +++ b/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs @@ -22,33 +22,6 @@ internal sealed class Miscellaneous(Configuration mutable) : ISettingsTab } ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName)); - - ImGui.Spacing(); - ImGui.Separator(); - ImGui.Spacing(); - - using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Preview_Name, Mutable.PreviewPosition.Name())) - { - if (combo) - { - foreach (var position in Enum.GetValues()) - if (ImGui.Selectable(position.Name(), Mutable.PreviewPosition == position)) - Mutable.PreviewPosition = position; - } - } - ImGuiUtil.HelpText(Language.Options_Preview_Description); - ImGui.Spacing(); - - if (Mutable.PreviewPosition is not PreviewPosition.None) - { - ImGuiUtil.OptionCheckbox(ref Mutable.OnlyPreviewIf, Language.Options_PreviewOnlyIf_Name, Language.Options_PreviewOnlyIf_Description); - ImGui.Spacing(); - if (ImGuiUtil.InputIntVertical(Language.Options_PreviewMinimum_Name, Language.Options_PreviewMinimum_Description, ref Mutable.PreviewMinimum)) - Mutable.PreviewMinimum = Math.Clamp(Mutable.PreviewMinimum, 1, 250); - } - - ImGui.Spacing(); - ImGui.Separator(); ImGui.Spacing(); using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name())) diff --git a/ChatTwo/Ui/SettingsTabs/Preview.cs b/ChatTwo/Ui/SettingsTabs/Preview.cs new file mode 100644 index 0000000..36e3d55 --- /dev/null +++ b/ChatTwo/Ui/SettingsTabs/Preview.cs @@ -0,0 +1,43 @@ +using ChatTwo.Resources; +using ChatTwo.Util; +using ImGuiNET; + +namespace ChatTwo.Ui.SettingsTabs; + +internal sealed class Preview : ISettingsTab +{ + private readonly Plugin Plugin; + private Configuration Mutable { get; } + + public string Name => Language.Options_Preview_Tab + "###tabs-preview"; + + internal Preview(Plugin plugin, Configuration mutable) + { + Plugin = plugin; + Mutable = mutable; + } + + public void Draw(bool changed) + { + using var wrap = ImGuiUtil.TextWrapPos(); + + using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Preview_Name, Mutable.PreviewPosition.Name())) + { + if (combo) + { + foreach (var position in Enum.GetValues()) + if (ImGui.Selectable(position.Name(), Mutable.PreviewPosition == position)) + Mutable.PreviewPosition = position; + } + } + ImGuiUtil.HelpText(Language.Options_Preview_Description); + ImGui.Spacing(); + + ImGuiUtil.OptionCheckbox(ref Mutable.OnlyPreviewIf, Language.Options_PreviewOnlyIf_Name, Language.Options_PreviewOnlyIf_Description); + ImGui.Spacing(); + if (ImGuiUtil.InputIntVertical(Language.Options_PreviewMinimum_Name, Language.Options_PreviewMinimum_Description, ref Mutable.PreviewMinimum)) + Mutable.PreviewMinimum = Math.Clamp(Mutable.PreviewMinimum, 1, 250); + + ImGui.Spacing(); + } +}