Merge pull request #77

feat: add close button to chat log
This commit is contained in:
Infi
2024-07-08 11:42:45 +02:00
committed by GitHub
6 changed files with 46 additions and 4 deletions
+1
View File
@@ -20,6 +20,7 @@ internal class Configuration : IPluginConfiguration
public bool HideWhenUiHidden = true; public bool HideWhenUiHidden = true;
public bool HideInLoadingScreens; public bool HideInLoadingScreens;
public bool HideInBattle; public bool HideInBattle;
public bool ShowCloseButton = true;
public bool NativeItemTooltips = true; public bool NativeItemTooltips = true;
public bool PrettierTimestamps = true; public bool PrettierTimestamps = true;
public bool MoreCompactPretty; public bool MoreCompactPretty;
+18
View File
@@ -2831,6 +2831,24 @@ namespace ChatTwo.Resources {
} }
} }
/// <summary>
/// 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..
/// </summary>
internal static string Options_ShowCloseButton_Description {
get {
return ResourceManager.GetString("Options_ShowCloseButton_Description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show close button.
/// </summary>
internal static string Options_ShowCloseButton_Name {
get {
return ResourceManager.GetString("Options_ShowCloseButton_Name", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Replaces words with their emote version, currently supports BetterTTV.. /// Looks up a localized string similar to Replaces words with their emote version, currently supports BetterTTV..
/// </summary> /// </summary>
+6
View File
@@ -163,6 +163,12 @@
<data name="Options_ShowNoviceNetwork_Description"> <data name="Options_ShowNoviceNetwork_Description">
<value>Show the Novice Network join button next to the settings button if logged in as a mentor.</value> <value>Show the Novice Network join button next to the settings button if logged in as a mentor.</value>
</data> </data>
<data name="Options_ShowCloseButton_Name" xml:space="preserve">
<value>Show close button</value>
</data>
<data name="Options_ShowCloseButton_Description" xml:space="preserve">
<value>Show a close button next to the settings button. The chat window can be returned by pressing return or slash to focus it.</value>
</data>
<data name="Options_FontSize_Name"> <data name="Options_FontSize_Name">
<value>Font size</value> <value>Font size</value>
</data> </data>
+10 -2
View File
@@ -662,7 +662,8 @@ public sealed class ChatLogWindow : Window
var buttonWidth = afterIcon.X - beforeIcon.X; var buttonWidth = afterIcon.X - beforeIcon.X;
var showNovice = Plugin.Config.ShowNoviceNetwork && GameFunctions.GameFunctions.IsMentor(); 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 inputType = TempChannel?.ToChatType() ?? activeTab?.Channel?.ToChatType() ?? Plugin.Functions.Chat.Channel.Channel.ToChatType();
var isCommand = Chat.Trim().StartsWith('/'); var isCommand = Chat.Trim().StartsWith('/');
@@ -774,9 +775,16 @@ public sealed class ChatLogWindow : Window
ImGui.SameLine(); ImGui.SameLine();
if (ImGuiUtil.IconButton(FontAwesomeIcon.Cog)) if (ImGuiUtil.IconButton(FontAwesomeIcon.Cog, width: (int)buttonWidth))
Plugin.SettingsWindow.Toggle(); Plugin.SettingsWindow.Toggle();
if (Plugin.Config.ShowCloseButton)
{
ImGui.SameLine();
if (ImGuiUtil.IconButton(FontAwesomeIcon.Times, width: (int)buttonWidth))
UserHide();
}
if (!showNovice) if (!showNovice)
return; return;
+3
View File
@@ -35,6 +35,9 @@ internal sealed class ChatLog : ISettingsTab
ImGuiUtil.OptionCheckbox(ref Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description); ImGuiUtil.OptionCheckbox(ref Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description);
ImGui.Spacing(); 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)); ImGuiUtil.OptionCheckbox(ref Mutable.NativeItemTooltips, Language.Options_NativeItemTooltips_Name, string.Format(Language.Options_NativeItemTooltips_Description, Plugin.PluginName));
ImGui.Spacing(); ImGui.Spacing();
+8 -2
View File
@@ -172,14 +172,20 @@ internal static class ImGuiUtil
return textEnd; 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(); var label = icon.ToIconString();
if (id != null) if (id != null)
label += $"##{id}"; label += $"##{id}";
Plugin.FontManager.FontAwesome.Push(); 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(); Plugin.FontManager.FontAwesome.Pop();
if (tooltip != null && ImGui.IsItemHovered()) if (tooltip != null && ImGui.IsItemHovered())