feat(settings): add General tab with direct-save toggles
This commit is contained in:
@@ -168,6 +168,9 @@ internal static class PluginHostFactory
|
||||
sp.GetRequiredService<Ui.Components.Settings.LivePreviewPanel>(),
|
||||
sp.GetRequiredService<Ui.Components.Settings.ThemeImportExportRow>()
|
||||
));
|
||||
services.AddSingleton(sp => new Ui.Components.Settings.Tabs.GeneralTab(
|
||||
sp.GetRequiredService<Plugin>()
|
||||
));
|
||||
services.AddSingleton(sp => new Ui.Components.StatusBar(
|
||||
sp.GetRequiredService<ThemeRegistry>(),
|
||||
sp.GetRequiredService<FontManager>()
|
||||
|
||||
@@ -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<bool> get, Action<bool> set)
|
||||
{
|
||||
var current = get();
|
||||
if (ImGui.Checkbox(label, ref current))
|
||||
{
|
||||
set(current);
|
||||
_plugin.SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSlider(string label, Func<float> get, Action<float> set, float min, float max)
|
||||
{
|
||||
var current = get();
|
||||
ImGui.SetNextItemWidth(200);
|
||||
if (ImGui.SliderFloat(label, ref current, min, max, "%.2f"))
|
||||
{
|
||||
set(current);
|
||||
_plugin.SaveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user