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