mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Replace U+202F with Indent payload (#1761)
* Replace U+202F with Indent payload * comment --------- Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
This commit is contained in:
parent
84abd23ad5
commit
c8f65e24f0
1 changed files with 41 additions and 21 deletions
|
|
@ -62,7 +62,7 @@ internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
|
||||||
this.populateItemLinkHook.Enable();
|
this.populateItemLinkHook.Enable();
|
||||||
this.interactableLinkClickedHook.Enable();
|
this.interactableLinkClickedHook.Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||||
private delegate uint PrintMessageDelegate(RaptureLogModule* manager, XivChatType chatType, Utf8String* sender, Utf8String* message, int timestamp, byte silent);
|
private delegate uint PrintMessageDelegate(RaptureLogModule* manager, XivChatType chatType, Utf8String* sender, Utf8String* message, int timestamp, byte silent);
|
||||||
|
|
||||||
|
|
@ -122,31 +122,31 @@ internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
|
||||||
{
|
{
|
||||||
this.chatQueue.Enqueue(chat);
|
this.chatQueue.Enqueue(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Print(string message, string? messageTag = null, ushort? tagColor = null)
|
public void Print(string message, string? messageTag = null, ushort? tagColor = null)
|
||||||
{
|
{
|
||||||
this.PrintTagged(message, this.configuration.GeneralChatType, messageTag, tagColor);
|
this.PrintTagged(message, this.configuration.GeneralChatType, messageTag, tagColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Print(SeString message, string? messageTag = null, ushort? tagColor = null)
|
public void Print(SeString message, string? messageTag = null, ushort? tagColor = null)
|
||||||
{
|
{
|
||||||
this.PrintTagged(message, this.configuration.GeneralChatType, messageTag, tagColor);
|
this.PrintTagged(message, this.configuration.GeneralChatType, messageTag, tagColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void PrintError(string message, string? messageTag = null, ushort? tagColor = null)
|
public void PrintError(string message, string? messageTag = null, ushort? tagColor = null)
|
||||||
{
|
{
|
||||||
this.PrintTagged(message, XivChatType.Urgent, messageTag, tagColor);
|
this.PrintTagged(message, XivChatType.Urgent, messageTag, tagColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void PrintError(SeString message, string? messageTag = null, ushort? tagColor = null)
|
public void PrintError(SeString message, string? messageTag = null, ushort? tagColor = null)
|
||||||
{
|
{
|
||||||
this.PrintTagged(message, XivChatType.Urgent, messageTag, tagColor);
|
this.PrintTagged(message, XivChatType.Urgent, messageTag, tagColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process a chat queue.
|
/// Process a chat queue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -155,9 +155,29 @@ internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
|
||||||
while (this.chatQueue.Count > 0)
|
while (this.chatQueue.Count > 0)
|
||||||
{
|
{
|
||||||
var chat = this.chatQueue.Dequeue();
|
var chat = this.chatQueue.Dequeue();
|
||||||
|
var replacedMessage = new SeStringBuilder();
|
||||||
|
|
||||||
|
// Normalize Unicode NBSP to the built-in one, as the former won't renderl
|
||||||
|
foreach (var payload in chat.Message.Payloads)
|
||||||
|
{
|
||||||
|
if (payload is TextPayload { Text: not null } textPayload)
|
||||||
|
{
|
||||||
|
var split = textPayload.Text.Split("\u202f"); // NARROW NO-BREAK SPACE
|
||||||
|
for (var i = 0; i < split.Length; i++)
|
||||||
|
{
|
||||||
|
replacedMessage.AddText(split[i]);
|
||||||
|
if (i + 1 < split.Length)
|
||||||
|
replacedMessage.Add(new RawPayload([0x02, (byte)Lumina.Text.Payloads.PayloadType.Indent, 0x01, 0x03]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
replacedMessage.Add(payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var sender = Utf8String.FromSequence(chat.Name.Encode());
|
var sender = Utf8String.FromSequence(chat.Name.Encode());
|
||||||
var message = Utf8String.FromSequence(chat.Message.Encode());
|
var message = Utf8String.FromSequence(replacedMessage.BuiltString.Encode());
|
||||||
|
|
||||||
this.HandlePrintMessageDetour(RaptureLogModule.Instance(), chat.Type, sender, message, (int)chat.SenderId, (byte)(chat.Parameters != 0 ? 1 : 0));
|
this.HandlePrintMessageDetour(RaptureLogModule.Instance(), chat.Type, sender, message, (int)chat.SenderId, (byte)(chat.Parameters != 0 ? 1 : 0));
|
||||||
|
|
||||||
|
|
@ -194,7 +214,7 @@ internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
|
||||||
lock (this.dalamudLinkHandlers)
|
lock (this.dalamudLinkHandlers)
|
||||||
{
|
{
|
||||||
var changed = false;
|
var changed = false;
|
||||||
|
|
||||||
foreach (var handler in this.RegisteredLinkHandlers.Keys.Where(k => k.PluginName == pluginName))
|
foreach (var handler in this.RegisteredLinkHandlers.Keys.Where(k => k.PluginName == pluginName))
|
||||||
changed |= this.dalamudLinkHandlers.Remove(handler);
|
changed |= this.dalamudLinkHandlers.Remove(handler);
|
||||||
if (changed)
|
if (changed)
|
||||||
|
|
@ -231,18 +251,18 @@ internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
|
||||||
builder.AddText($"[{tag}] ");
|
builder.AddText($"[{tag}] ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Print(new XivChatEntry
|
this.Print(new XivChatEntry
|
||||||
{
|
{
|
||||||
Message = builder.AddText(message).Build(),
|
Message = builder.AddText(message).Build(),
|
||||||
Type = channel,
|
Type = channel,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrintTagged(SeString message, XivChatType channel, string? tag, ushort? color)
|
private void PrintTagged(SeString message, XivChatType channel, string? tag, ushort? color)
|
||||||
{
|
{
|
||||||
var builder = new SeStringBuilder();
|
var builder = new SeStringBuilder();
|
||||||
|
|
||||||
if (!tag.IsNullOrEmpty())
|
if (!tag.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
if (color is not null)
|
if (color is not null)
|
||||||
|
|
@ -254,7 +274,7 @@ internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
|
||||||
builder.AddText($"[{tag}] ");
|
builder.AddText($"[{tag}] ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Print(new XivChatEntry
|
this.Print(new XivChatEntry
|
||||||
{
|
{
|
||||||
Message = builder.Build().Append(message),
|
Message = builder.Build().Append(message),
|
||||||
|
|
@ -425,16 +445,16 @@ internal class ChatGuiPluginScoped : IInternalDisposableService, IChatGui
|
||||||
this.chatGuiService.ChatMessageHandled += this.OnMessageHandledForward;
|
this.chatGuiService.ChatMessageHandled += this.OnMessageHandledForward;
|
||||||
this.chatGuiService.ChatMessageUnhandled += this.OnMessageUnhandledForward;
|
this.chatGuiService.ChatMessageUnhandled += this.OnMessageUnhandledForward;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public event IChatGui.OnMessageDelegate? ChatMessage;
|
public event IChatGui.OnMessageDelegate? ChatMessage;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public event IChatGui.OnCheckMessageHandledDelegate? CheckMessageHandled;
|
public event IChatGui.OnCheckMessageHandledDelegate? CheckMessageHandled;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public event IChatGui.OnMessageHandledDelegate? ChatMessageHandled;
|
public event IChatGui.OnMessageHandledDelegate? ChatMessageHandled;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public event IChatGui.OnMessageUnhandledDelegate? ChatMessageUnhandled;
|
public event IChatGui.OnMessageUnhandledDelegate? ChatMessageUnhandled;
|
||||||
|
|
||||||
|
|
@ -460,23 +480,23 @@ internal class ChatGuiPluginScoped : IInternalDisposableService, IChatGui
|
||||||
this.ChatMessageHandled = null;
|
this.ChatMessageHandled = null;
|
||||||
this.ChatMessageUnhandled = null;
|
this.ChatMessageUnhandled = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Print(XivChatEntry chat)
|
public void Print(XivChatEntry chat)
|
||||||
=> this.chatGuiService.Print(chat);
|
=> this.chatGuiService.Print(chat);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Print(string message, string? messageTag = null, ushort? tagColor = null)
|
public void Print(string message, string? messageTag = null, ushort? tagColor = null)
|
||||||
=> this.chatGuiService.Print(message, messageTag, tagColor);
|
=> this.chatGuiService.Print(message, messageTag, tagColor);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Print(SeString message, string? messageTag = null, ushort? tagColor = null)
|
public void Print(SeString message, string? messageTag = null, ushort? tagColor = null)
|
||||||
=> this.chatGuiService.Print(message, messageTag, tagColor);
|
=> this.chatGuiService.Print(message, messageTag, tagColor);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void PrintError(string message, string? messageTag = null, ushort? tagColor = null)
|
public void PrintError(string message, string? messageTag = null, ushort? tagColor = null)
|
||||||
=> this.chatGuiService.PrintError(message, messageTag, tagColor);
|
=> this.chatGuiService.PrintError(message, messageTag, tagColor);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void PrintError(SeString message, string? messageTag = null, ushort? tagColor = null)
|
public void PrintError(SeString message, string? messageTag = null, ushort? tagColor = null)
|
||||||
=> this.chatGuiService.PrintError(message, messageTag, tagColor);
|
=> this.chatGuiService.PrintError(message, messageTag, tagColor);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue