feat(settings): add Chat tab including command help side

This commit is contained in:
2026-05-26 19:12:01 +02:00
parent 7e933cb8ba
commit 2507ed5197
3 changed files with 122 additions and 0 deletions
@@ -0,0 +1,113 @@
using Dalamud.Bindings.ImGui;
using HellionChat.Code;
namespace HellionChat.Ui.Components.Settings.Tabs;
internal sealed class ChatTab
{
private readonly Plugin _plugin;
public ChatTab(Plugin plugin)
{
_plugin = plugin;
}
public void Draw()
{
if (ImGui.CollapsingHeader("Display modes", ImGuiTreeNodeFlags.DefaultOpen))
{
DrawToggle(
"Compact density (card vs compact)",
() => Plugin.Config.UseCompactDensity,
v => Plugin.Config.UseCompactDensity = v
);
DrawToggle(
"More compact pretty mode",
() => Plugin.Config.MoreCompactPretty,
v => Plugin.Config.MoreCompactPretty = v
);
DrawToggle(
"Prettier timestamps",
() => Plugin.Config.PrettierTimestamps,
v => Plugin.Config.PrettierTimestamps = v
);
DrawToggle(
"Hide same timestamps",
() => Plugin.Config.HideSameTimestamps,
v => Plugin.Config.HideSameTimestamps = v
);
}
if (ImGui.CollapsingHeader("Channel filter"))
{
DrawToggle(
"Privacy filter enabled",
() => Plugin.Config.PrivacyFilterEnabled,
v => Plugin.Config.PrivacyFilterEnabled = v
);
DrawPrivacyPersistChannels();
}
if (ImGui.CollapsingHeader("Command help"))
{
DrawCommandHelpSideCombo();
}
}
private void DrawPrivacyPersistChannels()
{
// Enum.GetValues gives a stable order; HashSet membership is the source
// of truth, so we toggle via Add/Remove instead of mutating a copy.
ImGui.TextUnformatted("Persist channels:");
foreach (var ct in Enum.GetValues<ChatType>())
{
var label = ct.ToString();
var present = Plugin.Config.PrivacyPersistChannels.Contains(ct);
if (ImGui.Checkbox($"{label}##persist-{label}", ref present))
{
if (present)
{
Plugin.Config.PrivacyPersistChannels.Add(ct);
}
else
{
Plugin.Config.PrivacyPersistChannels.Remove(ct);
}
_plugin.SaveConfig();
}
}
}
private void DrawCommandHelpSideCombo()
{
var current = Plugin.Config.CommandHelpSide;
var values = Enum.GetValues<CommandHelpSide>();
var labels = new string[values.Length];
var selected = 0;
for (var i = 0; i < values.Length; i++)
{
labels[i] = values[i].Name();
if (values[i] == current)
{
selected = i;
}
}
ImGui.SetNextItemWidth(200);
if (ImGui.Combo("Command help side", ref selected, labels, labels.Length))
{
Plugin.Config.CommandHelpSide = 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();
}
}
}
+6
View File
@@ -21,6 +21,7 @@ internal sealed class SettingsWindow : Window
private readonly LivePreviewPanel _livePreview;
private readonly AppearanceTab _appearance;
private readonly GeneralTab _general;
private readonly ChatTab _chat;
public SettingsWindow(
Plugin plugin,
@@ -31,6 +32,7 @@ internal sealed class SettingsWindow : Window
LivePreviewPanel livePreview,
AppearanceTab appearance,
GeneralTab general,
ChatTab chat,
ILoggerFactory loggerFactory
)
: base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings")
@@ -43,6 +45,7 @@ internal sealed class SettingsWindow : Window
_livePreview = livePreview;
_appearance = appearance;
_general = general;
_chat = chat;
_ = loggerFactory;
Size = new Vector2(720, 540);
@@ -74,6 +77,9 @@ internal sealed class SettingsWindow : Window
case "general":
_general.Draw();
break;
case "chat":
_chat.Draw();
break;
case "appearance":
_appearance.Draw();
break;