refactor(settings): rebuild the General tab into collapsible sections

This commit is contained in:
2026-05-22 23:07:01 +02:00
parent eafa20748c
commit 8a8c6ccae2
3 changed files with 63 additions and 58 deletions
+39 -39
View File
@@ -21,22 +21,22 @@ internal sealed class General : ISettingsTab
public void Draw(bool sectionJustEntered)
{
DrawInputSection();
DrawInputSection(sectionJustEntered);
ImGui.Spacing();
DrawAudioSection();
DrawSoundSection(sectionJustEntered);
ImGui.Spacing();
DrawPerformanceSection();
DrawLanguageSection(sectionJustEntered);
ImGui.Spacing();
DrawLanguageSection();
DrawPerformanceSection(sectionJustEntered);
}
private void DrawInputSection()
private void DrawInputSection(bool sectionJustEntered)
{
using var tree = ImRaii.TreeNode(HellionStrings.Settings_General_Input_Heading);
// Collapse every time the tab is freshly entered so state doesn't bleed across sessions.
if (sectionJustEntered) ImGui.SetNextItemOpen(false);
using var tree = ImRaii.TreeNode(HellionStrings.Settings_Section_Input);
if (!tree.Success)
{
return;
}
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
{
@@ -83,13 +83,13 @@ internal sealed class General : ISettingsTab
}
}
private void DrawAudioSection()
private void DrawSoundSection(bool sectionJustEntered)
{
using var tree = ImRaii.TreeNode(HellionStrings.Settings_General_Audio_Heading);
// Collapse every time the tab is freshly entered so state doesn't bleed across sessions.
if (sectionJustEntered) ImGui.SetNextItemOpen(false);
using var tree = ImRaii.TreeNode(HellionStrings.Settings_Section_Sound);
if (!tree.Success)
{
return;
}
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
{
@@ -112,42 +112,26 @@ internal sealed class General : ISettingsTab
{
Mutable.CustomSoundVolume = customSoundVolumePercent / 100f;
}
ImGuiUtil.HelpMarker(HellionStrings.Settings_General_CustomSoundVolume_Description);
ImGui.Checkbox(Language.Options_ShowNoviceNetwork_Name, ref Mutable.ShowNoviceNetwork);
ImGuiUtil.HelpMarker(Language.Options_ShowNoviceNetwork_Description);
// Show the functional description and the per-tab navigation hint together.
ImGuiUtil.HelpMarker(HellionStrings.Settings_General_CustomSoundVolume_Description + "\n\n" + HellionStrings.Settings_Section_Sound_TabsHint);
}
}
private void DrawPerformanceSection()
private void DrawLanguageSection(bool sectionJustEntered)
{
using var tree = ImRaii.TreeNode(HellionStrings.Settings_General_Performance_Heading);
// Collapse every time the tab is freshly entered so state doesn't bleed across sessions.
if (sectionJustEntered) ImGui.SetNextItemOpen(false);
using var tree = ImRaii.TreeNode(HellionStrings.Settings_Section_Language);
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);
}
}
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
ImGuiUtil.HelpMarker(Language.Options_SortAutoTranslate_Description);
private void DrawLanguageSection()
{
using var tree = ImRaii.TreeNode(HellionStrings.Settings_General_Language_Heading);
if (!tree.Success)
{
return;
}
ImGui.Spacing();
using (ImRaii.PushIndent(ImGui.GetStyle().IndentSpacing, false))
{
using (
var combo = ImGuiUtil.BeginComboVertical(
Language.Options_Language_Name,
@@ -201,9 +185,25 @@ internal sealed class General : ISettingsTab
string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName)
);
ImGui.Spacing();
}
}
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate);
ImGuiUtil.HelpMarker(Language.Options_SortAutoTranslate_Description);
private void DrawPerformanceSection(bool sectionJustEntered)
{
// Collapse every time the tab is freshly entered so state doesn't bleed across sessions.
if (sectionJustEntered) ImGui.SetNextItemOpen(false);
using var tree = ImRaii.TreeNode(HellionStrings.Settings_Section_Performance);
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);
}
}
}