feat(settings): add Chat tab including command help side
This commit is contained in:
@@ -171,6 +171,9 @@ internal static class PluginHostFactory
|
|||||||
services.AddSingleton(sp => new Ui.Components.Settings.Tabs.GeneralTab(
|
services.AddSingleton(sp => new Ui.Components.Settings.Tabs.GeneralTab(
|
||||||
sp.GetRequiredService<Plugin>()
|
sp.GetRequiredService<Plugin>()
|
||||||
));
|
));
|
||||||
|
services.AddSingleton(sp => new Ui.Components.Settings.Tabs.ChatTab(
|
||||||
|
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,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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ internal sealed class SettingsWindow : Window
|
|||||||
private readonly LivePreviewPanel _livePreview;
|
private readonly LivePreviewPanel _livePreview;
|
||||||
private readonly AppearanceTab _appearance;
|
private readonly AppearanceTab _appearance;
|
||||||
private readonly GeneralTab _general;
|
private readonly GeneralTab _general;
|
||||||
|
private readonly ChatTab _chat;
|
||||||
|
|
||||||
public SettingsWindow(
|
public SettingsWindow(
|
||||||
Plugin plugin,
|
Plugin plugin,
|
||||||
@@ -31,6 +32,7 @@ internal sealed class SettingsWindow : Window
|
|||||||
LivePreviewPanel livePreview,
|
LivePreviewPanel livePreview,
|
||||||
AppearanceTab appearance,
|
AppearanceTab appearance,
|
||||||
GeneralTab general,
|
GeneralTab general,
|
||||||
|
ChatTab chat,
|
||||||
ILoggerFactory loggerFactory
|
ILoggerFactory loggerFactory
|
||||||
)
|
)
|
||||||
: base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings")
|
: base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings")
|
||||||
@@ -43,6 +45,7 @@ internal sealed class SettingsWindow : Window
|
|||||||
_livePreview = livePreview;
|
_livePreview = livePreview;
|
||||||
_appearance = appearance;
|
_appearance = appearance;
|
||||||
_general = general;
|
_general = general;
|
||||||
|
_chat = chat;
|
||||||
_ = loggerFactory;
|
_ = loggerFactory;
|
||||||
|
|
||||||
Size = new Vector2(720, 540);
|
Size = new Vector2(720, 540);
|
||||||
@@ -74,6 +77,9 @@ internal sealed class SettingsWindow : Window
|
|||||||
case "general":
|
case "general":
|
||||||
_general.Draw();
|
_general.Draw();
|
||||||
break;
|
break;
|
||||||
|
case "chat":
|
||||||
|
_chat.Draw();
|
||||||
|
break;
|
||||||
case "appearance":
|
case "appearance":
|
||||||
_appearance.Draw();
|
_appearance.Draw();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user