From 5f7199773a4b5d4029005c9d117f8839e7274a0a Mon Sep 17 00:00:00 2001 From: Infi Date: Sun, 14 Apr 2024 20:37:01 +0200 Subject: [PATCH] Fix chat alerts breaking tell messages --- ChatTwo/ChatTwo.csproj | 2 +- ChatTwo/GameFunctions/Chat.cs | 4 ++-- ChatTwo/Ui/ChatLogWindow.cs | 1 + ChatTwo/Ui/SeStringDebugger.cs | 30 +++++++++++++++++++++++------- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index 5b42fa5..b14b0bd 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -1,6 +1,6 @@ - 1.20.5 + 1.21.0 net8.0-windows enable enable diff --git a/ChatTwo/GameFunctions/Chat.cs b/ChatTwo/GameFunctions/Chat.cs index 380c143..7c8dbea 100755 --- a/ChatTwo/GameFunctions/Chat.cs +++ b/ChatTwo/GameFunctions/Chat.cs @@ -39,7 +39,7 @@ internal sealed unsafe class Chat : IDisposable { private readonly delegate* unmanaged GetTellHistory = null!; [Signature("E8 ?? ?? ?? ?? 48 8D 4D 50 E8 ?? ?? ?? ?? 48 8B 17")] - private readonly delegate* unmanaged PrintTell = null!; + private readonly delegate* unmanaged PrintTellNative = null!; [Signature("E8 ?? ?? ?? ?? 48 8D 4C 24 ?? E8 ?? ?? ?? ?? 48 8D 8C 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? B0 01")] private readonly delegate* unmanaged SendTellNative = null!; @@ -747,8 +747,8 @@ internal sealed unsafe class Chat : IDisposable { var a1 = *(IntPtr*) (networkModule + 8); var logModule = Framework.Instance()->GetUiModule()->GetRaptureLogModule(); - PrintTell(logModule, 33, uName, uMessage, contentId, homeWorld, 255, 0, 0); SendTellNative(a1, contentId, homeWorld, uName, uMessage, (byte) reason, homeWorld); + PrintTellNative(logModule, 33, uName, uMessage, contentId, homeWorld, 255, 0, 0); uName->Dtor(true); uMessage->Dtor(true); diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index 1663542..633c24a 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -764,6 +764,7 @@ public sealed class ChatLogWindow : Window, IUiComponent { var tellBytes = Encoding.UTF8.GetBytes(trimmed); AutoTranslate.ReplaceWithPayload(Plugin.DataManager, ref tellBytes); + Plugin.Functions.Chat.SendTell(reason, target.ContentId, target.Name, (ushort) world.RowId, tellBytes); } diff --git a/ChatTwo/Ui/SeStringDebugger.cs b/ChatTwo/Ui/SeStringDebugger.cs index 38a985f..f936d1b 100644 --- a/ChatTwo/Ui/SeStringDebugger.cs +++ b/ChatTwo/Ui/SeStringDebugger.cs @@ -1,6 +1,7 @@ using System.Numerics; using System.Text; using ChatTwo.Util; +using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface.Windowing; using ImGuiNET; @@ -40,9 +41,6 @@ public class SeStringDebugger : Window public override void Draw() { - ImGui.TextUnformatted("SeString Content"); - ImGui.Spacing(); - if (Plugin.Store.LastMessage.Sender == null) { ImGui.TextUnformatted("Nothing to show"); @@ -50,7 +48,24 @@ public class SeStringDebugger : Window } // TODO: Make SeString freely selectable through chat - foreach (var payload in Plugin.Store.LastMessage.Sender.Payloads) + ImGui.TextUnformatted("Sender Content"); + ImGui.Spacing(); + if (Plugin.Store.LastMessage.Sender != null) + ProcessPayloads(Plugin.Store.LastMessage.Sender.Payloads); + else + ImGui.TextUnformatted("Nothing to show"); + + ImGui.TextUnformatted("Message Content"); + ImGui.Spacing(); + if (Plugin.Store.LastMessage.Message != null) + ProcessPayloads(Plugin.Store.LastMessage.Message.Payloads); + else + ImGui.TextUnformatted("Nothing to show"); + } + + private static void ProcessPayloads(List payloads) + { + foreach (var payload in payloads) { switch (payload) { @@ -112,9 +127,10 @@ public class SeStringDebugger : Window { RenderMetadataDictionary("Link PlayerPayload", new Dictionary { - { "Real", player.DisplayedName }, - { "PlayerName", player.PlayerName }, - { "World.Name", player.World.Name }, + { "Displayed", player.DisplayedName }, + { "Player Name", player.PlayerName }, + { "World Name", player.World.Name }, + { "Data", string.Join(" ", player.Encode().Select(b => b.ToString("X2"))) }, }); break; }