diff --git a/Dalamud/Game/Chat/SeStringHandling/Payload.cs b/Dalamud/Game/Chat/SeStringHandling/Payload.cs index 8a37e3138..eb02e4fe3 100644 --- a/Dalamud/Game/Chat/SeStringHandling/Payload.cs +++ b/Dalamud/Game/Chat/SeStringHandling/Payload.cs @@ -178,6 +178,10 @@ namespace Dalamud.Game.Chat.SeStringHandling payload = new UIGlowPayload(); break; + case SeStringChunkType.Icon: + payload = new IconPayload(); + break; + default: Log.Verbose("Unhandled SeStringChunkType: {0}", chunkType); break; @@ -208,6 +212,7 @@ namespace Dalamud.Game.Chat.SeStringHandling protected enum SeStringChunkType { + Icon = 0x12, EmphasisItalic = 0x1A, Interactable = 0x27, AutoTranslateKey = 0x2E, diff --git a/Dalamud/Game/Chat/SeStringHandling/PayloadType.cs b/Dalamud/Game/Chat/SeStringHandling/PayloadType.cs index fe379ffd2..b3fca980e 100644 --- a/Dalamud/Game/Chat/SeStringHandling/PayloadType.cs +++ b/Dalamud/Game/Chat/SeStringHandling/PayloadType.cs @@ -43,6 +43,10 @@ namespace Dalamud.Game.Chat.SeStringHandling /// EmphasisItalic, /// + /// An SeString payload representing a bitmap icon. + /// + Icon, + /// /// An SeString payload representing any data we don't handle. /// Unknown diff --git a/Dalamud/Game/Chat/SeStringHandling/Payloads/IconPayload.cs b/Dalamud/Game/Chat/SeStringHandling/Payloads/IconPayload.cs new file mode 100644 index 000000000..3b720262b --- /dev/null +++ b/Dalamud/Game/Chat/SeStringHandling/Payloads/IconPayload.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.IO; +using Serilog; + +namespace Dalamud.Game.Chat.SeStringHandling.Payloads { + + /// + /// SeString payload representing a bitmap icon from fontIcon + /// + public class IconPayload : Payload { + + /// + /// Index of the icon + /// + public uint IconIndex { get; private set; } + + internal IconPayload() { } + + /// + /// Create a Icon payload for the specified icon. + /// + /// Index of the icon + public IconPayload(uint iconIndex) { + this.IconIndex = iconIndex; + } + + public override PayloadType Type => PayloadType.Icon; + + protected override byte[] EncodeImpl() { + var indexBytes = MakeInteger(this.IconIndex); + var chunkLen = indexBytes.Length + 1; + var bytes = new List(new byte[] { + START_BYTE, (byte)SeStringChunkType.Icon, (byte)chunkLen + }); + bytes.AddRange(indexBytes); + bytes.Add(END_BYTE); + return bytes.ToArray(); + } + + protected override void DecodeImpl(BinaryReader reader, long endOfStream) { + this.IconIndex = GetInteger(reader); + } + + public override string ToString() { + return $"{Type} - IconIndex: {this.IconIndex}"; + } + + } +}