feat: more extrachat ipc
This commit is contained in:
@@ -3,24 +3,39 @@ using Dalamud.Plugin.Ipc;
|
|||||||
namespace ChatTwo.Ipc;
|
namespace ChatTwo.Ipc;
|
||||||
|
|
||||||
internal sealed class ExtraChat : IDisposable {
|
internal sealed class ExtraChat : IDisposable {
|
||||||
|
[Serializable]
|
||||||
private struct OverrideInfo {
|
private struct OverrideInfo {
|
||||||
internal string? Channel;
|
public string? Channel;
|
||||||
internal ushort UiColour;
|
public ushort UiColour;
|
||||||
internal uint Rgba;
|
public uint Rgba;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
|
||||||
private ICallGateSubscriber<OverrideInfo, object> OverrideChannelGate { get; }
|
private ICallGateSubscriber<OverrideInfo, object> OverrideChannelGate { get; }
|
||||||
|
private ICallGateSubscriber<Dictionary<string, uint>, Dictionary<string, uint>> ChannelCommandColoursGate { get; }
|
||||||
|
|
||||||
internal (string, uint)? ChannelOverride { get; set; }
|
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) {
|
internal ExtraChat(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
|
||||||
this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber<OverrideInfo, object>("ExtraChat.OverrideChannelColour");
|
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.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() {
|
public void Dispose() {
|
||||||
|
|||||||
@@ -537,6 +537,10 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
inputColour = overrideColour;
|
inputColour = overrideColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCommand && this.Ui.Plugin.ExtraChat.ChannelCommandColours.TryGetValue(this.Chat.Split(' ')[0], out var ecColour)) {
|
||||||
|
inputColour = ecColour;
|
||||||
|
}
|
||||||
|
|
||||||
if (inputColour != null) {
|
if (inputColour != null) {
|
||||||
ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(inputColour.Value));
|
ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(inputColour.Value));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user