Implement Print methods that work with Lumina SeString/ReadOnlySeString (#2106)

* Implement Print methods that work with Lumina SeString/ReadOnlySeString

* null terminate before passing to Utf8String

* Rename XivChatEntryReadOnly to XivChatEntryRaw

* Fix error from wrong conversion method

* Follow Rider suggestion

* Switch from AppendMacroString to BeginMacro for optimization

* More optimization suggested by kizer

* More kizer suggested optimizations

* Fix small mistake

* Use XivChatEntry and read/write to Byte fields accordingly
This commit is contained in:
Infi 2024-11-19 03:05:28 +01:00 committed by GitHub
parent bf7ef00ec0
commit 3a3d6b6e6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 118 additions and 45 deletions

View file

@ -48,7 +48,7 @@ public interface IChatGui
/// <param name="sender">The sender name.</param>
/// <param name="message">The message sent.</param>
public delegate void OnMessageUnhandledDelegate(XivChatType type, int timestamp, SeString sender, SeString message);
/// <summary>
/// Event that will be fired when a chat message is sent to chat by the game.
/// </summary>
@ -68,17 +68,17 @@ public interface IChatGui
/// Event that will be fired when a chat message is not handled by Dalamud or a Plugin.
/// </summary>
public event OnMessageUnhandledDelegate ChatMessageUnhandled;
/// <summary>
/// Gets the ID of the last linked item.
/// </summary>
public uint LastLinkedItemId { get; }
/// <summary>
/// Gets the flags of the last linked item.
/// </summary>
public byte LastLinkedItemFlags { get; }
/// <summary>
/// Gets the dictionary of Dalamud Link Handlers.
/// </summary>
@ -121,4 +121,20 @@ public interface IChatGui
/// <param name="messageTag">String to prepend message with "[messageTag] ".</param>
/// <param name="tagColor">Color to display the message tag with.</param>
public void PrintError(SeString message, string? messageTag = null, ushort? tagColor = null);
/// <summary>
/// Queue a chat message. Dalamud will send queued messages on the next framework event.
/// </summary>
/// <param name="message">A message to send.</param>
/// <param name="messageTag">String to prepend message with "[messageTag] ".</param>
/// <param name="tagColor">Color to display the message tag with.</param>
public void Print(ReadOnlySpan<byte> message, string? messageTag = null, ushort? tagColor = null);
/// <summary>
/// Queue a chat message. Dalamud will send queued messages on the next framework event.
/// </summary>
/// <param name="message">A message to send.</param>
/// <param name="messageTag">String to prepend message with "[messageTag] ".</param>
/// <param name="tagColor">Color to display the message tag with.</param>
public void PrintError(ReadOnlySpan<byte> message, string? messageTag = null, ushort? tagColor = null);
}