diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index 3da4c0b..3b96a9c 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -20,6 +20,7 @@ internal class Configuration : IPluginConfiguration public bool HideWhenUiHidden = true; public bool HideInLoadingScreens; public bool HideInBattle; + public bool ShowCloseButton = true; public bool NativeItemTooltips = true; public bool PrettierTimestamps = true; public bool MoreCompactPretty; diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index 0b15b18..a4fc93a 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -2831,6 +2831,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Show a close button next to the settings button. The chat window can be returned by pressing return or slash to focus it.. + /// + internal static string Options_ShowCloseButton_Description { + get { + return ResourceManager.GetString("Options_ShowCloseButton_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show close button. + /// + internal static string Options_ShowCloseButton_Name { + get { + return ResourceManager.GetString("Options_ShowCloseButton_Name", resourceCulture); + } + } + /// /// Looks up a localized string similar to Replaces words with their emote version, currently supports BetterTTV.. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 13b1884..5f83775 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -163,6 +163,12 @@ Show the Novice Network join button next to the settings button if logged in as a mentor. + + Show close button + + + Show a close button next to the settings button. The chat window can be returned by pressing return or slash to focus it. + Font size diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index 93f1db6..44ea23e 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -662,7 +662,8 @@ public sealed class ChatLogWindow : Window var buttonWidth = afterIcon.X - beforeIcon.X; var showNovice = Plugin.Config.ShowNoviceNetwork && GameFunctions.GameFunctions.IsMentor(); - var inputWidth = ImGui.GetContentRegionAvail().X - buttonWidth * (showNovice ? 2 : 1); + var buttonsRight = (showNovice ? 1 : 0) + (Plugin.Config.ShowCloseButton ? 1 : 0); + var inputWidth = ImGui.GetContentRegionAvail().X - buttonWidth * (1 + buttonsRight); var inputType = TempChannel?.ToChatType() ?? activeTab?.Channel?.ToChatType() ?? Plugin.Functions.Chat.Channel.Channel.ToChatType(); var isCommand = Chat.Trim().StartsWith('/'); @@ -774,9 +775,16 @@ public sealed class ChatLogWindow : Window ImGui.SameLine(); - if (ImGuiUtil.IconButton(FontAwesomeIcon.Cog)) + if (ImGuiUtil.IconButton(FontAwesomeIcon.Cog, width: (int)buttonWidth)) Plugin.SettingsWindow.Toggle(); + if (Plugin.Config.ShowCloseButton) + { + ImGui.SameLine(); + if (ImGuiUtil.IconButton(FontAwesomeIcon.Times, width: (int)buttonWidth)) + UserHide(); + } + if (!showNovice) return; diff --git a/ChatTwo/Ui/SettingsTabs/ChatLog.cs b/ChatTwo/Ui/SettingsTabs/ChatLog.cs index 6ee10a5..a4e3f44 100644 --- a/ChatTwo/Ui/SettingsTabs/ChatLog.cs +++ b/ChatTwo/Ui/SettingsTabs/ChatLog.cs @@ -35,6 +35,9 @@ internal sealed class ChatLog : ISettingsTab ImGuiUtil.OptionCheckbox(ref Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description); ImGui.Spacing(); + ImGuiUtil.OptionCheckbox(ref Mutable.ShowCloseButton, Language.Options_ShowCloseButton_Name, Language.Options_ShowCloseButton_Description); + ImGui.Spacing(); + ImGuiUtil.OptionCheckbox(ref Mutable.NativeItemTooltips, Language.Options_NativeItemTooltips_Name, string.Format(Language.Options_NativeItemTooltips_Description, Plugin.PluginName)); ImGui.Spacing(); diff --git a/ChatTwo/Util/ImGuiUtil.cs b/ChatTwo/Util/ImGuiUtil.cs index 27e5b95..83aab61 100755 --- a/ChatTwo/Util/ImGuiUtil.cs +++ b/ChatTwo/Util/ImGuiUtil.cs @@ -172,14 +172,20 @@ internal static class ImGuiUtil return textEnd; } - internal static bool IconButton(FontAwesomeIcon icon, string? id = null, string? tooltip = null) + internal static bool IconButton(FontAwesomeIcon icon, string? id = null, string? tooltip = null, int width = 0) { var label = icon.ToIconString(); if (id != null) label += $"##{id}"; Plugin.FontManager.FontAwesome.Push(); - var ret = ImGui.Button(label); + var size = new Vector2(0, 0); + if (width > 0) + { + var style = ImGui.GetStyle(); + size.X = width - 2 * style.CellPadding.X; + } + var ret = ImGui.Button(label, size); Plugin.FontManager.FontAwesome.Pop(); if (tooltip != null && ImGui.IsItemHovered())