feat(ui): add optional regex filter per tab
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using HellionChat._Helpers;
|
||||
using HellionChat.Code;
|
||||
using HellionChat.Resources;
|
||||
using HellionChat.Util;
|
||||
@@ -238,6 +240,25 @@ internal sealed class Tabs : ISettingsTab
|
||||
}
|
||||
}
|
||||
}
|
||||
// UI-8: optional regex filter for this tab.
|
||||
var regexBuffer = tab.MessageRegex ?? string.Empty;
|
||||
if (ImGui.InputText($"{HellionStrings.Settings_Tabs_MessageRegex_Name}##regex-{i}", ref regexBuffer, 256))
|
||||
tab.MessageRegex = string.IsNullOrEmpty(regexBuffer) ? null : regexBuffer;
|
||||
ImGuiUtil.HelpMarker(HellionStrings.Settings_Tabs_MessageRegex_Description);
|
||||
|
||||
// Validity feedback: the settings window is not a hot path, so a
|
||||
// per-frame Compile is fine. An invalid pattern shows a red line and
|
||||
// the tab behaves as if no regex were set.
|
||||
if (!string.IsNullOrEmpty(tab.MessageRegex))
|
||||
{
|
||||
var (_, regexError) = RegexRouteMatcher.Compile(tab.MessageRegex);
|
||||
if (regexError is not null)
|
||||
ImGui.TextColored(
|
||||
ImGuiColors.DalamudRed,
|
||||
string.Format(HellionStrings.Settings_Tabs_MessageRegex_Invalid, regexError)
|
||||
);
|
||||
}
|
||||
|
||||
ImGui.Checkbox(Language.Options_Tabs_PopOut, ref tab.PopOut);
|
||||
if (tab.PopOut)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user