refactor(settings): wire the section-open signal, rename tab files
This commit is contained in:
@@ -365,10 +365,10 @@ public sealed class FirstRunWizard : Window
|
||||
if (ImGui.Checkbox(HellionStrings.Wizard_Step3_LoadPreviousSession_Label, ref loadPrev))
|
||||
{
|
||||
_state.PendingLoadPreviousSession = loadPrev;
|
||||
// Mirror the DataManagement coupling: turning load-previous on
|
||||
// Mirror the DataAndPrivacy coupling: turning load-previous on
|
||||
// also turns filter-include on (otherwise old messages bypass
|
||||
// the filter chain), and turning filter-include off forces
|
||||
// load-previous off. Same idiom as Ui/SettingsTabs/DataManagement.cs:182-200.
|
||||
// load-previous off. Same idiom as Ui/SettingsTabs/DataAndPrivacy.cs:182-200.
|
||||
if (loadPrev)
|
||||
_state.PendingFilterIncludePreviousSessions = true;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@ public sealed class SettingsWindow : Dalamud.Interface.Windowing.Window
|
||||
private List<ISettingsTab> Tabs { get; }
|
||||
private int CurrentTab;
|
||||
private SettingsView View = SettingsView.Overview;
|
||||
|
||||
// Set when a section is freshly entered; the first Draw afterwards reads it
|
||||
// and clears it, so each section starts collapsed every time it is opened.
|
||||
private bool _sectionJustEntered;
|
||||
private readonly SettingsOverview Overview;
|
||||
|
||||
internal SettingsWindow(Plugin plugin, ILoggerFactory loggerFactory)
|
||||
@@ -46,15 +50,15 @@ public sealed class SettingsWindow : Dalamud.Interface.Windowing.Window
|
||||
Tabs =
|
||||
[
|
||||
new General(Plugin, Mutable),
|
||||
new ThemeAndLayout(Plugin, Mutable, loggerFactory.CreateLogger<ThemeAndLayout>()),
|
||||
new Appearance(Plugin, Mutable, loggerFactory.CreateLogger<Appearance>()),
|
||||
new FontsAndColours(Plugin, Mutable, loggerFactory.CreateLogger<FontsAndColours>()),
|
||||
new SettingsTabs.Window(Plugin, Mutable),
|
||||
new Chat(Plugin, Mutable),
|
||||
new SettingsTabs.Tabs(Plugin, Mutable),
|
||||
new SettingsTabs.Privacy(Plugin, Mutable),
|
||||
new DataManagement(Plugin, Mutable, loggerFactory.CreateLogger<DataManagement>()),
|
||||
new DataAndPrivacy(Plugin, Mutable, loggerFactory.CreateLogger<DataAndPrivacy>()),
|
||||
new SettingsTabs.Integrations(Plugin, Mutable),
|
||||
new Information(Mutable),
|
||||
new About(Mutable),
|
||||
];
|
||||
|
||||
RespectCloseHotkey = false;
|
||||
@@ -106,6 +110,7 @@ public sealed class SettingsWindow : Dalamud.Interface.Windowing.Window
|
||||
{
|
||||
CurrentTab = tabIndex;
|
||||
View = SettingsView.Detail;
|
||||
_sectionJustEntered = true;
|
||||
}
|
||||
|
||||
internal void OpenOverview()
|
||||
@@ -148,7 +153,10 @@ public sealed class SettingsWindow : Dalamud.Interface.Windowing.Window
|
||||
|
||||
using var child = ImRaii.Child("##chat2-settings-detail", new Vector2(-1, height));
|
||||
if (child.Success)
|
||||
Tabs[CurrentTab].Draw(false);
|
||||
{
|
||||
Tabs[CurrentTab].Draw(_sectionJustEntered);
|
||||
_sectionJustEntered = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSaveButtons()
|
||||
|
||||
@@ -11,7 +11,7 @@ using HellionChat.Util;
|
||||
namespace HellionChat.Ui.SettingsTabs;
|
||||
|
||||
// Combines the former About and Changelog tabs into three collapsible sections.
|
||||
internal sealed class Information : ISettingsTab
|
||||
internal sealed class About : ISettingsTab
|
||||
{
|
||||
private Configuration Mutable { get; }
|
||||
|
||||
@@ -47,7 +47,7 @@ internal sealed class Information : ISettingsTab
|
||||
"Sirayuki",
|
||||
];
|
||||
|
||||
internal Information(Configuration mutable)
|
||||
internal About(Configuration mutable)
|
||||
{
|
||||
Mutable = mutable;
|
||||
Translators.Sort(
|
||||
@@ -56,7 +56,7 @@ internal sealed class Information : ISettingsTab
|
||||
);
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
using var wrap = ImRaii.TextWrapPos(0.0f);
|
||||
|
||||
+4
-4
@@ -8,25 +8,25 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HellionChat.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class ThemeAndLayout : ISettingsTab
|
||||
internal sealed class Appearance : ISettingsTab
|
||||
{
|
||||
private Plugin Plugin { get; }
|
||||
private Configuration Mutable { get; }
|
||||
private readonly ILogger<ThemeAndLayout> _logger;
|
||||
private readonly ILogger<Appearance> _logger;
|
||||
|
||||
private string? _applyDismissedFor;
|
||||
|
||||
public string Name =>
|
||||
HellionStrings.Settings_Card_ThemeAndLayout_Title + "###tabs-themeandlayout";
|
||||
|
||||
internal ThemeAndLayout(Plugin plugin, Configuration mutable, ILogger<ThemeAndLayout> logger)
|
||||
internal Appearance(Plugin plugin, Configuration mutable, ILogger<Appearance> logger)
|
||||
{
|
||||
Plugin = plugin;
|
||||
Mutable = mutable;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
DrawThemeSection();
|
||||
ImGui.Spacing();
|
||||
@@ -40,7 +40,7 @@ internal sealed class Chat : ISettingsTab
|
||||
.ToArray(),
|
||||
};
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
DrawAutoTellTabsSection();
|
||||
ImGui.Spacing();
|
||||
|
||||
+5
-5
@@ -15,11 +15,11 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HellionChat.Ui.SettingsTabs;
|
||||
|
||||
internal sealed class DataManagement : ISettingsTab
|
||||
internal sealed class DataAndPrivacy : ISettingsTab
|
||||
{
|
||||
private Plugin Plugin { get; }
|
||||
private Configuration Mutable { get; }
|
||||
private readonly ILogger<DataManagement> _logger;
|
||||
private readonly ILogger<DataAndPrivacy> _logger;
|
||||
|
||||
public string Name =>
|
||||
HellionStrings.Settings_Card_DataManagement_Title + "###tabs-datamanagement";
|
||||
@@ -138,18 +138,18 @@ internal sealed class DataManagement : ISettingsTab
|
||||
),
|
||||
];
|
||||
|
||||
internal DataManagement(Plugin plugin, Configuration mutable, ILogger<DataManagement> logger)
|
||||
internal DataAndPrivacy(Plugin plugin, Configuration mutable, ILogger<DataAndPrivacy> logger)
|
||||
{
|
||||
Plugin = plugin;
|
||||
Mutable = mutable;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
// Shift-on-open keeps the Advanced tools available without a permanent
|
||||
// toggle in the UI, mirroring upstream Chat 2 behaviour.
|
||||
if (changed)
|
||||
if (sectionJustEntered)
|
||||
ShowAdvanced = ImGui.GetIO().KeyShift;
|
||||
|
||||
DrawStorageSection();
|
||||
@@ -27,7 +27,7 @@ internal sealed class FontsAndColours : ISettingsTab
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
DrawFontsSection();
|
||||
ImGui.Spacing();
|
||||
|
||||
@@ -19,7 +19,7 @@ internal sealed class General : ISettingsTab
|
||||
Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
DrawInputSection();
|
||||
ImGui.Spacing();
|
||||
|
||||
@@ -3,5 +3,5 @@ namespace HellionChat.Ui.SettingsTabs;
|
||||
internal interface ISettingsTab
|
||||
{
|
||||
string Name { get; }
|
||||
void Draw(bool changed);
|
||||
void Draw(bool sectionJustEntered);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ internal sealed class Integrations : ISettingsTab
|
||||
Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
ImGui.TextWrapped(HellionStrings.Settings_Integrations_Intro);
|
||||
ImGui.Spacing();
|
||||
|
||||
@@ -109,7 +109,7 @@ internal sealed class Privacy : ISettingsTab
|
||||
),
|
||||
];
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
if (ImGui.Button(HellionStrings.Wizard_Reopen_Button))
|
||||
Plugin.FirstRunWizard.IsOpen = true;
|
||||
|
||||
@@ -24,7 +24,7 @@ internal sealed class Tabs : ISettingsTab
|
||||
Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
const string addTabPopup = "add-tab-popup";
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ internal sealed class Window : ISettingsTab
|
||||
Mutable = mutable;
|
||||
}
|
||||
|
||||
public void Draw(bool changed)
|
||||
public void Draw(bool sectionJustEntered)
|
||||
{
|
||||
DrawHideSection();
|
||||
ImGui.Spacing();
|
||||
|
||||
Reference in New Issue
Block a user