Six tabs carried a byte-identical DrawToggle, four a byte-identical slider, and five hand-rolled the same enum combo loop. 281 lines out, 82 in. The combos were not only duplicated, they were wasteful: each one called Enum.GetValues inside Draw, so every open settings window allocated five arrays per frame for sets that cannot change at runtime. EnumValues<T> reads them once per closed generic, and the label array is one buffer shared by all of them. Two behaviours are now uniform rather than accidental. The range check on the selected index existed in exactly one of the five and is now in all of them, and the tell auto-open combo lost its inline literal array in favour of a Name extension like its seven peers -- still English, but at least in the place the localisation pass will look. SettingsWidgets is constructed by each tab rather than injected. The tabs are DI singletons and a seventh constructor signature change buys nothing here. One visible difference: the tell auto-open combo was 220px wide against 200 for every other combo in the window. It is 200 now.
84 lines
2.7 KiB
C#
84 lines
2.7 KiB
C#
using Dalamud.Bindings.ImGui;
|
|
using HellionChat.Resources;
|
|
using HellionChat.Util;
|
|
|
|
namespace HellionChat.Ui.Components.Settings.Tabs;
|
|
|
|
internal sealed class ChatTab
|
|
{
|
|
private readonly Plugin _plugin;
|
|
private readonly SettingsWidgets _w;
|
|
|
|
public ChatTab(Plugin plugin)
|
|
{
|
|
_plugin = plugin;
|
|
_w = new SettingsWidgets(plugin);
|
|
}
|
|
|
|
public void Draw()
|
|
{
|
|
if (ImGui.CollapsingHeader("Display modes", ImGuiTreeNodeFlags.DefaultOpen))
|
|
{
|
|
_w.Toggle(
|
|
"Compact density (card vs compact)",
|
|
() => Plugin.Config.UseCompactDensity,
|
|
v => Plugin.Config.UseCompactDensity = v
|
|
);
|
|
_w.Toggle(
|
|
"More compact pretty mode",
|
|
() => Plugin.Config.MoreCompactPretty,
|
|
v => Plugin.Config.MoreCompactPretty = v
|
|
);
|
|
_w.Toggle(
|
|
"Prettier timestamps",
|
|
() => Plugin.Config.PrettierTimestamps,
|
|
v => Plugin.Config.PrettierTimestamps = v
|
|
);
|
|
_w.Toggle(
|
|
"Hide same timestamps",
|
|
() => Plugin.Config.HideSameTimestamps,
|
|
v => Plugin.Config.HideSameTimestamps = v
|
|
);
|
|
_w.Toggle(
|
|
"24-hour clock",
|
|
() => Plugin.Config.Use24HourClock,
|
|
v => Plugin.Config.Use24HourClock = v
|
|
);
|
|
_w.EnumCombo(
|
|
HellionStrings.Settings_Chat_WorldSuffix_Name,
|
|
() => Plugin.Config.WorldSuffixMode,
|
|
v => Plugin.Config.WorldSuffixMode = v,
|
|
v => v.Name()
|
|
);
|
|
ImGuiUtil.HelpMarker(HellionStrings.Settings_Chat_WorldSuffix_Description);
|
|
_w.EnumCombo(
|
|
HellionStrings.Settings_Chat_NameForm_Name,
|
|
() => Plugin.Config.NameFormMode,
|
|
v => Plugin.Config.NameFormMode = v,
|
|
v => v.Name()
|
|
);
|
|
ImGuiUtil.HelpMarker(HellionStrings.Settings_Chat_NameForm_Description);
|
|
}
|
|
|
|
if (ImGui.CollapsingHeader("Command help"))
|
|
{
|
|
_w.EnumCombo(
|
|
"Command help side",
|
|
() => Plugin.Config.CommandHelpSide,
|
|
v => Plugin.Config.CommandHelpSide = v,
|
|
v => v.Name()
|
|
);
|
|
}
|
|
|
|
if (ImGui.CollapsingHeader("Plugin disclosure"))
|
|
{
|
|
_w.Toggle(
|
|
HellionStrings.Settings_Chat_NotifyPluginDisclosure_Name,
|
|
() => Plugin.Config.NotifyPluginDisclosure,
|
|
v => Plugin.Config.NotifyPluginDisclosure = v
|
|
);
|
|
ImGuiUtil.HelpMarker(HellionStrings.Settings_Chat_NotifyPluginDisclosure_Description);
|
|
}
|
|
}
|
|
}
|