refactor: change chat message API to pass parsed SeString

This commit is contained in:
goat 2020-02-12 01:20:17 +09:00
parent 3c4dad437e
commit 24cb7f014e
7 changed files with 32 additions and 36 deletions

View file

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

View file

@ -11,7 +11,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{
public override PayloadType Type => PayloadType.RawText;
public string Text { get; private set; }
public string Text { get; set; }
public TextPayload() { }

View file

@ -13,31 +13,8 @@ namespace Dalamud.Game.Chat.SeStringHandling
/// </summary>
public class SeString
{
private Dictionary<PayloadType, List<Payload>> mappedPayloads_ = null;
public List<Payload> Payloads { get; }
public Dictionary<PayloadType, List<Payload>> MappedPayloads
{
get
{
if (mappedPayloads_ == null)
{
mappedPayloads_ = new Dictionary<PayloadType, List<Payload>>();
foreach (var p in Payloads)
{
if (!mappedPayloads_.ContainsKey(p.Type))
{
mappedPayloads_[p.Type] = new List<Payload>();
}
mappedPayloads_[p.Type].Add(p);
}
}
return mappedPayloads_;
}
}
public SeString(List<Payload> payloads)
{
Payloads = payloads;
@ -93,10 +70,10 @@ namespace Dalamud.Game.Chat.SeStringHandling
/// </summary>
/// <param name="payloads"></param>
/// <returns>The bytes of the message.</returns>
public static byte[] Encode(List<Payload> payloads)
public byte[] Encode()
{
var messageBytes = new List<byte>();
foreach (var p in payloads)
foreach (var p in Payloads)
{
messageBytes.AddRange(p.Encode());
}