Files
HellionChat/ChatTwo/Ui/SettingsTabs/General.cs
T
JonKazama-Hellion 7de28ef9b2 refactor(settings): align performance section with helpmarker pattern
Drop the inline wall-of-text description in favour of the standard
HelpMarker tooltip used across the rest of the v0.5.0 settings UX.
Visual consistency for the General tab.
2026-05-02 21:18:30 +02:00

162 lines
5.6 KiB
C#

using ChatTwo.Resources;
using ChatTwo.Util;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Bindings.ImGui;
namespace ChatTwo.Ui.SettingsTabs;
internal sealed class General : ISettingsTab
{
private Plugin Plugin { get; }
private Configuration Mutable { get; }
public string Name => HellionStrings.Settings_Tab_General + "###tabs-general";
internal General(Plugin plugin, Configuration mutable)
{
Plugin = plugin;
Mutable = mutable;
}
public void Draw(bool changed)
{
DrawInputSection();
ImGui.Spacing();
DrawAudioSection();
ImGui.Spacing();
DrawPerformanceSection();
ImGui.Spacing();
DrawLanguageSection();
}
private void DrawInputSection()
{
using var tree = ImRaii.TreeNode(HellionStrings.Settings_General_Input_Heading);
if (!tree.Success)
{
return;
}
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
{
ImGui.Checkbox(Language.Options_KeepInputFocus_Name, ref Mutable.KeepInputFocus);
ImGuiUtil.HelpMarker(Language.Options_KeepInputFocus_Description);
ImGui.Spacing();
ImGui.TextUnformatted(Language.Options_ChatTabForwardKeybind_Name);
ImGui.SetNextItemWidth(-1);
ImGuiUtil.KeybindInput("ChatTabForwardKeybind", ref Mutable.ChatTabForward);
ImGui.TextUnformatted(Language.Options_ChatTabBackwardKeybind_Name);
ImGui.SetNextItemWidth(-1);
ImGuiUtil.KeybindInput("ChatTabBackwardKeybind", ref Mutable.ChatTabBackward);
}
}
private void DrawAudioSection()
{
using var tree = ImRaii.TreeNode(HellionStrings.Settings_General_Audio_Heading);
if (!tree.Success)
{
return;
}
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
{
ImGui.Checkbox(Language.Options_PlaySounds_Name, ref Mutable.PlaySounds);
ImGuiUtil.HelpMarker(Language.Options_PlaySounds_Description);
ImGui.Checkbox(Language.Options_ShowNoviceNetwork_Name, ref Mutable.ShowNoviceNetwork);
ImGuiUtil.HelpMarker(Language.Options_ShowNoviceNetwork_Description);
}
}
private void DrawPerformanceSection()
{
using var tree = ImRaii.TreeNode(HellionStrings.Settings_General_Performance_Heading);
if (!tree.Success)
{
return;
}
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
{
ImGui.SetNextItemWidth(200f * ImGuiHelpers.GlobalScale);
if (ImGui.InputInt(Language.Options_MaxLinesToShow_Name, ref Mutable.MaxLinesToRender))
{
Mutable.MaxLinesToRender = Math.Clamp(Mutable.MaxLinesToRender, 1, 10_000);
}
ImGuiUtil.HelpMarker(Language.Options_MaxLinesToShow_Description);
}
}
private void DrawLanguageSection()
{
using var tree = ImRaii.TreeNode(HellionStrings.Settings_General_Language_Heading);
if (!tree.Success)
{
return;
}
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
{
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name()))
{
if (combo.Success)
{
foreach (var language in Enum.GetValues<LanguageOverride>())
{
if (ImGui.Selectable(language.Name()))
{
Mutable.LanguageOverride = language;
}
}
}
}
ImGuiUtil.HelpMarker(string.Format(Language.Options_Language_Description, Plugin.PluginName));
ImGui.Spacing();
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name()))
{
if (combo.Success)
{
foreach (var side in Enum.GetValues<CommandHelpSide>())
{
if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side))
{
Mutable.CommandHelpSide = side;
}
}
}
}
ImGuiUtil.HelpMarker(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName));
ImGui.Spacing();
using (var combo = ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, Mutable.KeybindMode.Name()))
{
if (combo.Success)
{
foreach (var mode in Enum.GetValues<KeybindMode>())
{
if (ImGui.Selectable(mode.Name(), Mutable.KeybindMode == mode))
{
Mutable.KeybindMode = mode;
}
if (ImGui.IsItemHovered())
{
ImGuiUtil.Tooltip(mode.Tooltip() ?? "");
}
}
}
}
ImGuiUtil.HelpMarker(string.Format(Language.Options_KeybindMode_Description, Plugin.PluginName));
ImGui.Spacing();
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
ImGuiUtil.HelpMarker(Language.Options_SortAutoTranslate_Description);
}
}
}