The first sweep matched a character class that swallowed the digit, so a bare B1 slipped through while B1-2 was caught. Searching the whole A-Z space instead of guessing prefixes turned up 130-odd more: B0 through B6, C2, C3, D1, H2, M6, P7, P8, T2, W2, plus GP-04, KB-01, OD-1, PM-1, PM-3, SEC-01, TR-4, TR-7, UI-11, UI-12, XC-8 and API-3. Kept deliberately: 41 B4 01 is a byte signature, "N0" a format string, #L119-L128 a source anchor, LS4/LS6 are linkshells, and A=FF B=0C G=41 R=C2 explains a colour-channel order. Those look like codes and are not. Also translated the eight German comments left in the theme files and ImGuiUtil. Seven of them described what a palette does to which channel, which is worth reading -- just not in a second language in an otherwise English codebase.
90 lines
3.2 KiB
C#
90 lines
3.2 KiB
C#
using Dalamud.Plugin.Ipc;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace HellionChat.Ipc;
|
|
|
|
public sealed class ExtraChat : IDisposable
|
|
{
|
|
private readonly ILogger<ExtraChat> _logger;
|
|
|
|
#pragma warning disable CS0649 // Assigned through IPC
|
|
[Serializable]
|
|
private struct OverrideInfo
|
|
{
|
|
public string? Channel;
|
|
public ushort UiColour;
|
|
public uint Rgba;
|
|
}
|
|
#pragma warning restore CS0649
|
|
|
|
private ICallGateSubscriber<OverrideInfo, object> OverrideChannelGate { get; }
|
|
private ICallGateSubscriber<
|
|
Dictionary<string, uint>,
|
|
Dictionary<string, uint>
|
|
> ChannelCommandColoursGate { get; }
|
|
private ICallGateSubscriber<
|
|
Dictionary<Guid, string>,
|
|
Dictionary<Guid, string>
|
|
> ChannelNamesGate { get; }
|
|
|
|
internal (string, uint)? ChannelOverride { get; set; }
|
|
|
|
// volatile: IPC callbacks fire on a Dalamud thread while ImGui reads these.
|
|
// Reference assignment is atomic on x64, but the barrier ensures visibility
|
|
// across threads (especially Mono/Wine). Raised in the 2026-05-05 audit.
|
|
private volatile Dictionary<string, uint> ChannelCommandColoursInternal = new();
|
|
internal IReadOnlyDictionary<string, uint> ChannelCommandColours =>
|
|
ChannelCommandColoursInternal;
|
|
|
|
private volatile Dictionary<Guid, string> ChannelNamesInternal = new();
|
|
internal IReadOnlyDictionary<Guid, string> ChannelNames => ChannelNamesInternal;
|
|
|
|
internal ExtraChat(ILogger<ExtraChat> logger)
|
|
{
|
|
_logger = logger;
|
|
OverrideChannelGate = Plugin.Interface.GetIpcSubscriber<OverrideInfo, object>(
|
|
"ExtraChat.OverrideChannelColour"
|
|
);
|
|
ChannelCommandColoursGate = Plugin.Interface.GetIpcSubscriber<
|
|
Dictionary<string, uint>,
|
|
Dictionary<string, uint>
|
|
>("ExtraChat.ChannelCommandColours");
|
|
ChannelNamesGate = Plugin.Interface.GetIpcSubscriber<
|
|
Dictionary<Guid, string>,
|
|
Dictionary<Guid, string>
|
|
>("ExtraChat.ChannelNames");
|
|
|
|
OverrideChannelGate.Subscribe(OnOverrideChannel);
|
|
ChannelCommandColoursGate.Subscribe(OnChannelCommandColours);
|
|
ChannelNamesGate.Subscribe(OnChannelNames);
|
|
|
|
try
|
|
{
|
|
ChannelCommandColoursInternal = ChannelCommandColoursGate.InvokeFunc(null!);
|
|
ChannelNamesInternal = ChannelNamesGate.InvokeFunc(null!);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// ExtraChat is optional; IPC failure is normal when the plugin isn't loaded.
|
|
_logger.LogTrace(ex, "ExtraChat IPC initial state query failed (peer not loaded?)");
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
OverrideChannelGate.Unsubscribe(OnOverrideChannel);
|
|
ChannelCommandColoursGate.Unsubscribe(OnChannelCommandColours);
|
|
ChannelNamesGate.Unsubscribe(OnChannelNames);
|
|
}
|
|
|
|
private void OnOverrideChannel(OverrideInfo info)
|
|
{
|
|
ChannelOverride = info.Channel == null ? null : (info.Channel, info.Rgba);
|
|
}
|
|
|
|
private void OnChannelCommandColours(Dictionary<string, uint> obj) =>
|
|
ChannelCommandColoursInternal = obj;
|
|
|
|
private void OnChannelNames(Dictionary<Guid, string> obj) => ChannelNamesInternal = obj;
|
|
}
|