Files
HellionChat/HellionChat/Ui/Components/Settings/Tabs/ChannelsTab.cs
T

120 lines
3.7 KiB
C#

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"))
{
// Range matches Sidebar.MinSidebarWidth/MaxSidebarWidth (40-300). The
// lower bound sits just above the 38px icon-only threshold; the
// on-disk default (44) and the 150px expanded reference both fit.
DrawSliderInt(
"Sidebar width",
() => Plugin.Config.SidebarWidth,
v => Plugin.Config.SidebarWidth = v,
40,
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();
}
}
}