diff --git a/HellionChat/PluginHostFactory.cs b/HellionChat/PluginHostFactory.cs index f1445c9..f87bbe8 100644 --- a/HellionChat/PluginHostFactory.cs +++ b/HellionChat/PluginHostFactory.cs @@ -168,6 +168,9 @@ internal static class PluginHostFactory sp.GetRequiredService(), sp.GetRequiredService() )); + services.AddSingleton(sp => new Ui.Components.Settings.Tabs.GeneralTab( + sp.GetRequiredService() + )); services.AddSingleton(sp => new Ui.Components.StatusBar( sp.GetRequiredService(), sp.GetRequiredService() diff --git a/HellionChat/Ui/Components/Settings/Tabs/GeneralTab.cs b/HellionChat/Ui/Components/Settings/Tabs/GeneralTab.cs new file mode 100644 index 0000000..cbcbdbe --- /dev/null +++ b/HellionChat/Ui/Components/Settings/Tabs/GeneralTab.cs @@ -0,0 +1,56 @@ +using Dalamud.Bindings.ImGui; + +namespace HellionChat.Ui.Components.Settings.Tabs; + +internal sealed class GeneralTab +{ + private readonly Plugin _plugin; + + public GeneralTab(Plugin plugin) + { + _plugin = plugin; + } + + public void Draw() + { + if (ImGui.CollapsingHeader("Behavior", ImGuiTreeNodeFlags.DefaultOpen)) + { + DrawToggle("Allow window movement", () => Plugin.Config.CanMove, v => Plugin.Config.CanMove = v); + DrawToggle("Allow window resize", () => Plugin.Config.CanResize, v => Plugin.Config.CanResize = v); + DrawToggle("Reduce motion (no theme crossfade)", () => Plugin.Config.ReduceMotion, v => Plugin.Config.ReduceMotion = v); + DrawToggle("Print changelog on update", () => Plugin.Config.PrintChangelog, v => Plugin.Config.PrintChangelog = v); + } + + if (ImGui.CollapsingHeader("Notifications", ImGuiTreeNodeFlags.DefaultOpen)) + { + DrawToggle("Show novice network", () => Plugin.Config.ShowNoviceNetwork, v => Plugin.Config.ShowNoviceNetwork = v); + DrawToggle("Enable auto-tell tabs", () => Plugin.Config.EnableAutoTellTabs, v => Plugin.Config.EnableAutoTellTabs = v); + } + + if (ImGui.CollapsingHeader("Volumes", ImGuiTreeNodeFlags.DefaultOpen)) + { + DrawSlider("Custom sound volume", () => Plugin.Config.CustomSoundVolume, v => Plugin.Config.CustomSoundVolume = v, 0f, 1f); + } + } + + private void DrawToggle(string label, Func get, Action set) + { + var current = get(); + if (ImGui.Checkbox(label, ref current)) + { + set(current); + _plugin.SaveConfig(); + } + } + + private void DrawSlider(string label, Func get, Action set, float min, float max) + { + var current = get(); + ImGui.SetNextItemWidth(200); + if (ImGui.SliderFloat(label, ref current, min, max, "%.2f")) + { + set(current); + _plugin.SaveConfig(); + } + } +} diff --git a/HellionChat/Ui/Windows/SettingsWindow.cs b/HellionChat/Ui/Windows/SettingsWindow.cs index 55bb744..4b89bcb 100644 --- a/HellionChat/Ui/Windows/SettingsWindow.cs +++ b/HellionChat/Ui/Windows/SettingsWindow.cs @@ -20,6 +20,7 @@ internal sealed class SettingsWindow : Window private readonly ColorPicker _colorPicker; private readonly LivePreviewPanel _livePreview; private readonly AppearanceTab _appearance; + private readonly GeneralTab _general; public SettingsWindow( Plugin plugin, @@ -29,6 +30,7 @@ internal sealed class SettingsWindow : Window ColorPicker colorPicker, LivePreviewPanel livePreview, AppearanceTab appearance, + GeneralTab general, ILoggerFactory loggerFactory ) : base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings") @@ -40,6 +42,7 @@ internal sealed class SettingsWindow : Window _colorPicker = colorPicker; _livePreview = livePreview; _appearance = appearance; + _general = general; _ = loggerFactory; Size = new Vector2(720, 540); @@ -68,6 +71,9 @@ internal sealed class SettingsWindow : Window { switch (tabId) { + case "general": + _general.Draw(); + break; case "appearance": _appearance.Draw(); break;