feat: more extrachat ipc

This commit is contained in:
Anna 2022-07-01 11:05:51 -04:00
parent b10f872ea9
commit 7c7116322c
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
2 changed files with 22 additions and 3 deletions

View File

@ -3,24 +3,39 @@ using Dalamud.Plugin.Ipc;
namespace ChatTwo.Ipc;
internal sealed class ExtraChat : IDisposable {
[Serializable]
private struct OverrideInfo {
internal string? Channel;
internal ushort UiColour;
internal uint Rgba;
public string? Channel;
public ushort UiColour;
public uint Rgba;
}
private Plugin Plugin { get; }
private ICallGateSubscriber<OverrideInfo, object> OverrideChannelGate { get; }
private ICallGateSubscriber<Dictionary<string, uint>, Dictionary<string, uint>> ChannelCommandColoursGate { get; }
internal (string, uint)? ChannelOverride { get; set; }
private Dictionary<string, uint> ChannelCommandColoursInternal { get; set; } = new();
internal IReadOnlyDictionary<string, uint> ChannelCommandColours => this.ChannelCommandColoursInternal;
internal ExtraChat(Plugin plugin) {
this.Plugin = plugin;
this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber<OverrideInfo, object>("ExtraChat.OverrideChannelColour");
this.ChannelCommandColoursGate = this.Plugin.Interface.GetIpcSubscriber<Dictionary<string, uint>, Dictionary<string, uint>>("ExtraChat.ChannelCommandColours");
this.OverrideChannelGate.Subscribe(this.OnOverrideChannel);
this.ChannelCommandColoursGate.Subscribe(this.OnChannelCommandColours);
try {
this.ChannelCommandColoursInternal = this.ChannelCommandColoursGate.InvokeFunc(null!);
} catch (Exception) {
// no-op
}
}
private void OnChannelCommandColours(Dictionary<string, uint> obj) {
this.ChannelCommandColoursInternal = obj;
}
public void Dispose() {

View File

@ -537,6 +537,10 @@ internal sealed class ChatLog : IUiComponent {
inputColour = overrideColour;
}
if (isCommand && this.Ui.Plugin.ExtraChat.ChannelCommandColours.TryGetValue(this.Chat.Split(' ')[0], out var ecColour)) {
inputColour = ecColour;
}
if (inputColour != null) {
ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(inputColour.Value));
}