feat: expose RawData of text payload

This commit is contained in:
goat 2020-02-12 03:23:50 +09:00
parent bfbdaa5fc6
commit 3980929f71
3 changed files with 19 additions and 3 deletions

View file

@ -50,8 +50,6 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
// unk
bytes.AddRange(new byte[] { 0x02, 0x01, END_BYTE });
return bytes.ToArray();
}

View file

@ -11,7 +11,24 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{
public override PayloadType Type => PayloadType.RawText;
public string Text { get; set; }
private string textConverted = null;
/// <summary>
/// The Text of this text payload as an UTF-8 converted string.
/// Don't rely on this for accurate representation of SE payload data, please check RawData instead.
/// </summary>
public string Text {
get { return this.textConverted ??= Encoding.UTF8.GetString(RawData); }
set {
this.textConverted = value;
RawData = Encoding.UTF8.GetBytes(value);
}
}
/// <summary>
/// The raw unconverted data of this text payload.
/// </summary>
public byte[] RawData { get; set; }
public TextPayload() { }

View file

@ -113,6 +113,7 @@ namespace Dalamud.Game.Internal.Gui {
Log.Verbose("SeString was edited, taking precedence over StdString edit.");
message.RawData = newEdited;
}
Log.Debug($"\nOLD: {BitConverter.ToString(originalMessageData)}\nNEW: {BitConverter.ToString(newEdited)}");
var messagePtr = pMessage;
OwnedStdString allocatedString = null;