feat: more extrachat ipc
This commit is contained in:
parent
1ecd45eff2
commit
807eb33ed5
|
@ -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() {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue