feat(settings): add Channels tab with auto-tell and sidebar configs
This commit is contained in:
@@ -177,6 +177,9 @@ internal static class PluginHostFactory
|
|||||||
services.AddSingleton(sp => new Ui.Components.Settings.Tabs.WindowTab(
|
services.AddSingleton(sp => new Ui.Components.Settings.Tabs.WindowTab(
|
||||||
sp.GetRequiredService<Plugin>()
|
sp.GetRequiredService<Plugin>()
|
||||||
));
|
));
|
||||||
|
services.AddSingleton(sp => new Ui.Components.Settings.Tabs.ChannelsTab(
|
||||||
|
sp.GetRequiredService<Plugin>()
|
||||||
|
));
|
||||||
services.AddSingleton(sp => new Ui.Components.StatusBar(
|
services.AddSingleton(sp => new Ui.Components.StatusBar(
|
||||||
sp.GetRequiredService<ThemeRegistry>(),
|
sp.GetRequiredService<ThemeRegistry>(),
|
||||||
sp.GetRequiredService<FontManager>()
|
sp.GetRequiredService<FontManager>()
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
using Dalamud.Bindings.ImGui;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
|
|
||||||
|
namespace HellionChat.Ui.Components.Settings.Tabs;
|
||||||
|
|
||||||
|
internal sealed class ChannelsTab
|
||||||
|
{
|
||||||
|
private readonly Plugin _plugin;
|
||||||
|
|
||||||
|
public ChannelsTab(Plugin plugin)
|
||||||
|
{
|
||||||
|
_plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draw()
|
||||||
|
{
|
||||||
|
if (ImGui.CollapsingHeader("Tab management", ImGuiTreeNodeFlags.DefaultOpen))
|
||||||
|
{
|
||||||
|
DrawSliderInt(
|
||||||
|
"Auto-tell tabs limit",
|
||||||
|
() => Plugin.Config.AutoTellTabsLimit,
|
||||||
|
v => Plugin.Config.AutoTellTabsLimit = v,
|
||||||
|
1,
|
||||||
|
32
|
||||||
|
);
|
||||||
|
DrawToggle(
|
||||||
|
"Compact display",
|
||||||
|
() => Plugin.Config.AutoTellTabsCompactDisplay,
|
||||||
|
v => Plugin.Config.AutoTellTabsCompactDisplay = v
|
||||||
|
);
|
||||||
|
DrawSliderInt(
|
||||||
|
"History preload",
|
||||||
|
() => Plugin.Config.AutoTellTabsHistoryPreload,
|
||||||
|
v => Plugin.Config.AutoTellTabsHistoryPreload = v,
|
||||||
|
0,
|
||||||
|
200
|
||||||
|
);
|
||||||
|
DrawToggle(
|
||||||
|
"Show greeted toggle",
|
||||||
|
() => Plugin.Config.AutoTellTabsShowGreetedToggle,
|
||||||
|
v => Plugin.Config.AutoTellTabsShowGreetedToggle = v
|
||||||
|
);
|
||||||
|
// Popout is a v1.8.0 teaser — render disabled, do NOT persist.
|
||||||
|
using (ImRaii.Disabled(true))
|
||||||
|
{
|
||||||
|
var openAsPopout = Plugin.Config.AutoTellTabsOpenAsPopout;
|
||||||
|
ImGui.Checkbox("Open as popout (lands in v1.8.0)", ref openAsPopout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.CollapsingHeader("Tell auto-open mode", ImGuiTreeNodeFlags.DefaultOpen))
|
||||||
|
{
|
||||||
|
DrawTellAutoOpenModeCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.CollapsingHeader("Sidebar"))
|
||||||
|
{
|
||||||
|
DrawToggle(
|
||||||
|
"Show sidebar tabs",
|
||||||
|
() => Plugin.Config.SidebarTabView,
|
||||||
|
v => Plugin.Config.SidebarTabView = v
|
||||||
|
);
|
||||||
|
// Range covers the on-disk default (44) plus Master-Spec §4.1 reference
|
||||||
|
// (38px icon-only, 150px expanded). An earlier 120-400 range would clamp
|
||||||
|
// the default 44 up to 120 silently. 30 leaves headroom for a future
|
||||||
|
// ultra-tight icon-only mode; 300 stays above the 150 expanded reference
|
||||||
|
// without giving the slider an absurd ceiling.
|
||||||
|
DrawSliderInt(
|
||||||
|
"Sidebar width",
|
||||||
|
() => Plugin.Config.SidebarWidth,
|
||||||
|
v => Plugin.Config.SidebarWidth = v,
|
||||||
|
30,
|
||||||
|
300
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawTellAutoOpenModeCombo()
|
||||||
|
{
|
||||||
|
var labels = new[] { "Off", "Sidebar", "Top tab", "Popout (lands in v1.8.0)" };
|
||||||
|
var values = Enum.GetValues<TellAutoOpenMode>();
|
||||||
|
var current = Plugin.Config.TellAutoOpenMode;
|
||||||
|
var selected = 0;
|
||||||
|
for (var i = 0; i < values.Length; i++)
|
||||||
|
{
|
||||||
|
if (values[i] == current)
|
||||||
|
{
|
||||||
|
selected = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.SetNextItemWidth(220);
|
||||||
|
if (ImGui.Combo("Tell auto-open mode", ref selected, labels, labels.Length))
|
||||||
|
{
|
||||||
|
// Popout (index 3) is a v1.8.0 teaser — revert to previous value
|
||||||
|
// and skip SaveConfig.
|
||||||
|
if (selected >= 0 && selected < values.Length && selected != 3)
|
||||||
|
{
|
||||||
|
Plugin.Config.TellAutoOpenMode = values[selected];
|
||||||
|
_plugin.SaveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 DrawSliderInt(string label, Func<int> get, Action<int> set, int min, int max)
|
||||||
|
{
|
||||||
|
var current = get();
|
||||||
|
ImGui.SetNextItemWidth(200);
|
||||||
|
if (ImGui.SliderInt(label, ref current, min, max, "%d"))
|
||||||
|
{
|
||||||
|
set(current);
|
||||||
|
_plugin.SaveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ internal sealed class SettingsWindow : Window
|
|||||||
private readonly GeneralTab _general;
|
private readonly GeneralTab _general;
|
||||||
private readonly ChatTab _chat;
|
private readonly ChatTab _chat;
|
||||||
private readonly WindowTab _window;
|
private readonly WindowTab _window;
|
||||||
|
private readonly ChannelsTab _channels;
|
||||||
|
|
||||||
public SettingsWindow(
|
public SettingsWindow(
|
||||||
Plugin plugin,
|
Plugin plugin,
|
||||||
@@ -35,6 +36,7 @@ internal sealed class SettingsWindow : Window
|
|||||||
GeneralTab general,
|
GeneralTab general,
|
||||||
ChatTab chat,
|
ChatTab chat,
|
||||||
WindowTab window,
|
WindowTab window,
|
||||||
|
ChannelsTab channels,
|
||||||
ILoggerFactory loggerFactory
|
ILoggerFactory loggerFactory
|
||||||
)
|
)
|
||||||
: base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings")
|
: base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings")
|
||||||
@@ -49,6 +51,7 @@ internal sealed class SettingsWindow : Window
|
|||||||
_general = general;
|
_general = general;
|
||||||
_chat = chat;
|
_chat = chat;
|
||||||
_window = window;
|
_window = window;
|
||||||
|
_channels = channels;
|
||||||
_ = loggerFactory;
|
_ = loggerFactory;
|
||||||
|
|
||||||
Size = new Vector2(720, 540);
|
Size = new Vector2(720, 540);
|
||||||
@@ -86,6 +89,9 @@ internal sealed class SettingsWindow : Window
|
|||||||
case "window":
|
case "window":
|
||||||
_window.Draw();
|
_window.Draw();
|
||||||
break;
|
break;
|
||||||
|
case "channels":
|
||||||
|
_channels.Draw();
|
||||||
|
break;
|
||||||
case "appearance":
|
case "appearance":
|
||||||
_appearance.Draw();
|
_appearance.Draw();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user