feat: better extrachat integration
This commit is contained in:
parent
04cb133613
commit
506baaf96d
|
@ -5,14 +5,14 @@ namespace ChatTwo.Ipc;
|
||||||
internal sealed class ExtraChat : IDisposable {
|
internal sealed class ExtraChat : IDisposable {
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
|
||||||
private ICallGateSubscriber<string?, object> OverrideChannelGate { get; }
|
private ICallGateSubscriber<(string, ushort, uint)?, object> OverrideChannelGate { get; }
|
||||||
|
|
||||||
internal string? ChannelOverride { get; set; }
|
internal (string, uint)? ChannelOverride { get; set; }
|
||||||
|
|
||||||
internal ExtraChat(Plugin plugin) {
|
internal ExtraChat(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
|
||||||
this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber<string?, object>("ExtraChat.OverrideChannel");
|
this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber<(string, ushort, uint)?, object>("ExtraChat.OverrideChannelColour");
|
||||||
|
|
||||||
this.OverrideChannelGate.Subscribe(this.OnOverrideChannel);
|
this.OverrideChannelGate.Subscribe(this.OnOverrideChannel);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,12 @@ internal sealed class ExtraChat : IDisposable {
|
||||||
this.OverrideChannelGate.Unsubscribe(this.OnOverrideChannel);
|
this.OverrideChannelGate.Unsubscribe(this.OnOverrideChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOverrideChannel(string? channel) {
|
private void OnOverrideChannel((string, ushort, uint)? info) {
|
||||||
this.ChannelOverride = channel;
|
if (info == null) {
|
||||||
|
this.ChannelOverride = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ChannelOverride = (info.Value.Item1, info.Value.Item3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -470,8 +470,8 @@ internal sealed class ChatLog : IUiComponent {
|
||||||
}
|
}
|
||||||
} else if (activeTab is { Channel: { } channel }) {
|
} else if (activeTab is { Channel: { } channel }) {
|
||||||
ImGui.TextUnformatted(channel.ToChatType().Name());
|
ImGui.TextUnformatted(channel.ToChatType().Name());
|
||||||
} else if (this.Ui.Plugin.ExtraChat.ChannelOverride is { } overriden) {
|
} else if (this.Ui.Plugin.ExtraChat.ChannelOverride is var (overrideName, _)) {
|
||||||
ImGui.TextUnformatted(overriden);
|
ImGui.TextUnformatted(overrideName);
|
||||||
} else {
|
} else {
|
||||||
this.DrawChunks(this.Ui.Plugin.Functions.Chat.Channel.name);
|
this.DrawChunks(this.Ui.Plugin.Functions.Chat.Channel.name);
|
||||||
}
|
}
|
||||||
|
@ -532,6 +532,10 @@ internal sealed class ChatLog : IUiComponent {
|
||||||
? inputCol
|
? inputCol
|
||||||
: inputType.DefaultColour();
|
: inputType.DefaultColour();
|
||||||
|
|
||||||
|
if (this.Ui.Plugin.ExtraChat.ChannelOverride is var (_, overrideColour)) {
|
||||||
|
inputColour = overrideColour;
|
||||||
|
}
|
||||||
|
|
||||||
if (inputColour != null) {
|
if (inputColour != null) {
|
||||||
ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(inputColour.Value));
|
ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(inputColour.Value));
|
||||||
}
|
}
|
||||||
|
@ -548,7 +552,7 @@ internal sealed class ChatLog : IUiComponent {
|
||||||
if (ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Escape))) {
|
if (ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Escape))) {
|
||||||
this.Chat = chatCopy;
|
this.Chat = chatCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
var enter = ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Enter))
|
var enter = ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Enter))
|
||||||
|| ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.KeyPadEnter));
|
|| ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.KeyPadEnter));
|
||||||
if (enter) {
|
if (enter) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user