Files
HellionChat/HellionChat/Ui/Windows/SettingsWindow.cs
T

86 lines
2.6 KiB
C#

using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using HellionChat.Resources;
using HellionChat.Ui.Components.Settings;
using HellionChat.Ui.Components.Settings.Tabs;
using Microsoft.Extensions.Logging;
namespace HellionChat.Ui.Windows;
// `internal` to match the Plugin.SettingsWindow property in W2; `public` here
// would raise CS0053 against the internal members. Matches MainWindow shape.
internal sealed class SettingsWindow : Window
{
private readonly Plugin _plugin;
private readonly TabSidebar _sidebar;
private readonly ContentArea _content;
private readonly ThemePicker _themePicker;
private readonly ColorPicker _colorPicker;
private readonly LivePreviewPanel _livePreview;
private readonly AppearanceTab _appearance;
private readonly GeneralTab _general;
public SettingsWindow(
Plugin plugin,
TabSidebar sidebar,
ContentArea content,
ThemePicker themePicker,
ColorPicker colorPicker,
LivePreviewPanel livePreview,
AppearanceTab appearance,
GeneralTab general,
ILoggerFactory loggerFactory
)
: base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings")
{
_plugin = plugin;
_sidebar = sidebar;
_content = content;
_themePicker = themePicker;
_colorPicker = colorPicker;
_livePreview = livePreview;
_appearance = appearance;
_general = general;
_ = loggerFactory;
Size = new Vector2(720, 540);
SizeCondition = ImGuiCond.FirstUseEver;
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(600, 400),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue),
};
Flags = ImGuiWindowFlags.NoCollapse;
// Carry-over from v1.6.0 stub: Escape must not auto-close, and toggle
// events must not play default Dalamud window sounds.
RespectCloseHotkey = false;
DisableWindowSounds = true;
}
public override void Draw()
{
_sidebar.Draw();
ImGui.SameLine();
_content.Draw(_sidebar.ActiveTab, RenderActiveTab);
}
private void RenderActiveTab(string tabId)
{
switch (tabId)
{
case "general":
_general.Draw();
break;
case "appearance":
_appearance.Draw();
break;
default:
ImGui.TextUnformatted($"[{tabId}] tab content lands in later task");
break;
}
}
}